infra 模块添加操作日志.
This commit is contained in:
@@ -308,6 +308,7 @@ public class OperatorLogAspect {
|
||||
* @param type type
|
||||
*/
|
||||
private void fillLogInfo(OperatorLogModel model, Map<String, Object> extra, OperatorType type) {
|
||||
model.setRiskLevel(type.getRiskLevel().name());
|
||||
model.setModule(type.getModule());
|
||||
model.setType(type.getType());
|
||||
model.setLogInfo(ReplacementFormatters.format(type.getTemplate(), extra));
|
||||
|
||||
@@ -17,14 +17,16 @@ public interface OperatorLogKeys {
|
||||
|
||||
String NAME = "name";
|
||||
|
||||
String STATUS = "status";
|
||||
|
||||
String STATUS_NAME = "statusName";
|
||||
|
||||
String USERNAME = "username";
|
||||
|
||||
String TITLE = "title";
|
||||
|
||||
String VALUE = "value";
|
||||
|
||||
String LABEL = "label";
|
||||
|
||||
String STATUS = "status";
|
||||
|
||||
String STATUS_NAME = "statusName";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.orion.ops.framework.biz.operator.log.core.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 操作风险等级
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/12 14:19
|
||||
*/
|
||||
@Getter
|
||||
public enum OperatorRiskLevel {
|
||||
|
||||
/**
|
||||
* 低风险
|
||||
*/
|
||||
L,
|
||||
|
||||
/**
|
||||
* 中风险
|
||||
*/
|
||||
M,
|
||||
|
||||
/**
|
||||
* 高风险
|
||||
*/
|
||||
H,
|
||||
|
||||
;
|
||||
|
||||
}
|
||||
@@ -49,6 +49,11 @@ public class OperatorLogModel {
|
||||
*/
|
||||
private String logInfo;
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
private String riskLevel;
|
||||
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orion.ops.framework.biz.operator.log.core.model;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -16,6 +17,11 @@ import lombok.Getter;
|
||||
@AllArgsConstructor
|
||||
public class OperatorType {
|
||||
|
||||
/**
|
||||
* 风险等级
|
||||
*/
|
||||
private final OperatorRiskLevel riskLevel;
|
||||
|
||||
/**
|
||||
* 模块
|
||||
*/
|
||||
|
||||
@@ -35,7 +35,7 @@ public class OperatorLogs implements OperatorLogKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加参数
|
||||
* 添加日志参数
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
@@ -45,7 +45,7 @@ public class OperatorLogs implements OperatorLogKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加参数 json
|
||||
* 添加日志参数 json
|
||||
*
|
||||
* @param key key
|
||||
* @param value value
|
||||
@@ -55,7 +55,7 @@ public class OperatorLogs implements OperatorLogKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加参数
|
||||
* 添加日志参数
|
||||
*
|
||||
* @param map map
|
||||
*/
|
||||
@@ -64,7 +64,7 @@ public class OperatorLogs implements OperatorLogKeys {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加参数
|
||||
* 添加日志参数
|
||||
*
|
||||
* @param obj obj
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@ package ${currentPackage};
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*;
|
||||
import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set;
|
||||
|
||||
/**
|
||||
@@ -24,10 +25,10 @@ public class ${type}OperatorType {
|
||||
public static final String EXPORT = "${typeHyphen}:export";
|
||||
|
||||
public static void init() {
|
||||
set(new OperatorType(MODULE, CREATE, "创建$!{table.comment}"));
|
||||
set(new OperatorType(MODULE, UPDATE, "更新$!{table.comment}"));
|
||||
set(new OperatorType(MODULE, DELETE, "删除$!{table.comment}"));
|
||||
set(new OperatorType(MODULE, EXPORT, "导出$!{table.comment}"));
|
||||
set(new OperatorType(L, MODULE, CREATE, "创建$!{table.comment}"));
|
||||
set(new OperatorType(M, MODULE, UPDATE, "更新$!{table.comment}"));
|
||||
set(new OperatorType(H, MODULE, DELETE, "删除$!{table.comment}"));
|
||||
set(new OperatorType(L, MODULE, EXPORT, "导出$!{table.comment}"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.orion.ops.module.infra.controller;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.infra.entity.request.menu.*;
|
||||
import com.orion.ops.module.infra.define.operator.SystemMenuOperatorType;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuQueryRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuUpdateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemMenuUpdateStatusRequest;
|
||||
import com.orion.ops.module.infra.entity.vo.SystemMenuVO;
|
||||
import com.orion.ops.module.infra.service.SystemMenuService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@@ -36,6 +41,7 @@ public class SystemMenuController {
|
||||
@Resource
|
||||
private SystemMenuService systemMenuService;
|
||||
|
||||
@OperatorLog(SystemMenuOperatorType.CREATE)
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建菜单")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-menu:create')")
|
||||
@@ -43,6 +49,7 @@ public class SystemMenuController {
|
||||
return systemMenuService.createSystemMenu(request);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemMenuOperatorType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "通过 id 更新菜单")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-menu:update')")
|
||||
@@ -50,6 +57,7 @@ public class SystemMenuController {
|
||||
return systemMenuService.updateSystemMenuById(request);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemMenuOperatorType.UPDATE_STATUS)
|
||||
@PutMapping("/update-status")
|
||||
@Operation(summary = "通过 id 级联更新菜单状态")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-menu:update-status')")
|
||||
@@ -74,6 +82,7 @@ public class SystemMenuController {
|
||||
return systemMenuService.getSystemMenuByIdList(request);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemMenuOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "通过 id 级联删除菜单")
|
||||
@Parameter(name = "id", description = "id", required = true)
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.orion.ops.module.infra.controller;
|
||||
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.common.validator.group.Page;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.infra.define.operator.SystemRoleOperatorType;
|
||||
import com.orion.ops.module.infra.entity.request.menu.SystemRoleGrantMenuRequest;
|
||||
import com.orion.ops.module.infra.entity.request.role.SystemRoleCreateRequest;
|
||||
import com.orion.ops.module.infra.entity.request.role.SystemRoleQueryRequest;
|
||||
@@ -46,6 +48,7 @@ public class SystemRoleController {
|
||||
@Resource
|
||||
private SystemRoleMenuService systemRoleMenuService;
|
||||
|
||||
@OperatorLog(SystemRoleOperatorType.CREATE)
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建角色")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-role:create')")
|
||||
@@ -53,6 +56,7 @@ public class SystemRoleController {
|
||||
return systemRoleService.createSystemRole(request);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemRoleOperatorType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "通过 id 更新角色")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-role:update')")
|
||||
@@ -60,6 +64,7 @@ public class SystemRoleController {
|
||||
return systemRoleService.updateSystemRoleById(request);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemRoleOperatorType.UPDATE_STATUS)
|
||||
@PutMapping("/update-status")
|
||||
@Operation(summary = "通过 id 更新角色状态")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-role:update-status')")
|
||||
@@ -99,6 +104,7 @@ public class SystemRoleController {
|
||||
return systemRoleMenuService.getRoleMenuIdList(roleId);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemRoleOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "通过 id 删除角色")
|
||||
@Parameter(name = "id", description = "id", required = true)
|
||||
@@ -107,8 +113,9 @@ public class SystemRoleController {
|
||||
return systemRoleService.deleteSystemRoleById(id);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemRoleOperatorType.GRANT_MENU)
|
||||
@PutMapping("/grant-menu")
|
||||
@Operation(summary = "绑定角色菜单")
|
||||
@Operation(summary = "分配角色菜单")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-role:grant-menu')")
|
||||
public Integer grantRoleMenu(@RequestBody SystemRoleGrantMenuRequest request) {
|
||||
return systemRoleMenuService.grantRoleMenu(request);
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.orion.ops.module.infra.controller;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.define.wrapper.HttpWrapper;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.biz.operator.log.core.annotation.OperatorLog;
|
||||
import com.orion.ops.framework.common.validator.group.Page;
|
||||
import com.orion.ops.framework.log.core.annotation.IgnoreLog;
|
||||
import com.orion.ops.framework.log.core.enums.IgnoreLogMode;
|
||||
import com.orion.ops.framework.web.core.annotation.RestWrapper;
|
||||
import com.orion.ops.module.infra.define.operator.SystemUserOperatorType;
|
||||
import com.orion.ops.module.infra.entity.request.user.*;
|
||||
import com.orion.ops.module.infra.entity.vo.SystemUserVO;
|
||||
import com.orion.ops.module.infra.service.SystemUserRoleService;
|
||||
@@ -44,6 +46,7 @@ public class SystemUserController {
|
||||
@Resource
|
||||
private SystemUserRoleService systemUserRoleService;
|
||||
|
||||
@OperatorLog(SystemUserOperatorType.CREATE)
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建用户")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:create')")
|
||||
@@ -51,6 +54,7 @@ public class SystemUserController {
|
||||
return systemUserService.createSystemUser(request);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemUserOperatorType.UPDATE)
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "通过 id 更新用户")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:update')")
|
||||
@@ -60,6 +64,7 @@ public class SystemUserController {
|
||||
|
||||
// TODO 修改头像 最后再说 可有可无的功能 要是有 http 文件需求就写
|
||||
|
||||
@OperatorLog(SystemUserOperatorType.UPDATE_STATUS)
|
||||
@PutMapping("/update-status")
|
||||
@Operation(summary = "修改用户状态")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:update-status')")
|
||||
@@ -67,6 +72,7 @@ public class SystemUserController {
|
||||
return systemUserService.updateUserStatus(request);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemUserOperatorType.GRANT_ROLE)
|
||||
@PutMapping("/grant-role")
|
||||
@Operation(summary = "分配用户角色")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:grant-role')")
|
||||
@@ -80,6 +86,7 @@ public class SystemUserController {
|
||||
}
|
||||
}
|
||||
|
||||
@OperatorLog(SystemUserOperatorType.RESET_PASSWORD)
|
||||
@PutMapping("/reset-password")
|
||||
@Operation(summary = "重置用户密码")
|
||||
@PreAuthorize("@ss.hasPermission('infra:system-user:reset-password')")
|
||||
@@ -121,6 +128,7 @@ public class SystemUserController {
|
||||
return systemUserService.getSystemUserPage(request);
|
||||
}
|
||||
|
||||
@OperatorLog(SystemUserOperatorType.DELETE)
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "通过 id 删除用户")
|
||||
@Parameter(name = "id", description = "id", required = true)
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orion.ops.module.infra.define.operator;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.L;
|
||||
import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set;
|
||||
|
||||
/**
|
||||
@@ -22,9 +23,9 @@ public class AuthenticationOperatorType {
|
||||
public static final String UPDATE_PASSWORD = "authentication:update-password";
|
||||
|
||||
public static void init() {
|
||||
set(new OperatorType(MODULE, LOGIN, "登陆系统"));
|
||||
set(new OperatorType(MODULE, LOGOUT, "登出系统"));
|
||||
set(new OperatorType(MODULE, UPDATE_PASSWORD, "修改密码"));
|
||||
set(new OperatorType(L, MODULE, LOGIN, "登陆系统"));
|
||||
set(new OperatorType(L, MODULE, LOGOUT, "登出系统"));
|
||||
set(new OperatorType(L, MODULE, UPDATE_PASSWORD, "修改密码"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.orion.ops.module.infra.define.operator;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*;
|
||||
import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set;
|
||||
|
||||
/**
|
||||
* 系统菜单 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/10 17:30
|
||||
*/
|
||||
public class SystemMenuOperatorType {
|
||||
|
||||
private static final String MODULE = "infra:system-menu";
|
||||
|
||||
public static final String CREATE = "system-menu:create";
|
||||
|
||||
public static final String UPDATE = "system-menu:update";
|
||||
|
||||
public static final String UPDATE_STATUS = "system-menu:update-status";
|
||||
|
||||
public static final String DELETE = "system-menu:delete";
|
||||
|
||||
public static void init() {
|
||||
set(new OperatorType(L, MODULE, CREATE, "创建菜单 <sb>${name}</sb>"));
|
||||
set(new OperatorType(L, MODULE, UPDATE, "修改菜单 <sb>${name}</sb>"));
|
||||
set(new OperatorType(M, MODULE, UPDATE_STATUS, "修改菜单状态 <sb>${name}</sb> - <sb>${label}</sb>"));
|
||||
set(new OperatorType(H, MODULE, DELETE, "删除菜单 <sb>${name}</sb>"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.orion.ops.module.infra.define.operator;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*;
|
||||
import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set;
|
||||
|
||||
/**
|
||||
* 系统角色 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/10 17:30
|
||||
*/
|
||||
public class SystemRoleOperatorType {
|
||||
|
||||
private static final String MODULE = "infra:system-role";
|
||||
|
||||
public static final String CREATE = "system-role:create";
|
||||
|
||||
public static final String UPDATE = "system-role:update";
|
||||
|
||||
public static final String UPDATE_STATUS = "system-role:update-status";
|
||||
|
||||
public static final String DELETE = "system-role:delete";
|
||||
|
||||
public static final String GRANT_MENU = "system-role:grant-menu";
|
||||
|
||||
public static void init() {
|
||||
set(new OperatorType(L, MODULE, CREATE, "创建角色 <sb>${name}(${code})</sb>"));
|
||||
set(new OperatorType(M, MODULE, UPDATE, "修改角色 <sb>${name}(${code})</sb>"));
|
||||
set(new OperatorType(M, MODULE, UPDATE_STATUS, "修改角色状态 <sb>${name}(${code})</sb> - <sb>${statusName}</sb>"));
|
||||
set(new OperatorType(H, MODULE, DELETE, "删除角色 <sb>${name}(${code})</sb>"));
|
||||
set(new OperatorType(M, MODULE, GRANT_MENU, "分配角色菜单 <sb>${name}(${code})</sb>"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.orion.ops.module.infra.define.operator;
|
||||
|
||||
import com.orion.ops.framework.biz.operator.log.core.model.OperatorType;
|
||||
|
||||
import static com.orion.ops.framework.biz.operator.log.core.enums.OperatorRiskLevel.*;
|
||||
import static com.orion.ops.framework.biz.operator.log.core.holder.OperatorTypeHolder.set;
|
||||
|
||||
/**
|
||||
* 系统用户 操作日志类型
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/10/10 17:30
|
||||
*/
|
||||
public class SystemUserOperatorType {
|
||||
|
||||
private static final String MODULE = "infra:system-user";
|
||||
|
||||
public static final String CREATE = "system-user:create";
|
||||
|
||||
public static final String UPDATE = "system-user:update";
|
||||
|
||||
public static final String UPDATE_STATUS = "system-user:update-status";
|
||||
|
||||
public static final String GRANT_ROLE = "system-user:grant-role";
|
||||
|
||||
public static final String RESET_PASSWORD = "system-user:reset-password";
|
||||
|
||||
public static final String DELETE = "system-user:delete";
|
||||
|
||||
public static void init() {
|
||||
set(new OperatorType(L, MODULE, CREATE, "创建用户 <sb>${username}</sb>"));
|
||||
set(new OperatorType(M, MODULE, UPDATE, "修改用户 <sb>${username}</sb>"));
|
||||
set(new OperatorType(M, MODULE, UPDATE_STATUS, "修改用户状态 <sb>${username}</sb> - <sb>${statusName}</sb>"));
|
||||
set(new OperatorType(M, MODULE, GRANT_ROLE, "用户分配角色 <sb>${username}</sb>"));
|
||||
set(new OperatorType(H, MODULE, RESET_PASSWORD, "重置用户密码 <sb>${username}</sb>"));
|
||||
set(new OperatorType(H, MODULE, DELETE, "删除用户 <sb>${username}</sb>"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,6 +56,10 @@ public class OperatorLogDO extends BaseDO {
|
||||
@TableField("user_agent")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "风险等级")
|
||||
@TableField("risk_level")
|
||||
private String riskLevel;
|
||||
|
||||
@Schema(description = "模块")
|
||||
@TableField("module")
|
||||
private String module;
|
||||
|
||||
@@ -30,6 +30,10 @@ public class OperatorLogQueryRequest extends PageRequest {
|
||||
@Schema(description = "模块")
|
||||
private String module;
|
||||
|
||||
@Size(max = 1)
|
||||
@Schema(description = "风险等级")
|
||||
private String riskLevel;
|
||||
|
||||
@Size(max = 64)
|
||||
@Schema(description = "操作类型")
|
||||
private String type;
|
||||
|
||||
@@ -46,6 +46,9 @@ public class OperatorLogVO implements Serializable {
|
||||
@Schema(description = "userAgent")
|
||||
private String userAgent;
|
||||
|
||||
@Schema(description = "风险等级")
|
||||
private String riskLevel;
|
||||
|
||||
@Schema(description = "模块")
|
||||
private String module;
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.orion.ops.module.infra.runner;
|
||||
|
||||
import com.orion.ops.module.infra.define.operator.AuthenticationOperatorType;
|
||||
import com.orion.ops.module.infra.define.operator.SystemMenuOperatorType;
|
||||
import com.orion.ops.module.infra.define.operator.SystemRoleOperatorType;
|
||||
import com.orion.ops.module.infra.define.operator.SystemUserOperatorType;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -17,6 +20,9 @@ public class InfraOperatorTypeRunner implements CommandLineRunner {
|
||||
@Override
|
||||
public void run(String... args) {
|
||||
AuthenticationOperatorType.init();
|
||||
SystemMenuOperatorType.init();
|
||||
SystemRoleOperatorType.init();
|
||||
SystemUserOperatorType.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ public class OperatorLogServiceImpl implements OperatorLogService {
|
||||
private LambdaQueryWrapper<OperatorLogDO> buildQueryWrapper(OperatorLogQueryRequest request) {
|
||||
return operatorLogDAO.wrapper()
|
||||
.eq(OperatorLogDO::getUserId, request.getUserId())
|
||||
.eq(OperatorLogDO::getRiskLevel, request.getRiskLevel())
|
||||
.eq(OperatorLogDO::getModule, request.getModule())
|
||||
.eq(OperatorLogDO::getType, request.getType())
|
||||
.eq(OperatorLogDO::getResult, request.getResult())
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.orion.ops.module.infra.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
@@ -181,14 +182,20 @@ public class SystemMenuServiceImpl implements SystemMenuService {
|
||||
Integer status = request.getStatus();
|
||||
Integer visible = request.getVisible();
|
||||
if (status != null) {
|
||||
Valid.valid(MenuStatusEnum::of, status);
|
||||
MenuStatusEnum statusEnum = Valid.valid(MenuStatusEnum::of, status);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.LABEL, statusEnum.name());
|
||||
}
|
||||
if (visible != null) {
|
||||
Valid.valid(MenuVisibleEnum::of, visible);
|
||||
MenuVisibleEnum visibleEnum = Valid.valid(MenuVisibleEnum::of, visible);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.LABEL, visibleEnum.name());
|
||||
}
|
||||
// 查询
|
||||
SystemMenuDO record = systemMenuDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.NAME, record.getName());
|
||||
// 从缓存中查询
|
||||
List<SystemMenuCacheDTO> cache = permissionService.getMenuCache();
|
||||
// 获取要更新的id
|
||||
@@ -219,6 +226,8 @@ public class SystemMenuServiceImpl implements SystemMenuService {
|
||||
// 查询
|
||||
SystemMenuDO record = systemMenuDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.NAME, record.getName());
|
||||
// 从缓存中查询
|
||||
List<SystemMenuCacheDTO> cache = permissionService.getMenuCache();
|
||||
// 获取要删除的id
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.orion.ops.module.infra.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs;
|
||||
import com.orion.ops.framework.common.constant.ErrorCode;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
@@ -57,6 +58,9 @@ public class SystemRoleMenuServiceImpl implements SystemRoleMenuService {
|
||||
List<Long> menuIdList = request.getMenuIdList();
|
||||
// 检查角色是否存在
|
||||
SystemRoleDO role = Valid.notNull(systemRoleDAO.selectById(roleId), ErrorMessage.ROLE_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.NAME, role.getName());
|
||||
OperatorLogs.add(OperatorLogs.CODE, role.getCode());
|
||||
// 查询菜单列表
|
||||
List<SystemMenuDO> menuList;
|
||||
if (menuIdList.isEmpty()) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.module.infra.convert.SystemRoleConvert;
|
||||
@@ -76,6 +77,8 @@ public class SystemRoleServiceImpl implements SystemRoleService {
|
||||
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
SystemRoleDO record = systemRoleDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.ROLE_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.CODE, record.getCode());
|
||||
// 转换
|
||||
SystemRoleDO updateRecord = SystemRoleConvert.MAPPER.to(request);
|
||||
// 查询名称是否存在
|
||||
@@ -100,7 +103,11 @@ public class SystemRoleServiceImpl implements SystemRoleService {
|
||||
// 转换
|
||||
SystemRoleDO updateRecord = SystemRoleConvert.MAPPER.to(request);
|
||||
Integer status = updateRecord.getStatus();
|
||||
Valid.valid(RoleStatusEnum::of, status);
|
||||
RoleStatusEnum statusEnum = Valid.valid(RoleStatusEnum::of, status);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.CODE, record.getCode());
|
||||
OperatorLogs.add(OperatorLogs.NAME, record.getName());
|
||||
OperatorLogs.add(OperatorLogs.STATUS_NAME, statusEnum.name());
|
||||
// 更新
|
||||
int effect = systemRoleDAO.updateById(updateRecord);
|
||||
log.info("SystemRoleService-updateRoleStatus effect: {}, updateRecord: {}", effect, JSON.toJSONString(updateRecord));
|
||||
@@ -151,6 +158,9 @@ public class SystemRoleServiceImpl implements SystemRoleService {
|
||||
SystemRoleDO record = systemRoleDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.DATA_ABSENT);
|
||||
String code = record.getCode();
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.CODE, code);
|
||||
OperatorLogs.add(OperatorLogs.NAME, record.getName());
|
||||
// 检查是否为管理员账号
|
||||
Valid.isTrue(!RoleDefine.isAdmin(code), ErrorMessage.UNABLE_OPERATE_ADMIN_ROLE);
|
||||
// 删除角色
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.orion.ops.module.infra.service.impl;
|
||||
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
@@ -51,6 +52,11 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
|
||||
@Override
|
||||
public Integer deleteUserRoles(SystemUserUpdateRoleRequest request) {
|
||||
Long userId = request.getId();
|
||||
// 查询用户
|
||||
SystemUserDO user = systemUserDAO.selectById(userId);
|
||||
Valid.notNull(user, ErrorMessage.USER_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.USERNAME, user.getUsername());
|
||||
// 删除用户关联
|
||||
int effect = systemUserRoleDAO.deleteByUserId(userId);
|
||||
// 更新缓存中的角色
|
||||
@@ -66,8 +72,10 @@ public class SystemUserRoleServiceImpl implements SystemUserRoleService {
|
||||
Long userId = request.getId();
|
||||
List<Long> roleIdList = request.getRoleIdList();
|
||||
// 查询用户
|
||||
SystemUserDO record = systemUserDAO.selectById(userId);
|
||||
Valid.notNull(record, ErrorMessage.USER_ABSENT);
|
||||
SystemUserDO user = systemUserDAO.selectById(userId);
|
||||
Valid.notNull(user, ErrorMessage.USER_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.USERNAME, user.getUsername());
|
||||
// 查询角色
|
||||
List<SystemRoleDO> userRoles = systemRoleDAO.selectBatchIds(roleIdList);
|
||||
// 检查角色是否存在
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.define.wrapper.DataGrid;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
import com.orion.lang.utils.crypto.Signatures;
|
||||
import com.orion.ops.framework.biz.operator.log.core.uitls.OperatorLogs;
|
||||
import com.orion.ops.framework.common.constant.ErrorCode;
|
||||
import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
@@ -79,6 +80,8 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
SystemUserDO record = systemUserDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.USER_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.USERNAME, record.getUsername());
|
||||
// 转换
|
||||
SystemUserDO updateRecord = SystemUserConvert.MAPPER.to(request);
|
||||
// 查询花名是否存在
|
||||
@@ -107,6 +110,9 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
// 查询用户
|
||||
SystemUserDO record = systemUserDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.USER_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.USERNAME, record.getUsername());
|
||||
OperatorLogs.add(OperatorLogs.STATUS_NAME, status.name());
|
||||
// 转换
|
||||
SystemUserDO updateRecord = SystemUserConvert.MAPPER.to(request);
|
||||
// 更新用户
|
||||
@@ -165,6 +171,12 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
if (id.equals(SecurityUtils.getLoginUserId())) {
|
||||
throw ErrorCode.UNSUPPOETED.exception();
|
||||
}
|
||||
// 查询用户
|
||||
SystemUserDO record = systemUserDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.USER_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.USERNAME, record.getUsername());
|
||||
// 删除用户
|
||||
int effect = systemUserDAO.deleteById(id);
|
||||
log.info("SystemUserService-deleteSystemUserById id: {}, effect: {}", id, effect);
|
||||
// 删除角色关联
|
||||
@@ -181,7 +193,11 @@ public class SystemUserServiceImpl implements SystemUserService {
|
||||
@Override
|
||||
public void resetPassword(UserResetPasswordRequest request) {
|
||||
Long id = Valid.notNull(request.getId(), ErrorMessage.ID_MISSING);
|
||||
SystemUserDO record = Valid.notNull(systemUserDAO.selectById(id), ErrorMessage.USER_ABSENT);
|
||||
// 查询用户
|
||||
SystemUserDO record = systemUserDAO.selectById(id);
|
||||
Valid.notNull(record, ErrorMessage.USER_ABSENT);
|
||||
// 添加日志参数
|
||||
OperatorLogs.add(OperatorLogs.USERNAME, record.getUsername());
|
||||
// 修改密码
|
||||
SystemUserDO update = new SystemUserDO();
|
||||
update.setId(id);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<result column="address" property="address"/>
|
||||
<result column="location" property="location"/>
|
||||
<result column="user_agent" property="userAgent"/>
|
||||
<result column="risk_level" property="riskLevel"/>
|
||||
<result column="module" property="module"/>
|
||||
<result column="type" property="type"/>
|
||||
<result column="log_info" property="logInfo"/>
|
||||
@@ -26,7 +27,7 @@
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, username, trace_id, address, location, user_agent, module, type, log_info, extra, result, error_message, return_value, duration, start_time, end_time, create_time
|
||||
id, user_id, username, trace_id, address, location, user_agent, risk_level, module, type, log_info, extra, result, error_message, return_value, duration, start_time, end_time, create_time
|
||||
</sql>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user