系统日志
This commit is contained in:
parent
60ac3a5fed
commit
8e5fc3fe1f
|
|
@ -0,0 +1,65 @@
|
|||
package com.securitycontrol.system.api.domain;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author:cwchen
|
||||
* @date:2024-02-28-14:14
|
||||
* @version:1.0
|
||||
* @description:系统日志
|
||||
*/
|
||||
@Data
|
||||
public class SysLog {
|
||||
|
||||
@ApiModelProperty(value = "日志ID")
|
||||
private String logId;
|
||||
|
||||
@ApiModelProperty(value = "操作ip")
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private Integer userId;
|
||||
|
||||
@ApiModelProperty(value = "操作人")
|
||||
private String operaUserName;
|
||||
|
||||
@ApiModelProperty(value = "操作模块")
|
||||
private String model;
|
||||
|
||||
@ApiModelProperty(value = "操作时间")
|
||||
private String operTime;
|
||||
|
||||
@ApiModelProperty(value = "执行方法")
|
||||
private String method;
|
||||
|
||||
@ApiModelProperty(value = "操作参数")
|
||||
private String params;
|
||||
|
||||
@ApiModelProperty(value = "操作详情")
|
||||
private String operateDetail;
|
||||
|
||||
@ApiModelProperty(value = "操作类型 增删改查 登陆 登出")
|
||||
private String operType;
|
||||
|
||||
@ApiModelProperty(value = "操作页面路径URI")
|
||||
private String operUri;
|
||||
|
||||
@ApiModelProperty(value = "日志类型 1 业务日志 0 系统日志 2异常日志")
|
||||
private String logType;
|
||||
|
||||
@ApiModelProperty(value = "执行结果(1.成功/2.失败)")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty(value = "执行时间(秒/ms)")
|
||||
private String times;
|
||||
|
||||
@ApiModelProperty(value = "失败原因")
|
||||
private String failureReason;
|
||||
|
||||
@ApiModelProperty(value = "异常事件等级(高、中、低")
|
||||
private String grade;
|
||||
|
||||
@ApiModelProperty(value = "异常类型(ip异常/越权)")
|
||||
private String errType;
|
||||
}
|
||||
|
|
@ -1,10 +1,32 @@
|
|||
package com.securitycontrol.system.base.controller;
|
||||
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.system.api.domain.SysLog;
|
||||
import com.securitycontrol.system.base.service.ISysLogService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author:cwchen
|
||||
* @date:2024-02-28-14:01
|
||||
* @version:1.0
|
||||
* @description:系统日志
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/sysLog/")
|
||||
public class SysLogController {
|
||||
|
||||
@Resource(name = "ISysLogService")
|
||||
private ISysLogService service;
|
||||
|
||||
@ApiOperation(value = "保存系统日志")
|
||||
@PostMapping("saveLogs")
|
||||
public AjaxResult saveLogs(@RequestBody SysLog sysLog) {
|
||||
return service.saveLogs(sysLog);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,23 @@
|
|||
package com.securitycontrol.system.base.mapper;
|
||||
|
||||
import com.securitycontrol.system.api.domain.SysLog;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @author:cwchen
|
||||
* @date:2024-02-28-14:03
|
||||
* @version:1.0
|
||||
* @description:系统日志-数据库访问层
|
||||
*/
|
||||
@Repository(value = "ISysLogMapper")
|
||||
public interface ISysLogMapper {
|
||||
|
||||
/**
|
||||
* 保存系统日志
|
||||
* @param sysLog
|
||||
* @description 保存系统日志
|
||||
* @author cwchen
|
||||
* @date 2024/2/28 14:35
|
||||
*/
|
||||
void saveLogs(SysLog sysLog);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,22 @@
|
|||
package com.securitycontrol.system.base.service;
|
||||
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.system.api.domain.SysLog;
|
||||
|
||||
/**
|
||||
* @author:cwchen
|
||||
* @date:2024-02-28-14:01
|
||||
* @version:1.0
|
||||
* @description:系统日志-业务层
|
||||
*/
|
||||
public class ISysLogService {
|
||||
public interface ISysLogService {
|
||||
/**
|
||||
* 保存系统日志
|
||||
* @param sysLog
|
||||
* @return AjaxResult
|
||||
* @description
|
||||
* @author cwchen
|
||||
* @date 2024/2/28 14:33
|
||||
*/
|
||||
AjaxResult saveLogs(SysLog sysLog);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,39 @@
|
|||
package com.securitycontrol.system.base.service.impl;
|
||||
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.system.api.domain.SysLog;
|
||||
import com.securitycontrol.system.base.mapper.ISysLogMapper;
|
||||
import com.securitycontrol.system.base.service.ISysLogService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author:cwchen
|
||||
* @date:2024-02-28-14:02
|
||||
* @version:1.0
|
||||
* @description:系统日志-业务逻辑层
|
||||
*/
|
||||
public class SysLogServiceImpl {
|
||||
@Service(value = "ISysLogService")
|
||||
@Slf4j
|
||||
public class SysLogServiceImpl implements ISysLogService {
|
||||
|
||||
@Resource(name = "ISysLogMapper")
|
||||
private ISysLogMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public AjaxResult saveLogs(SysLog sysLog) {
|
||||
try {
|
||||
mapper.saveLogs(sysLog);
|
||||
} catch (Exception e) {
|
||||
log.error("保存系统日志");
|
||||
//手动回滚异常
|
||||
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
package com.securitycontrol.system.controller;
|
||||
|
||||
import com.securitycontrol.common.core.domain.Result;
|
||||
import com.securitycontrol.common.core.web.controller.BaseController;
|
||||
import com.securitycontrol.common.core.web.domain.AjaxResult;
|
||||
import com.securitycontrol.common.log.annotation.Log;
|
||||
import com.securitycontrol.common.log.enums.BusinessType;
|
||||
import com.securitycontrol.entity.system.dto.MenuDto;
|
||||
import com.securitycontrol.entity.system.dto.OrgDto;
|
||||
import com.securitycontrol.entity.system.dto.RoleDto;
|
||||
import com.securitycontrol.entity.system.vo.MenuVo;
|
||||
import com.securitycontrol.entity.system.vo.OrgVo;
|
||||
import com.securitycontrol.entity.system.vo.RoleVo;
|
||||
import com.securitycontrol.system.service.MenuService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单管理层
|
||||
|
|
@ -30,18 +26,21 @@ public class MenuController extends BaseController {
|
|||
|
||||
@ApiOperation(value = "获取菜单列表")
|
||||
@GetMapping("getMenuList")
|
||||
@Log(title = "系统管理", menu = "系统管理->菜单管理", businessType = BusinessType.QUERY, details = "查询菜单", type = "系统日志")
|
||||
public AjaxResult getMenuList(MenuDto dto) {
|
||||
return service.getMenuList(dto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "新增菜单")
|
||||
@PostMapping("addMenu")
|
||||
@Log(title = "系统管理", menu = "系统管理->菜单管理", businessType = BusinessType.INSERT, details = "新增菜单", type = "系统日志")
|
||||
public AjaxResult addMenu(@Valid @RequestBody MenuVo vo){
|
||||
return service.addOrUpdateMenu(vo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改菜单")
|
||||
@PostMapping("editMenu")
|
||||
@Log(title = "系统管理", menu = "系统管理->菜单管理", businessType = BusinessType.UPDATE, details = "修改菜单", type = "系统日志")
|
||||
public AjaxResult editMenu(@Valid @RequestBody MenuVo vo){
|
||||
return service.addOrUpdateMenu(vo);
|
||||
}
|
||||
|
|
@ -54,6 +53,7 @@ public class MenuController extends BaseController {
|
|||
|
||||
@ApiOperation(value = "删除菜单")
|
||||
@PostMapping("delMenu")
|
||||
@Log(title = "系统管理", menu = "系统管理->菜单管理", businessType = BusinessType.DELETE, details = "删除菜单", type = "系统日志")
|
||||
public AjaxResult delMenu(MenuDto dto){
|
||||
return service.delMenu(dto);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,4 +2,46 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.securitycontrol.system.base.mapper.ISysLogMapper">
|
||||
|
||||
<!--保存系统日志-->
|
||||
<insert id="saveLogs">
|
||||
INSERT INTO sys_role
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="logId != null and logId != ''">log_id,</if>
|
||||
<if test="ip != null and ip!=''">ip,</if>
|
||||
<if test="userId != null ">user_id,</if>
|
||||
<if test="model != null and model!=''">model,</if>
|
||||
<if test="operaUserName != null and operaUserName!=''">opera_user_name,</if>
|
||||
<if test="operTime != null and operTime!=''">oper_time,</if>
|
||||
<if test="method != null and method!=''">method,</if>
|
||||
<if test="params != null and params!=''">params,</if>
|
||||
<if test="operateDetail != null and operateDetail!=''">operate_detail,</if>
|
||||
<if test="operType != null and operType!=''">oper_type,</if>
|
||||
<if test="operUri != null and operUri!=''">oper_uri,</if>
|
||||
<if test="logType != null">log_type,</if>
|
||||
<if test="result != null">result,</if>
|
||||
<if test="times != null and times!=''">times,</if>
|
||||
<if test="failureReason != null and failureReason!=''">failure_reason,</if>
|
||||
<if test="grade != null and grade!=''">grade,</if>
|
||||
<if test="errType != null and errType!=''">err_type,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="logId != null and logId != ''">#{logId},</if>
|
||||
<if test="ip != null and ip!=''">#{ip},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="operaUserName != null and operaUserName!=''">#{operaUserName},</if>
|
||||
<if test="model != null and model!=''">#{model},</if>
|
||||
<if test="operTime != null and operTime!=''">#{operTime},</if>
|
||||
<if test="method != null and method!=''">#{method},</if>
|
||||
<if test="params != null and params!=''">#{params},</if>
|
||||
<if test="operateDetail != null and operateDetail!=''">#{operateDetail},</if>
|
||||
<if test="operType != null and operType!=''">#{operType},</if>
|
||||
<if test="operUri != null and operUri!=''">#{operUri},</if>
|
||||
<if test="logType != null">#{logType},</if>
|
||||
<if test="result != null">#{result},</if>
|
||||
<if test="times != null and times!=''">#{times},</if>
|
||||
<if test="failureReason != null and failureReason!=''">#{failureReason},</if>
|
||||
<if test="grade != null and grade!=''">#{grade},</if>
|
||||
<if test="errType != null and errType!=''">#{errType},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue