使用mybatis-flex重构“操作日志”模块代码
This commit is contained in:
parent
7b0f3591f0
commit
f6626d7a30
@ -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 端口 随着主应用端口飘逸 避免集群冲突
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,9 @@
|
||||
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校验注解实现
|
||||
@ -13,22 +12,9 @@ import java.util.regex.Pattern;
|
||||
*/
|
||||
public class XssValidator implements ConstraintValidator<Xss, String>
|
||||
{
|
||||
private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />";
|
||||
|
||||
@Override
|
||||
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
|
||||
{
|
||||
if (StringUtils.isBlank(value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return !containsHtml(value);
|
||||
}
|
||||
|
||||
public static boolean containsHtml(String value)
|
||||
{
|
||||
Pattern pattern = Pattern.compile(HTML_PATTERN);
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
return matcher.matches();
|
||||
return !ReUtil.contains(HtmlUtil.RE_HTML_MARK, value);
|
||||
}
|
||||
}
|
@ -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<SysOperLogVo> list(SysOperLogBo operLogBo)
|
||||
{
|
||||
startPage();
|
||||
List<SysOperLog> 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<SysOperLog> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil<SysOperLog> util = new ExcelUtil<>(SysOperLog.class);
|
||||
util.exportExcel(response, list, "操作日志");
|
||||
List<SysOperLogVo> list = operLogService.selectOperLogList(operLog);
|
||||
ExcelUtil.exportExcel(list, "操作日志", SysOperLogVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据编号获取详细信息
|
||||
* @param operId 日志id
|
||||
*/
|
||||
@SaCheckPermission("monitor:operlog:list")
|
||||
@GetMapping("/{operId}")
|
||||
public R<SysOperLogVo> getInfo(@PathVariable Long operId)
|
||||
{
|
||||
return R.ok(operLogService.selectOperLogById(operId));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -68,10 +77,15 @@ public class SysOperlogController extends BaseController
|
||||
@Log(title = "操作日志", businessType = BusinessType.DELETE)
|
||||
@SaCheckPermission("monitor:operlog:remove")
|
||||
@DeleteMapping("/{operIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] operIds)
|
||||
public R<Void> remove(@PathVariable Long[] operIds)
|
||||
{
|
||||
return toAjax(operLogService.deleteOperLogByIds(operIds));
|
||||
boolean deleted = operLogService.deleteOperLogByIds(operIds);
|
||||
if (!deleted) {
|
||||
R.fail("删除操作日志记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 清理操作日志记录
|
||||
@ -79,9 +93,12 @@ public class SysOperlogController extends BaseController
|
||||
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
|
||||
@SaCheckPermission("monitor:operlog:remove")
|
||||
@DeleteMapping("/clean")
|
||||
public AjaxResult clean()
|
||||
public R<Void> clean()
|
||||
{
|
||||
operLogService.cleanOperLog();
|
||||
return success();
|
||||
boolean cleaned = operLogService.cleanOperLog();
|
||||
if (!cleaned) {
|
||||
R.fail("清除操作日志记录失败!");
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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<String, Object> params = new HashMap<>();
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class SysOperLogBo {
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private String tenantId;
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 模块标题
|
||||
|
@ -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<SysOperLog>
|
||||
{
|
||||
/**
|
||||
* 新增操作日志
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
*/
|
||||
public void insertOperlog(SysOperLog operLog);
|
||||
|
||||
/**
|
||||
* 查询系统操作日志集合
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
public List<SysOperLog> selectOperLogList(SysOperLog operLog);
|
||||
|
||||
/**
|
||||
* 批量删除系统操作日志
|
||||
*
|
||||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteOperLogByIds(Long[] operIds);
|
||||
|
||||
/**
|
||||
* 查询操作日志详细
|
||||
*
|
||||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
public SysOperLog selectOperLogById(Long operId);
|
||||
|
||||
/**
|
||||
* 清空操作日志
|
||||
*/
|
||||
public void cleanOperLog();
|
||||
}
|
||||
|
@ -1,37 +1,50 @@
|
||||
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<SysOperLog>
|
||||
{
|
||||
/**
|
||||
* 新增操作日志
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
*/
|
||||
public void insertOperlog(SysOperLog operLog);
|
||||
void insertOperlog(SysOperLogBo operLog);
|
||||
|
||||
/**
|
||||
* 查询系统操作日志集合
|
||||
*
|
||||
* @param operLog 操作日志对象
|
||||
* @param operLogBo 操作日志对象
|
||||
* @return 操作日志集合
|
||||
*/
|
||||
public List<SysOperLog> selectOperLogList(SysOperLog operLog);
|
||||
List<SysOperLogVo> selectOperLogList(SysOperLogBo operLogBo);
|
||||
|
||||
/**
|
||||
* 分页查询系统操作日志集合
|
||||
*
|
||||
* @param operLogBo 操作日志对象
|
||||
* @return 分页操作日志对象集合
|
||||
*/
|
||||
TableDataInfo<SysOperLogVo> selectPage(SysOperLogBo operLogBo);
|
||||
|
||||
/**
|
||||
* 批量删除系统操作日志
|
||||
*
|
||||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
* @return 结果:true 删除成功,false 删除失败。
|
||||
*/
|
||||
public int deleteOperLogByIds(Long[] operIds);
|
||||
boolean deleteOperLogByIds(Long[] operIds);
|
||||
|
||||
/**
|
||||
* 查询操作日志详细
|
||||
@ -39,10 +52,10 @@ public interface ISysOperLogService
|
||||
* @param operId 操作ID
|
||||
* @return 操作日志对象
|
||||
*/
|
||||
public SysOperLog selectOperLogById(Long operId);
|
||||
SysOperLogVo selectOperLogById(Long operId);
|
||||
|
||||
/**
|
||||
* 清空操作日志
|
||||
*/
|
||||
public void cleanOperLog();
|
||||
boolean cleanOperLog();
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ public class SysDeptServiceImpl extends BaseServiceImpl<SysDeptMapper, SysDept>
|
||||
*/
|
||||
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())) {
|
||||
|
@ -116,7 +116,7 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据noticeBo构建QueryWrapper查询条件
|
||||
* 根据logininforBo构建QueryWrapper查询条件
|
||||
*
|
||||
* @param logininforBo
|
||||
* @return 查询条件
|
||||
|
@ -56,7 +56,6 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
|
||||
*/
|
||||
private QueryWrapper buildQueryWrapper(SysNoticeBo noticeBo) {
|
||||
QueryWrapper queryWrapper = super.buildBaseQueryWrapper();
|
||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
||||
|
||||
if (StringUtils.isNotEmpty(noticeBo.getNoticeTitle())) {
|
||||
queryWrapper.and(SYS_NOTICE.NOTICE_TITLE.like(noticeBo.getNoticeTitle()));
|
||||
@ -68,10 +67,6 @@ public class SysNoticeServiceImpl extends BaseServiceImpl<SysNoticeMapper, SysNo
|
||||
queryWrapper.and(SYS_NOTICE.CREATE_BY.like(noticeBo.getCreateBy()));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
|
||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
||||
queryWrapper.orderBy(orderBy);
|
||||
}
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
@ -1,56 +1,144 @@
|
||||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.ruoyi.common.core.utils.MapstructUtils;
|
||||
import com.ruoyi.common.core.utils.StringUtils;
|
||||
import com.ruoyi.common.core.utils.ip.AddressUtils;
|
||||
import com.ruoyi.common.log.event.OperLogEvent;
|
||||
import com.ruoyi.common.orm.core.page.PageQuery;
|
||||
import com.ruoyi.common.orm.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
|
||||
import com.ruoyi.system.domain.bo.SysOperLogBo;
|
||||
import com.ruoyi.system.domain.vo.SysOperLogVo;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.system.domain.SysOperLog;
|
||||
import com.ruoyi.system.mapper.SysOperLogMapper;
|
||||
import com.ruoyi.system.service.ISysOperLogService;
|
||||
|
||||
import static com.ruoyi.system.domain.table.SysOperLogTableDef.SYS_OPER_LOG;
|
||||
|
||||
/**
|
||||
* 操作日志 服务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
public class SysOperLogServiceImpl implements ISysOperLogService
|
||||
public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLogMapper, SysOperLog> 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<String, Object> 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<SysOperLog> selectOperLogList(SysOperLog operLog)
|
||||
public List<SysOperLogVo> selectOperLogList(SysOperLogBo operLogBo)
|
||||
{
|
||||
return operLogMapper.selectOperLogList(operLog);
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(operLogBo);
|
||||
return this.listAs(queryWrapper, SysOperLogVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询系统操作日志集合
|
||||
*
|
||||
* @param operLogBo 操作日志对象
|
||||
* @return 分页操作日志对象集合
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysOperLogVo> selectPage(SysOperLogBo operLogBo) {
|
||||
QueryWrapper queryWrapper = buildQueryWrapper(operLogBo);
|
||||
Page<SysOperLogVo> 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));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,17 +148,21 @@ public class SysOperLogServiceImpl implements ISysOperLogService
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,6 @@ public class SysPostServiceImpl extends BaseServiceImpl<SysPostMapper, SysPost>
|
||||
*/
|
||||
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<SysPostMapper, SysPost>
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -4,81 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.system.mapper.SysOperLogMapper">
|
||||
|
||||
<resultMap type="SysOperLog" id="SysOperLogResult">
|
||||
<id property="operId" column="oper_id" />
|
||||
<result property="title" column="title" />
|
||||
<result property="businessType" column="business_type" />
|
||||
<result property="method" column="method" />
|
||||
<result property="requestMethod" column="request_method" />
|
||||
<result property="operatorType" column="operator_type" />
|
||||
<result property="operName" column="oper_name" />
|
||||
<result property="deptName" column="dept_name" />
|
||||
<result property="operUrl" column="oper_url" />
|
||||
<result property="operIp" column="oper_ip" />
|
||||
<result property="operLocation" column="oper_location" />
|
||||
<result property="operParam" column="oper_param" />
|
||||
<result property="jsonResult" column="json_result" />
|
||||
<result property="status" column="status" />
|
||||
<result property="errorMsg" column="error_msg" />
|
||||
<result property="operTime" column="oper_time" />
|
||||
<result property="costTime" column="cost_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectOperLogVo">
|
||||
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
|
||||
</sql>
|
||||
|
||||
<insert id="insertOperlog" parameterType="SysOperLog">
|
||||
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())
|
||||
</insert>
|
||||
|
||||
<select id="selectOperLogList" parameterType="SysOperLog" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''">
|
||||
AND title like concat('%', #{title}, '%')
|
||||
</if>
|
||||
<if test="businessType != null">
|
||||
AND business_type = #{businessType}
|
||||
</if>
|
||||
<if test="businessTypes != null and businessTypes.length > 0">
|
||||
AND business_type in
|
||||
<foreach collection="businessTypes" item="businessType" open="(" separator="," close=")">
|
||||
#{businessType}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="operName != null and operName != ''">
|
||||
AND oper_name like concat('%', #{operName}, '%')
|
||||
</if>
|
||||
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
|
||||
AND oper_time >= #{params.beginTime}
|
||||
</if>
|
||||
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
|
||||
AND oper_time <= #{params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
order by oper_id desc
|
||||
</select>
|
||||
|
||||
<delete id="deleteOperLogByIds" parameterType="Long">
|
||||
delete from sys_oper_log where oper_id in
|
||||
<foreach collection="array" item="operId" open="(" separator="," close=")">
|
||||
#{operId}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectOperLogById" parameterType="Long" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
where oper_id = #{operId}
|
||||
</select>
|
||||
|
||||
<update id="cleanOperLog">
|
||||
truncate table sys_oper_log
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -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({
|
||||
|
@ -38,12 +38,11 @@
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="['00:00:00', '23:59:59']"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
|
@ -53,12 +53,11 @@
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
style="width: 240px"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="['00:00:00', '23:59:59']"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
@ -129,9 +128,10 @@
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
type="text"
|
||||
link
|
||||
type="primary"
|
||||
icon="View"
|
||||
@click="handleView(scope.row,scope.index)"
|
||||
@click="handleView(scope.row)"
|
||||
v-hasPermi="['monitor:operlog:query']"
|
||||
>详细</el-button>
|
||||
</template>
|
||||
@ -147,8 +147,8 @@
|
||||
/>
|
||||
|
||||
<!-- 操作日志详细 -->
|
||||
<el-dialog title="操作日志详细" :visible.sync="open" width="700px" append-to-body>
|
||||
<el-form ref="form" :model="form" label-width="100px" >
|
||||
<el-dialog title="操作日志详细" v-model="open" width="700px" append-to-body>
|
||||
<el-form :model="form" label-width="100px" >
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="操作模块:">{{ form.title }} / {{ typeFormat(form) }}</el-form-item>
|
||||
@ -186,16 +186,17 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="open = false">关 闭</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { list, delOperlog, cleanOperlog } from "@/api/monitor/operlog";
|
||||
import {getCurrentInstance, reactive, ref, toRefs} from "vue";
|
||||
import { list, getOperlog, delOperlog, cleanOperlog } from "@/api/monitor/operlog";
|
||||
const { proxy } = getCurrentInstance();
|
||||
const { sys_oper_type, sys_common_status } = proxy.useDict("sys_oper_type","sys_common_status");
|
||||
|
||||
@ -263,8 +264,11 @@ function handleSortChange(column, prop, order) {
|
||||
}
|
||||
/** 详细按钮操作 */
|
||||
function handleView(row) {
|
||||
const operId = row.operId || ids.value;
|
||||
getOperlog(operId).then(response => {
|
||||
open.value = true;
|
||||
form.value = row;
|
||||
form.value = response.data;
|
||||
});
|
||||
}
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
|
Loading…
Reference in New Issue
Block a user