diff --git a/ruoyi-admin/src/main/resources/application-dev.yml b/ruoyi-admin/src/main/resources/application-dev.yml index 7300b5b..b55bd50 100644 --- a/ruoyi-admin/src/main/resources/application-dev.yml +++ b/ruoyi-admin/src/main/resources/application-dev.yml @@ -117,7 +117,7 @@ management: --- # 监控中心客户端配置 spring.boot.admin.client: # 增加客户端开关 - enabled: false + enabled: true url: http://localhost:9090/admin instance: service-host-type: IP @@ -128,7 +128,7 @@ spring.boot.admin.client: powerjob: worker: # 如何开启调度中心请查看文档教程 - enabled: false + enabled: true # 需要先在 powerjob 登录页执行应用注册后才能使用 app-name: ruoyi-worker # 28080 端口 随着主应用端口飘逸 避免集群冲突 diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StringUtils.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StringUtils.java index a4398e8..7f9e5ff 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StringUtils.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/StringUtils.java @@ -384,48 +384,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils */ public static String toUnderScoreCase(String str) { - if (str == null) - { - return null; - } - StringBuilder sb = new StringBuilder(); - // 前置字符是否大写 - boolean preCharIsUpperCase = true; - // 当前字符是否大写 - boolean curreCharIsUpperCase = true; - // 下一字符是否大写 - boolean nexteCharIsUpperCase = true; - for (int i = 0; i < str.length(); i++) - { - char c = str.charAt(i); - if (i > 0) - { - preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1)); - } - else - { - preCharIsUpperCase = false; - } - - curreCharIsUpperCase = Character.isUpperCase(c); - - if (i < (str.length() - 1)) - { - nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1)); - } - - if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) - { - sb.append(SEPARATOR); - } - else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) - { - sb.append(SEPARATOR); - } - sb.append(Character.toLowerCase(c)); - } - - return sb.toString(); + return StrUtil.toUnderlineCase(str); } /** diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java index 11a37ac..5fbd758 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/xss/XssValidator.java @@ -1,34 +1,20 @@ package com.ruoyi.common.core.xss; -import com.ruoyi.common.core.utils.StringUtils; +import cn.hutool.core.util.ReUtil; +import cn.hutool.http.HtmlUtil; import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; -import java.util.regex.Matcher; -import java.util.regex.Pattern; /** * 自定义xss校验注解实现 - * + * * @author ruoyi */ public class XssValidator implements ConstraintValidator { - private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />"; - @Override public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) { - if (StringUtils.isBlank(value)) - { - return true; - } - return !containsHtml(value); + return !ReUtil.contains(HtmlUtil.RE_HTML_MARK, value); } - - public static boolean containsHtml(String value) - { - Pattern pattern = Pattern.compile(HTML_PATTERN); - Matcher matcher = pattern.matcher(value); - return matcher.matches(); - } -} \ No newline at end of file +} diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/SysOperlogController.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/SysOperlogController.java index f62cebe..aec31e2 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/SysOperlogController.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/controller/monitor/SysOperlogController.java @@ -3,12 +3,16 @@ package com.ruoyi.system.controller.monitor; import java.util.List; import cn.dev33.satoken.annotation.SaCheckPermission; +import com.ruoyi.common.core.core.domain.R; +import com.ruoyi.common.excel.utils.ExcelUtil; import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.orm.core.page.TableDataInfo; +import com.ruoyi.system.domain.bo.SysOperLogBo; +import com.ruoyi.system.domain.vo.SysOperLogVo; +import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -17,9 +21,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.web.core.BaseController; -import com.ruoyi.common.core.core.domain.AjaxResult; -import com.ruoyi.common.core.utils.poi.ExcelUtil; -import com.ruoyi.system.domain.SysOperLog; import com.ruoyi.system.service.ISysOperLogService; /** @@ -33,7 +34,7 @@ import com.ruoyi.system.service.ISysOperLogService; @RequestMapping("/monitor/operlog") public class SysOperlogController extends BaseController { - @Autowired + @Resource private ISysOperLogService operLogService; /** @@ -41,11 +42,9 @@ public class SysOperlogController extends BaseController */ @SaCheckPermission("monitor:operlog:list") @GetMapping("/list") - public TableDataInfo list(SysOperLog operLog) + public TableDataInfo list(SysOperLogBo operLogBo) { - startPage(); - List list = operLogService.selectOperLogList(operLog); - return getDataTable(list); + return operLogService.selectPage(operLogBo); } /** @@ -54,11 +53,21 @@ public class SysOperlogController extends BaseController @Log(title = "操作日志", businessType = BusinessType.EXPORT) @SaCheckPermission("monitor:operlog:export") @PostMapping("/export") - public void export(HttpServletResponse response, SysOperLog operLog) + public void export(HttpServletResponse response, SysOperLogBo operLog) { - List list = operLogService.selectOperLogList(operLog); - ExcelUtil util = new ExcelUtil<>(SysOperLog.class); - util.exportExcel(response, list, "操作日志"); + List list = operLogService.selectOperLogList(operLog); + ExcelUtil.exportExcel(list, "操作日志", SysOperLogVo.class, response); + } + + /** + * 根据编号获取详细信息 + * @param operId 日志id + */ + @SaCheckPermission("monitor:operlog:list") + @GetMapping("/{operId}") + public R getInfo(@PathVariable Long operId) + { + return R.ok(operLogService.selectOperLogById(operId)); } /** @@ -68,20 +77,28 @@ public class SysOperlogController extends BaseController @Log(title = "操作日志", businessType = BusinessType.DELETE) @SaCheckPermission("monitor:operlog:remove") @DeleteMapping("/{operIds}") - public AjaxResult remove(@PathVariable Long[] operIds) + public R remove(@PathVariable Long[] operIds) { - return toAjax(operLogService.deleteOperLogByIds(operIds)); + boolean deleted = operLogService.deleteOperLogByIds(operIds); + if (!deleted) { + R.fail("删除操作日志记录失败!"); + } + return R.ok(); } + /** * 清理操作日志记录 */ @Log(title = "操作日志", businessType = BusinessType.CLEAN) @SaCheckPermission("monitor:operlog:remove") @DeleteMapping("/clean") - public AjaxResult clean() + public R clean() { - operLogService.cleanOperLog(); - return success(); + boolean cleaned = operLogService.cleanOperLog(); + if (!cleaned) { + R.fail("清除操作日志记录失败!"); + } + return R.ok(); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java index 9270568..bbe152f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java @@ -1,6 +1,7 @@ package com.ruoyi.system.domain; import java.io.Serial; +import java.io.Serializable; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -17,7 +18,7 @@ import lombok.Data; */ @Data @Table(value = "sys_logininfor") -public class SysLogininfor +public class SysLogininfor implements Serializable { @Serial private static final long serialVersionUID = 1L; diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java index ac4b445..97e648f 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java @@ -1,269 +1,89 @@ package com.ruoyi.system.domain; +import java.io.Serial; +import java.io.Serializable; import java.util.Date; +import java.util.HashMap; +import java.util.Map; + import com.fasterxml.jackson.annotation.JsonFormat; +import com.mybatisflex.annotation.Id; +import com.mybatisflex.annotation.Table; import com.ruoyi.common.core.annotation.Excel; import com.ruoyi.common.core.annotation.Excel.ColumnType; import com.ruoyi.common.orm.core.domain.BaseEntity; +import lombok.Data; /** * 操作日志记录表 oper_log * * @author ruoyi */ -public class SysOperLog extends BaseEntity +@Data +@Table(value = "sys_oper_log") +public class SysOperLog implements Serializable { + @Serial private static final long serialVersionUID = 1L; /** 日志主键 */ - @Excel(name = "操作序号", cellType = ColumnType.NUMERIC) + @Id private Long operId; /** 操作模块 */ - @Excel(name = "操作模块") private String title; /** 业务类型(0其它 1新增 2修改 3删除) */ - @Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据") private Integer businessType; /** 业务类型数组 */ private Integer[] businessTypes; /** 请求方法 */ - @Excel(name = "请求方法") private String method; /** 请求方式 */ - @Excel(name = "请求方式") private String requestMethod; /** 操作类别(0其它 1后台用户 2手机端用户) */ - @Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户") private Integer operatorType; /** 操作人员 */ - @Excel(name = "操作人员") private String operName; /** 部门名称 */ - @Excel(name = "部门名称") private String deptName; /** 请求url */ - @Excel(name = "请求地址") private String operUrl; /** 操作地址 */ - @Excel(name = "操作地址") private String operIp; /** 操作地点 */ - @Excel(name = "操作地点") private String operLocation; /** 请求参数 */ - @Excel(name = "请求参数") private String operParam; /** 返回参数 */ - @Excel(name = "返回参数") private String jsonResult; /** 操作状态(0正常 1异常) */ - @Excel(name = "状态", readConverterExp = "0=正常,1=异常") private Integer status; /** 错误消息 */ - @Excel(name = "错误消息") private String errorMsg; /** 操作时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") private Date operTime; /** 消耗时间 */ - @Excel(name = "消耗时间", suffix = "毫秒") private Long costTime; - public Long getOperId() - { - return operId; - } - - public void setOperId(Long operId) - { - this.operId = operId; - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } - - public Integer getBusinessType() - { - return businessType; - } - - public void setBusinessType(Integer businessType) - { - this.businessType = businessType; - } - - public Integer[] getBusinessTypes() - { - return businessTypes; - } - - public void setBusinessTypes(Integer[] businessTypes) - { - this.businessTypes = businessTypes; - } - - public String getMethod() - { - return method; - } - - public void setMethod(String method) - { - this.method = method; - } - - public String getRequestMethod() - { - return requestMethod; - } - - public void setRequestMethod(String requestMethod) - { - this.requestMethod = requestMethod; - } - - public Integer getOperatorType() - { - return operatorType; - } - - public void setOperatorType(Integer operatorType) - { - this.operatorType = operatorType; - } - - public String getOperName() - { - return operName; - } - - public void setOperName(String operName) - { - this.operName = operName; - } - - public String getDeptName() - { - return deptName; - } - - public void setDeptName(String deptName) - { - this.deptName = deptName; - } - - public String getOperUrl() - { - return operUrl; - } - - public void setOperUrl(String operUrl) - { - this.operUrl = operUrl; - } - - public String getOperIp() - { - return operIp; - } - - public void setOperIp(String operIp) - { - this.operIp = operIp; - } - - public String getOperLocation() - { - return operLocation; - } - - public void setOperLocation(String operLocation) - { - this.operLocation = operLocation; - } - - public String getOperParam() - { - return operParam; - } - - public void setOperParam(String operParam) - { - this.operParam = operParam; - } - - public String getJsonResult() - { - return jsonResult; - } - - public void setJsonResult(String jsonResult) - { - this.jsonResult = jsonResult; - } - - public Integer getStatus() - { - return status; - } - - public void setStatus(Integer status) - { - this.status = status; - } - - public String getErrorMsg() - { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) - { - this.errorMsg = errorMsg; - } - - public Date getOperTime() - { - return operTime; - } - - public void setOperTime(Date operTime) - { - this.operTime = operTime; - } - - public Long getCostTime() - { - return costTime; - } - - public void setCostTime(Long costTime) - { - this.costTime = costTime; - } + /** + * 请求参数 + */ + private Map params = new HashMap<>(); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/bo/SysOperLogBo.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/bo/SysOperLogBo.java index 4ebdb86..038dcc4 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/bo/SysOperLogBo.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/domain/bo/SysOperLogBo.java @@ -32,7 +32,7 @@ public class SysOperLogBo { /** * 租户编号 */ - private String tenantId; + private Long tenantId; /** * 模块标题 diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java index 2ae6457..898d5e6 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java @@ -1,48 +1,17 @@ package com.ruoyi.system.mapper; -import java.util.List; + +import com.mybatisflex.core.BaseMapper; import com.ruoyi.system.domain.SysOperLog; +import org.apache.ibatis.annotations.Mapper; /** * 操作日志 数据层 - * + * * @author ruoyi */ -public interface SysOperLogMapper +@Mapper +public interface SysOperLogMapper extends BaseMapper { - /** - * 新增操作日志 - * - * @param operLog 操作日志对象 - */ - public void insertOperlog(SysOperLog operLog); - /** - * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 - * @return 操作日志集合 - */ - public List selectOperLogList(SysOperLog operLog); - - /** - * 批量删除系统操作日志 - * - * @param operIds 需要删除的操作日志ID - * @return 结果 - */ - public int deleteOperLogByIds(Long[] operIds); - - /** - * 查询操作日志详细 - * - * @param operId 操作ID - * @return 操作日志对象 - */ - public SysOperLog selectOperLogById(Long operId); - - /** - * 清空操作日志 - */ - public void cleanOperLog(); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java index 4fd8e5a..bc75669 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java @@ -1,48 +1,61 @@ package com.ruoyi.system.service; import java.util.List; + +import com.ruoyi.common.orm.core.page.TableDataInfo; +import com.ruoyi.common.orm.core.service.IBaseService; import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.domain.bo.SysOperLogBo; +import com.ruoyi.system.domain.vo.SysOperLogVo; /** * 操作日志 服务层 - * + * * @author ruoyi */ -public interface ISysOperLogService +public interface ISysOperLogService extends IBaseService { /** * 新增操作日志 - * + * * @param operLog 操作日志对象 */ - public void insertOperlog(SysOperLog operLog); + void insertOperlog(SysOperLogBo operLog); /** * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 + * + * @param operLogBo 操作日志对象 * @return 操作日志集合 */ - public List selectOperLogList(SysOperLog operLog); + List selectOperLogList(SysOperLogBo operLogBo); + + /** + * 分页查询系统操作日志集合 + * + * @param operLogBo 操作日志对象 + * @return 分页操作日志对象集合 + */ + TableDataInfo selectPage(SysOperLogBo operLogBo); /** * 批量删除系统操作日志 - * + * * @param operIds 需要删除的操作日志ID - * @return 结果 + * @return 结果:true 删除成功,false 删除失败。 */ - public int deleteOperLogByIds(Long[] operIds); + boolean deleteOperLogByIds(Long[] operIds); /** * 查询操作日志详细 - * + * * @param operId 操作ID * @return 操作日志对象 */ - public SysOperLog selectOperLogById(Long operId); + SysOperLogVo selectOperLogById(Long operId); /** * 清空操作日志 */ - public void cleanOperLog(); + boolean cleanOperLog(); } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 43e42c9..7b30e74 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -69,7 +69,6 @@ public class SysDeptServiceImpl extends BaseServiceImpl */ private QueryWrapper buildQueryWrapper(SysDeptBo deptBo) { QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); - PageDomain pageDomain = TableSupport.buildPageRequest(); queryWrapper.where(SYS_DEPT.DEL_FLAG.eq("0")); if (ObjectUtil.isNotNull(deptBo.getDeptId())) { diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java index 51d86a8..3fceaee 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java @@ -116,7 +116,7 @@ public class SysLogininforServiceImpl extends BaseServiceImpl implements ISysOperLogService { - @Autowired - private SysOperLogMapper operLogMapper; + @Override + public QueryWrapper query() { + return super.query().from(SYS_OPER_LOG); + } + + /** + * 操作日志记录 + * + * @param operLogEvent 操作日志事件 + */ + @Async + @EventListener + public void recordLog(OperLogEvent operLogEvent) { + SysOperLogBo operLog = MapstructUtils.convert(operLogEvent, SysOperLogBo.class); + // 远程查询操作地点 + operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp())); + insertOperlog(operLog); + } /** * 新增操作日志 - * - * @param operLog 操作日志对象 + * + * @param operLogBo 操作日志对象 */ @Override - public void insertOperlog(SysOperLog operLog) + public void insertOperlog(SysOperLogBo operLogBo) { - operLogMapper.insertOperlog(operLog); + SysOperLog operLog = MapstructUtils.convert(operLogBo, SysOperLog.class); + operLog.setOperTime(new Date()); + this.save(operLog); + } + + /** + * 根据operLogBo构建QueryWrapper查询条件 + * + * @param operLogBo + * @return 查询条件 + */ + private QueryWrapper buildQueryWrapper(SysOperLogBo operLogBo) { + QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); + + if (StringUtils.isNotEmpty(operLogBo.getTitle())) { + queryWrapper.and(SYS_OPER_LOG.TITLE.like(operLogBo.getTitle())); + } + if (ObjectUtil.isNotEmpty(operLogBo.getBusinessType())) { + queryWrapper.and(SYS_OPER_LOG.BUSINESS_TYPE.eq(operLogBo.getBusinessType())); + } + if (ArrayUtil.isNotEmpty(operLogBo.getBusinessTypes())) { + queryWrapper.and(SYS_OPER_LOG.BUSINESS_TYPE.in(Arrays.asList(operLogBo.getBusinessTypes()))); + } + + if (ObjectUtil.isNotNull(operLogBo.getStatus())) { + queryWrapper.and(SYS_OPER_LOG.STATUS.eq(operLogBo.getStatus())); + } + + if (ObjectUtil.isNotNull(operLogBo.getOperName())) { + queryWrapper.and(SYS_OPER_LOG.OPER_NAME.eq(operLogBo.getOperName())); + } + + Map params = operLogBo.getParams(); + if (params.get("beginTime") != null && params.get("endTime") != null) { + queryWrapper.and(SYS_OPER_LOG.OPER_TIME.between(params.get("beginTime"), params.get("endTime"))); + } + queryWrapper.orderBy(SYS_OPER_LOG.OPER_ID.desc()); + + return queryWrapper; } /** * 查询系统操作日志集合 - * - * @param operLog 操作日志对象 + * + * @param operLogBo 操作日志对象 * @return 操作日志集合 */ @Override - public List selectOperLogList(SysOperLog operLog) + public List selectOperLogList(SysOperLogBo operLogBo) { - return operLogMapper.selectOperLogList(operLog); + QueryWrapper queryWrapper = buildQueryWrapper(operLogBo); + return this.listAs(queryWrapper, SysOperLogVo.class); + } + + /** + * 分页查询系统操作日志集合 + * + * @param operLogBo 操作日志对象 + * @return 分页操作日志对象集合 + */ + @Override + public TableDataInfo selectPage(SysOperLogBo operLogBo) { + QueryWrapper queryWrapper = buildQueryWrapper(operLogBo); + Page page = this.pageAs(PageQuery.build(), queryWrapper, SysOperLogVo.class); + return TableDataInfo.build(page); } /** * 批量删除系统操作日志 - * + * delete from sys_oper_log where oper_id in * @param operIds 需要删除的操作日志ID - * @return 结果 + * @return 结果:true 删除成功,false 删除失败。 */ @Override - public int deleteOperLogByIds(Long[] operIds) + public boolean deleteOperLogByIds(Long[] operIds) { - return operLogMapper.deleteOperLogByIds(operIds); + return this.removeByIds(Arrays.asList(operIds)); } /** * 查询操作日志详细 - * + * * @param operId 操作ID * @return 操作日志对象 */ @Override - public SysOperLog selectOperLogById(Long operId) + public SysOperLogVo selectOperLogById(Long operId) { - return operLogMapper.selectOperLogById(operId); + QueryWrapper queryWrapper = query(); + queryWrapper.where(SYS_OPER_LOG.OPER_ID.eq(operId)); + return this.getOneAs(queryWrapper, SysOperLogVo.class); } /** * 清空操作日志 + * delete from sys_oper_log where oper_id>0 */ @Override - public void cleanOperLog() + public boolean cleanOperLog() { - operLogMapper.cleanOperLog(); + QueryWrapper queryWrapper = query().from(SYS_OPER_LOG).where(SYS_OPER_LOG.OPER_ID.gt(0)); + return this.remove(queryWrapper); } } diff --git a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index ae05162..4ac9e3b 100644 --- a/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -53,7 +53,6 @@ public class SysPostServiceImpl extends BaseServiceImpl */ private QueryWrapper buildQueryWrapper(SysPostBo postBo) { QueryWrapper queryWrapper = super.buildBaseQueryWrapper(); - PageDomain pageDomain = TableSupport.buildPageRequest(); if (StringUtils.isNotEmpty(postBo.getPostCode())) { queryWrapper.and(SYS_POST.POST_CODE.like(postBo.getPostCode())); @@ -65,10 +64,6 @@ public class SysPostServiceImpl extends BaseServiceImpl queryWrapper.and(SYS_POST.POST_NAME.like(postBo.getPostName())); } - if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) { - String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); - queryWrapper.orderBy(orderBy); - } return queryWrapper; } diff --git a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml index 96bc621..fe357d0 100644 --- a/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml +++ b/ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml @@ -4,81 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - - - - - - - - - - - - - - - - - - - - - - select oper_id, title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time, cost_time - from sys_oper_log - - - - insert into sys_oper_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, cost_time, oper_time) - values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, #{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, #{costTime}, sysdate()) - - - - - - delete from sys_oper_log where oper_id in - - #{operId} - - - - - - - truncate table sys_oper_log - - - \ No newline at end of file + diff --git a/ruoyi-ui/src/api/monitor/operlog.js b/ruoyi-ui/src/api/monitor/operlog.js index a04bca8..2288205 100644 --- a/ruoyi-ui/src/api/monitor/operlog.js +++ b/ruoyi-ui/src/api/monitor/operlog.js @@ -9,6 +9,14 @@ export function list(query) { }) } +// 查询单个操作日志 +export function getOperlog(operId) { + return request({ + url: '/monitor/operlog/' + operId, + method: 'get' + }) +} + // 删除操作日志 export function delOperlog(operId) { return request({ diff --git a/ruoyi-ui/src/views/monitor/logininfor/index.vue b/ruoyi-ui/src/views/monitor/logininfor/index.vue index f21eeee..2a05150 100644 --- a/ruoyi-ui/src/views/monitor/logininfor/index.vue +++ b/ruoyi-ui/src/views/monitor/logininfor/index.vue @@ -38,12 +38,11 @@ diff --git a/ruoyi-ui/src/views/monitor/operlog/index.vue b/ruoyi-ui/src/views/monitor/operlog/index.vue index fcf3e42..03672a1 100644 --- a/ruoyi-ui/src/views/monitor/operlog/index.vue +++ b/ruoyi-ui/src/views/monitor/operlog/index.vue @@ -53,12 +53,11 @@ @@ -129,9 +128,10 @@ @@ -147,8 +147,8 @@ /> - - + + {{ form.title }} / {{ typeFormat(form) }} @@ -186,16 +186,17 @@ - +