diff --git a/config/rbac/schema.sql b/config/rbac/schema.sql index c0628d9..e480d4e 100644 --- a/config/rbac/schema.sql +++ b/config/rbac/schema.sql @@ -156,6 +156,7 @@ CREATE TABLE IF NOT EXISTS `sys_operation_log` `operation_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作类型', `operation_status` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作状态', `description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '操作说明', + `access_user` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '访问用户', `request_ip` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求来源 IP 地址', `call_function` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '请求接口', `http_method` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT 'HTTP 请求类型', diff --git a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAccessDeniedHandler.java b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAccessDeniedHandler.java index 6186c1f..fed31dd 100644 --- a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAccessDeniedHandler.java +++ b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAccessDeniedHandler.java @@ -28,7 +28,7 @@ public class JwtAccessDeniedHandler implements AccessDeniedHandler { HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException { response.setStatus(HttpServletResponse.SC_FORBIDDEN); - SecurityResponseUtils.authenticationResponse(request, response, ErrorCode.ERR_PERMISSION, accessDeniedException.getMessage(), + SecurityResponseUtils.authenticationResponse(request, response, ErrorCode.ERR_PERMISSION, ErrorCode.ERR_PERMISSION.getStringValue(), optLogDbService); } } diff --git a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAuthenticationEntryPoint.java b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAuthenticationEntryPoint.java index 8dbec10..f853047 100644 --- a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAuthenticationEntryPoint.java +++ b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAuthenticationEntryPoint.java @@ -27,6 +27,6 @@ public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { HttpServletResponse response, AuthenticationException authException) throws IOException { response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - SecurityResponseUtils.authenticationResponse(request, response, ErrorCode.ERR_PARAMEXCEPTION, authException.getMessage(), optLogDbService); + SecurityResponseUtils.authenticationResponse(request, response, ErrorCode.ERR_PARAMEXCEPTION, ErrorCode.ERR_PARAMEXCEPTION.getStringValue(), optLogDbService); } } diff --git a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAuthenticationFilter.java b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAuthenticationFilter.java index 81b9ebf..0d8837d 100644 --- a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAuthenticationFilter.java +++ b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtAuthenticationFilter.java @@ -95,6 +95,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter { private void handleException(HttpServletRequest request, HttpServletResponse response, ErrorCode err) throws IOException { // 特定处理逻辑,例如设置响应状态、记录日志、重定向等 response.setStatus(HttpServletResponse.SC_UNAUTHORIZED); - SecurityResponseUtils.authenticationResponse(request, response, err, err.getDescription(), optLogDbService); + SecurityResponseUtils.authenticationResponse(request, response, err, err.getStringValue(), optLogDbService); } } diff --git a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtCustomUsernamePassword.java b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtCustomUsernamePassword.java index 356dcf3..0c0cf49 100644 --- a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtCustomUsernamePassword.java +++ b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtCustomUsernamePassword.java @@ -39,7 +39,6 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic import org.springframework.web.bind.annotation.RequestMethod; import java.io.IOException; -import java.util.Arrays; import java.util.List; /** @@ -74,7 +73,7 @@ public class JwtCustomUsernamePassword extends UsernamePasswordAuthenticationFil try { ProtocolReq loginReq = ProtocolJsonUtils.jsonGetObject(request.getInputStream(), new TypeReference<>() { - }); + }); List validate = HelperUtils.validate(loginReq, ValidGroups.ProtocolCommonValid.class, ValidGroups.LogoutReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -131,12 +130,15 @@ public class JwtCustomUsernamePassword extends UsernamePasswordAuthenticationFil if (failed instanceof AuthenticationServiceException) { if (failed.getCause() instanceof CommonAuthException ex) { + err = ex.getErr(); rsp.setStatus(ex.getErr().getCode()); } else { + err = ErrorCode.ERR_ACCOUNT; rsp.setStatus(ErrorCode.ERR_ACCOUNT.getCode()); } rsp.setMessage(new String[] {failed.getMessage()}); } else if (failed instanceof CommonAuthException ex) { + err = ex.getErr(); rsp.setStatus(ex.getErr().getCode()); rsp.setMessage(ex.getDescription()); } else { @@ -144,8 +146,7 @@ public class JwtCustomUsernamePassword extends UsernamePasswordAuthenticationFil rsp.setMessage(new String[] {err.getDescription()}); } - SecurityResponseUtils.authenticationResponse(request, response, rsp, Arrays.toString(rsp.getMessage()), - optLogDbService); + SecurityResponseUtils.authenticationResponse(request, response, rsp, err.getStringValue(), optLogDbService); } @Override @@ -182,8 +183,7 @@ public class JwtCustomUsernamePassword extends UsernamePasswordAuthenticationFil ApiContextUtils.setJwtUserInfo(jwt, au.getUsername(), au.getUid(), au.getId()); try { - SecurityResponseUtils.authenticationResponse(request, response, loginRsp, - "[" + authResult.getName() + "] login", optLogDbService); + SecurityResponseUtils.authenticationResponse(request, response, loginRsp, "SYSLOG_DESC_LOGIN", optLogDbService); } finally { ApiContextUtils.clear(); } diff --git a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtLogoutHandler.java b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtLogoutHandler.java index 05286cb..e2bc385 100644 --- a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtLogoutHandler.java +++ b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtLogoutHandler.java @@ -17,7 +17,6 @@ import org.springframework.security.web.authentication.logout.LogoutHandler; import org.springframework.stereotype.Component; import java.io.IOException; -import java.util.Arrays; /** * The type Jwt logout handler. @@ -40,20 +39,20 @@ public class JwtLogoutHandler implements LogoutHandler { try { ApiContext ctx = ApiContextUtils.get(); String username = ctx.getUsername(); - + ErrorCode err; if (!HelperUtils.stringNotEmptyOrNull(username)) { - rsp.setStatus(ErrorCode.ERR_TOKENNOTFOUND.getCode()); - rsp.setMessage(new String[] {ErrorCode.ERR_TOKENNOTFOUND.getDescription()}); + err = ErrorCode.ERR_TOKENNOTFOUND; + } else { // 校验通过,才会执行业务逻辑处理 accountJwtCacheService.deleteAccountJwtCache(ctx.getUid()); - rsp.setStatus(ErrorCode.ERR_OK.getCode()); - rsp.setMessage(new String[] {ErrorCode.ERR_OK.getDescription()}); + err = ErrorCode.ERR_OK; } + rsp.setStatus(err.getCode()); + rsp.setMessage(new String[] {err.getDescription()}); rsp.setUsername(username); - SecurityResponseUtils.authenticationResponse(request, response, rsp, Arrays.toString(rsp.getMessage()), - optLogDbService); + SecurityResponseUtils.authenticationResponse(request, response, rsp, err.getStringValue(), optLogDbService); } catch (IOException e) { throw new AuthenticationServiceException(e.getMessage()); } diff --git a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtLogoutSuccessHandler.java b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtLogoutSuccessHandler.java index 86f4803..74e374e 100644 --- a/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtLogoutSuccessHandler.java +++ b/cs-authentication/src/main/java/com/cf/cs/authentication/security/impl/JwtLogoutSuccessHandler.java @@ -32,6 +32,6 @@ public class JwtLogoutSuccessHandler implements LogoutSuccessHandler { new SecurityContextLogoutHandler().logout(request, response, authentication); } - SecurityResponseUtils.authenticationResponse(request, response, ErrorCode.ERR_OK, "logout", optLogDbService); + SecurityResponseUtils.authenticationResponse(request, response, ErrorCode.ERR_OK, "SYSLOG_DESC_LOGOUT", optLogDbService); } } diff --git a/cs-base/src/main/java/com/cf/cs/base/config/LocaleConfig.java b/cs-base/src/main/java/com/cf/cs/base/config/LocaleConfig.java index 813fe54..8559b72 100644 --- a/cs-base/src/main/java/com/cf/cs/base/config/LocaleConfig.java +++ b/cs-base/src/main/java/com/cf/cs/base/config/LocaleConfig.java @@ -25,7 +25,7 @@ public class LocaleConfig { Locale.setDefault(Locale.CHINA); ResourceBundleMessageSource source = new ResourceBundleMessageSource(); //设置国际化文件存储路径和名称 i18n目录,messages文件名 - source.setBasenames("i18n/message", "i18n/errorMessage", "i18n/enumMessage"); + source.setBasenames("i18n/message", "i18n/errorMessage", "i18n/enumMessage", "i18n/syslogMessage"); //设置根据key如果没有获取到对应的文本信息,则返回key作为信息 source.setUseCodeAsDefaultMessage(true); //设置字符编码 diff --git a/cs-base/src/main/java/com/cf/cs/base/misc/MessageUtil.java b/cs-base/src/main/java/com/cf/cs/base/misc/MessageUtil.java index 5efc5be..b0709e1 100644 --- a/cs-base/src/main/java/com/cf/cs/base/misc/MessageUtil.java +++ b/cs-base/src/main/java/com/cf/cs/base/misc/MessageUtil.java @@ -56,7 +56,13 @@ public class MessageUtil { } private static String get(String key, Object[] params, Locale language) { - return getInstance().getMessage(key, params, language); + String ret = getInstance().getMessage(key, params, language); + + if (HelperUtils.stringNotEmptyOrNull(ret)) { + return ret; + } + + return key; } private static MessageSource getInstance() { diff --git a/cs-base/src/main/resources/i18n/syslogMessage_en_US.properties b/cs-base/src/main/resources/i18n/syslogMessage_en_US.properties new file mode 100644 index 0000000..43856bb --- /dev/null +++ b/cs-base/src/main/resources/i18n/syslogMessage_en_US.properties @@ -0,0 +1,38 @@ +SYSLOG_MOD_COMMON=Universal Module +SYSLOG_MOD_SYSLOG=Operation Log Module +SYSLOG_MOD_AUTH=Rights Management Module +SYSLOG_MOD_DICT=Dictionary Module +SYSLOG_MOD_SYSINFO=System Information Module +SYSLOG_MOD_USER_MGR=User Management Module +SYSLOG_MOD_SECURITY=System Safety Module +SYSLOG_TYPE_AUTH=Authentication/Authentication +SYSLOG_TYPE_READ=READ +SYSLOG_TYPE_WRITE=WRITE +SYSLOG_TYPE_CREATE=CREATE +SYSLOG_TYPE_DEL=DELETE +SYSLOG_TYPE_MODIFY=MODIFY +SYSLOG_DESC_GET_VERSION=Obtain the current system version information +SYSLOG_DESC_GET_SYSLOG_SUMMARY=Obtain the brief information about operationlogs +SYSLOG_DESC_GET_SYSLOG_DETAIL=Obtain operation logdetails +SYSLOG_DESC_GET_CUR_USR_RES_RIGHT=Get the current user resource rights +SYSLOG_DESC_GET_USR_RES_RIGHT=Obtain user resource rights +SYSLOG_DESC_GET_ALL_USR_GROUP=Get all current user groups +SYSLOG_DESC_CREATE_RESOURCE=Register a new resource +SYSLOG_DESC_DEL_RESOURCE=Delete resource +SYSLOG_DESC_GET_ALL_ENUM_DICT=Get all enumeration dictionary type information of the system +SYSLOG_DESC_GET_ENUM_DETAIL=Gets the details of the system enumeration dictionary +SYSLOG_DESC_CREATE_USER_DICT=Creating a user dictionary +SYSLOG_DESC_MODIFY_USER_DICT=Modify the contents of the user dictionary +SYSLOG_DESC_GET_ALL_USER_DICT=Get all user dictionaries +SYSLOG_DESC_GET_USER_DETAIL=Get the user dictionary content item +SYSLOG_DESC_CREATE_USER_DICT_ITEM=Add user dictionary content items +SYSLOG_DESC_GET_OS_INFO=Obtain information about the current operating system +SYSLOG_DESC_GET_CPU_INFO=Gets current processor information +SYSLOG_DESC_GET_HW_INFO=Obtain system hardware information +SYSLOG_DESC_GET_USER=Get user information +SYSLOG_DESC_GET_USER_LIST=Get user list +SYSLOG_DESC_GET_CUR_USER=get current user information +SYSLOG_DESC_CREATE_USER=Create new user +SYSLOG_DESC_DEL_USER=Delete user +SYSLOG_DESC_LOGOUT=Logout +SYSLOG_DESC_LOGIN=Login \ No newline at end of file diff --git a/cs-base/src/main/resources/i18n/syslogMessage_zh_CN.properties b/cs-base/src/main/resources/i18n/syslogMessage_zh_CN.properties new file mode 100644 index 0000000..a12a799 --- /dev/null +++ b/cs-base/src/main/resources/i18n/syslogMessage_zh_CN.properties @@ -0,0 +1,38 @@ +SYSLOG_MOD_COMMON=\u901A\u7528\u6A21\u5757 +SYSLOG_MOD_SYSLOG=\u64CD\u4F5C\u65E5\u5FD7\u6A21\u5757 +SYSLOG_MOD_AUTH=\u6743\u9650\u7BA1\u7406\u6A21\u5757 +SYSLOG_MOD_DICT=\u5B57\u5178\u6A21\u5757 +SYSLOG_MOD_SYSINFO=\u7CFB\u7EDF\u4FE1\u606F\u6A21\u5757 +SYSLOG_MOD_USER_MGR=\u7528\u6237\u7BA1\u7406\u6A21\u5757 +SYSLOG_MOD_SECURITY=\u7CFB\u7EDF\u5B89\u5168\u6A21\u5757 +SYSLOG_TYPE_AUTH=\u8BA4\u8BC1/\u9274\u6743 +SYSLOG_TYPE_READ=\u8BFB\u53D6 +SYSLOG_TYPE_WRITE=\u5199\u5165 +SYSLOG_TYPE_CREATE=\u521B\u5EFA +SYSLOG_TYPE_DEL=\u5220\u9664 +SYSLOG_TYPE_MODIFY=\u4FEE\u6539 +SYSLOG_DESC_GET_VERSION=\u83B7\u53D6\u5F53\u524D\u7CFB\u7EDF\u7248\u672C\u4FE1\u606F +SYSLOG_DESC_GET_SYSLOG_SUMMARY=\u83B7\u53D6\u64CD\u4F5C\u65E5\u5FD7\u7B80\u8981\u4FE1\u606F +SYSLOG_DESC_GET_SYSLOG_DETAIL=\u83B7\u53D6\u64CD\u4F5C\u65E5\u5FD7\u8BE6\u7EC6\u4FE1\u606F +SYSLOG_DESC_GET_CUR_USR_RES_RIGHT=\u83B7\u53D6\u5F53\u524D\u7528\u6237\u8D44\u6E90\u6743\u9650 +SYSLOG_DESC_GET_USR_RES_RIGHT=\u83B7\u53D6\u7528\u6237\u8D44\u6E90\u6743\u9650 +SYSLOG_DESC_GET_ALL_USR_GROUP=\u83B7\u53D6\u5F53\u524D\u6240\u6709\u7528\u6237\u7EC4 +SYSLOG_DESC_CREATE_RESOURCE=\u6CE8\u518C\u65B0\u7684\u8D44\u6E90 +SYSLOG_DESC_DEL_RESOURCE=\u5220\u9664\u8D44\u6E90 +SYSLOG_DESC_GET_ALL_ENUM_DICT=\u83B7\u53D6\u7CFB\u7EDF\u6240\u6709\u679A\u4E3E\u5B57\u5178\u7C7B\u578B\u4FE1\u606F +SYSLOG_DESC_GET_ENUM_DETAIL=\u83B7\u53D6\u7CFB\u7EDF\u679A\u4E3E\u5B57\u5178\u8BE6\u7EC6\u5185\u5BB9 +SYSLOG_DESC_CREATE_USER_DICT=\u65B0\u5EFA\u7528\u6237\u5B57\u5178 +SYSLOG_DESC_MODIFY_USER_DICT=\u4FEE\u6539\u7528\u6237\u5B57\u5178\u5185\u5BB9 +SYSLOG_DESC_GET_ALL_USER_DICT=\u83B7\u53D6\u6240\u6709\u7528\u6237\u5B57\u5178 +SYSLOG_DESC_GET_USER_DETAIL=\u83B7\u53D6\u7528\u6237\u5B57\u5178\u5185\u5BB9\u9879 +SYSLOG_DESC_CREATE_USER_DICT_ITEM=\u65B0\u589E\u7528\u6237\u5B57\u5178\u5185\u5BB9\u9879 +SYSLOG_DESC_GET_OS_INFO=\u83B7\u53D6\u5F53\u524D\u64CD\u4F5C\u7CFB\u7EDF\u4FE1\u606F +SYSLOG_DESC_GET_CPU_INFO=\u83B7\u53D6\u5F53\u524D\u5904\u7406\u5668\u4FE1\u606F +SYSLOG_DESC_GET_HW_INFO=\u83B7\u53D6\u7CFB\u7EDF\u786C\u4EF6\u4FE1\u606F +SYSLOG_DESC_GET_USER=\u83B7\u53D6\u7528\u6237\u4FE1\u606F +SYSLOG_DESC_GET_USER_LIST=\u83B7\u53D6\u7528\u6237\u5217\u8868 +SYSLOG_DESC_GET_CUR_USER=\u83B7\u53D6\u5F53\u524D\u7528\u6237\u4FE1\u606F +SYSLOG_DESC_CREATE_USER=\u521B\u5EFA\u65B0\u7528\u6237 +SYSLOG_DESC_DEL_USER=\u5220\u9664\u7528\u6237 +SYSLOG_DESC_LOGOUT=\u6CE8\u9500 +SYSLOG_DESC_LOGIN=\u767B\u5F55 \ No newline at end of file diff --git a/cs-database/src/main/java/com/cf/cs/database/pojo/entity/OperationLog.java b/cs-database/src/main/java/com/cf/cs/database/pojo/entity/OperationLog.java index cc15d0c..d634460 100644 --- a/cs-database/src/main/java/com/cf/cs/database/pojo/entity/OperationLog.java +++ b/cs-database/src/main/java/com/cf/cs/database/pojo/entity/OperationLog.java @@ -59,6 +59,10 @@ public class OperationLog { @Column(value = "description") private String description; + @Schema(description = "访问用户") + @Column(value = "access_user") + private String accessUser; + /** * 请求来源 IP 地址 */ diff --git a/cs-database/src/main/java/com/cf/cs/database/service/impl/OperationLogDataBaseServiceImpl.java b/cs-database/src/main/java/com/cf/cs/database/service/impl/OperationLogDataBaseServiceImpl.java index f145821..c0394c9 100644 --- a/cs-database/src/main/java/com/cf/cs/database/service/impl/OperationLogDataBaseServiceImpl.java +++ b/cs-database/src/main/java/com/cf/cs/database/service/impl/OperationLogDataBaseServiceImpl.java @@ -58,8 +58,8 @@ public class OperationLogDataBaseServiceImpl extends ServiceImpl getSystemOperationSummary(Long pageNumber, - Long pageSize, - Long totalSize, - List userName) { + public Page getSystemOperationSummary(Long pageNumber, Long pageSize, Long totalSize, List userName) { QueryWrapper wrapper; ApiContext ctx = ApiContextUtils.get(); @@ -163,19 +160,17 @@ public class OperationLogDataBaseServiceImpl extends ServiceImpl getSystemOperationDetails(List operationId) { - QueryWrapper wrapper = QueryWrapper.create() - .from(OPERATION_LOG) - .select() - .where(OPERATION_LOG.ID.in(operationId)); + QueryWrapper wrapper = QueryWrapper.create().from(OPERATION_LOG).select().where(OPERATION_LOG.ID.in(operationId)); return operationLogMapper.selectListByQuery(wrapper); } @@ -210,12 +202,13 @@ public class OperationLogDataBaseServiceImpl extends ServiceImpl getVersion() { return ProtocolResp.result(VersionResp.builder() .version(VersionInfo.builder() @@ -57,7 +57,7 @@ public class CommonFrameworkApi { */ @GetMapping("/version") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "通用模块", OperationType = "读取", OperationDesc = "获取当前系统版本信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_COMMON", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_VERSION") public ProtocolResp getVersionV2() { return ProtocolResp.result(VersionResp.builder() .version(VersionInfo.builder() diff --git a/cs-restful/src/main/java/com/cf/cs/restful/controller/OperationLogApi.java b/cs-restful/src/main/java/com/cf/cs/restful/controller/OperationLogApi.java index 3f6514a..b4e65a6 100644 --- a/cs-restful/src/main/java/com/cf/cs/restful/controller/OperationLogApi.java +++ b/cs-restful/src/main/java/com/cf/cs/restful/controller/OperationLogApi.java @@ -3,7 +3,9 @@ package com.cf.cs.restful.controller; import com.cf.cs.base.annotation.OperationLogAnnotation; import com.cf.cs.base.common.ErrorCode; +import com.cf.cs.base.misc.ApiContextUtils; import com.cf.cs.base.misc.HelperUtils; +import com.cf.cs.base.misc.MessageUtil; import com.cf.cs.crypto.annotation.EncryptionProtocol; import com.cf.cs.base.pojo.po.PageResults; import com.cf.cs.protocol.pojo.dto.OperationLogDetailsReq; @@ -49,7 +51,7 @@ public class OperationLogApi { */ @PostMapping("/summary") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "操作日志模块", OperationType = "读取", OperationDesc = "获取操作日志简要信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_SYSLOG", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_SYSLOG_SUMMARY") public ProtocolResp getSummary(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.BasePagedReqValid.class, @@ -61,6 +63,13 @@ public class OperationLogApi { PageResults ret = operationLogService.getOperationLogSummary(req.getPageNumber(), req.getPageSize(), req.getTotalSize(), req.getUserName()); + ret.getItems().forEach(k -> { + k.setOperationStatus(MessageUtil.get(k.getOperationStatus(), ApiContextUtils.getLanguare())); + k.setModule(MessageUtil.get(k.getModule(), ApiContextUtils.getLanguare())); + k.setOperationType(MessageUtil.get(k.getOperationType(), ApiContextUtils.getLanguare())); + k.setDescription(MessageUtil.get(k.getDescription(), ApiContextUtils.getLanguare())); + }); + return ProtocolResp.result(BasePageResultResp.builder() .items(ret) .build()); @@ -79,7 +88,7 @@ public class OperationLogApi { */ @PostMapping("/details") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "操作日志模块", OperationType = "读取", OperationDesc = "获取操作日志详细信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_SYSLOG", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_SYSLOG_DETAIL") public ProtocolResp getDetails(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.OperationLogReqValid.class); diff --git a/cs-restful/src/main/java/com/cf/cs/restful/controller/PermissionManagerApi.java b/cs-restful/src/main/java/com/cf/cs/restful/controller/PermissionManagerApi.java index 94ae544..c42522d 100644 --- a/cs-restful/src/main/java/com/cf/cs/restful/controller/PermissionManagerApi.java +++ b/cs-restful/src/main/java/com/cf/cs/restful/controller/PermissionManagerApi.java @@ -62,7 +62,7 @@ public class PermissionManagerApi { */ @GetMapping("resourcePermission") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "权限管理模块", OperationType = "读取", OperationDesc = "获取当前用户资源权限") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_AUTH", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DEC_GET_CUR_USR_RES_RIGHT") public ProtocolResp getCurrentUserResourcePermission() { AuthAccountUser au = authUsersService.getAuthAccountByUserName(ApiContextUtils.get().getUsername()); @@ -86,7 +86,7 @@ public class PermissionManagerApi { @PostMapping("resourcePermission") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "权限管理模块", OperationType = "读取", OperationDesc = "获取用户资源权限") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_AUTH", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DEC_GET_USR_RES_RIGHT") public ProtocolResp getUserResourcePermission(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.OperationLogReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -115,7 +115,7 @@ public class PermissionManagerApi { */ @GetMapping("/allRoles") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "权限管理模块", OperationType = "读取", OperationDesc = "获取当前所有用户组") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_AUTH", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_ALL_USR_GROUP") public ProtocolResp getAllRoles() { return ProtocolResp.result(GetRoleResp.builder().roles(userPermissionService.getAllUserGroup()).build()); } @@ -129,7 +129,7 @@ public class PermissionManagerApi { @PutMapping("/resource") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "权限管理模块", OperationType = "创建", OperationDesc = "注册新的资源") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_AUTH", OperationType = "SYSLOG_TYPE_CREATE", OperationDesc = "SYSLOG_DESC_CREATE_RESOURCE") public ProtocolResp registerResource(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.ResourceReqValid.class, ValidGroups.ResourceInfoValid.class); @@ -155,7 +155,7 @@ public class PermissionManagerApi { @DeleteMapping("/resource") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "权限管理模块", OperationType = "删除", OperationDesc = "删除资源") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_AUTH", OperationType = "SYSLOG_TYPE_DEL", OperationDesc = "SYSLOG_DESC_DEL_RESOURCE") public ProtocolResp removeResourceById(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.UserIdReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 diff --git a/cs-restful/src/main/java/com/cf/cs/restful/controller/SystemDictController.java b/cs-restful/src/main/java/com/cf/cs/restful/controller/SystemDictController.java index 1245dca..04c3b4f 100644 --- a/cs-restful/src/main/java/com/cf/cs/restful/controller/SystemDictController.java +++ b/cs-restful/src/main/java/com/cf/cs/restful/controller/SystemDictController.java @@ -57,7 +57,7 @@ public class SystemDictController { */ @GetMapping("/enum/allDict") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "字典模块", OperationType = "读取", OperationDesc = "获取系统所有枚举字典类型信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_DICT", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_ALL_ENUM_DICT") public ProtocolResp getEnumDictionary() { Set ret = dictionaryService.getAllEnumDictionary(); @@ -74,7 +74,7 @@ public class SystemDictController { */ @PostMapping("/enum/dictContent") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "字典模块", OperationType = "读取", OperationDesc = "获取系统枚举字典详细内容") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_DICT", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_ENUM_DETAIL") public ProtocolResp getEnumDictionaryContent(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.DictReqValid.class); @@ -103,7 +103,7 @@ public class SystemDictController { @PutMapping("/user/add") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "字典模块", OperationType = "创建", OperationDesc = "新建用户字典") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_DICT", OperationType = "SYSLOG_TYPE_CREATE", OperationDesc = "新建用户字典") public ProtocolResp createNewDictionary(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.DictReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -128,7 +128,7 @@ public class SystemDictController { @DeleteMapping("/user/delete") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "字典模块", OperationType = "创建", OperationDesc = "新建用户字典") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_DICT", OperationType = "SYSLOG_TYPE_CREATE", OperationDesc = "SYSLOG_DESC_CREATE_USER_DICT") public ProtocolResp removeDictionary(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.DictReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -153,7 +153,7 @@ public class SystemDictController { @PostMapping("/user/upgrade") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "字典模块", OperationType = "修改", OperationDesc = "修改用户字典内容") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_DICT", OperationType = "SYSLOG_TYPE_MODIFY", OperationDesc = "SYSLOG_DESC_MODIFY_USER_DICT") public ProtocolResp upgradeDictionary(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.DictReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -178,7 +178,7 @@ public class SystemDictController { @PostMapping("/user/allDict") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "字典模块", OperationType = "读取", OperationDesc = "获取所有用户字典") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_DICT", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_ALL_USER_DICT") public ProtocolResp getUserDictionary(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.BasePagedReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -205,7 +205,7 @@ public class SystemDictController { @PostMapping("/user/getDictContent") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "字典模块", OperationType = "读取", OperationDesc = "获取用户字典内容项") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_DICT", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_USER_DETAIL") public ProtocolResp getUserDictionaryContent(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.DictReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -231,7 +231,7 @@ public class SystemDictController { @PutMapping("/user/addDictContent") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "字典模块", OperationType = "创建", OperationDesc = "新增用户字典内容项") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_DICT", OperationType = "SYSLOG_TYPE_CREATE", OperationDesc = "SYSLOG_DESC_CREATE_USER_DICT_ITEM") public ProtocolResp createNewDictionaryContent(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.DictReqValid.class, ValidGroups.DictReqContentValid.class); diff --git a/cs-restful/src/main/java/com/cf/cs/restful/controller/SystemInfoApi.java b/cs-restful/src/main/java/com/cf/cs/restful/controller/SystemInfoApi.java index 7f621ea..5c0ee2a 100644 --- a/cs-restful/src/main/java/com/cf/cs/restful/controller/SystemInfoApi.java +++ b/cs-restful/src/main/java/com/cf/cs/restful/controller/SystemInfoApi.java @@ -36,7 +36,7 @@ public class SystemInfoApi { */ @GetMapping("/osInfo") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "系统信息模块", OperationType = "读取", OperationDesc = "获取当前操作系统信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_SYSINFO", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_OS_INFO") public ProtocolResp getOsInfo() { return ProtocolResp.result(GetOsInfoResp.builder() .os(systemInfoService.getOsName()) @@ -51,7 +51,7 @@ public class SystemInfoApi { */ @GetMapping("/processorInfo") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "系统信息模块", OperationType = "读取", OperationDesc = "获取当前处理器信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_SYSINFO", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_CPU_INFO") public ProtocolResp getProcessorInfo() { return ProtocolResp.result(GetProcessorInfoResp.builder().cpuInfo(systemInfoService.getProcessInfo()).build()); } @@ -63,7 +63,7 @@ public class SystemInfoApi { */ @GetMapping("/hwInfo") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "系统信息模块", OperationType = "读取", OperationDesc = "获取系统硬件信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_SYSINFO", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_HW_INFO") public ProtocolResp getHwInfo() { return ProtocolResp.result(GetHwInfoResp.builder().hwInfo(systemInfoService.getHardwareInfo()).build()); } diff --git a/cs-restful/src/main/java/com/cf/cs/restful/controller/UserManagerApi.java b/cs-restful/src/main/java/com/cf/cs/restful/controller/UserManagerApi.java index 279e10b..e175c83 100644 --- a/cs-restful/src/main/java/com/cf/cs/restful/controller/UserManagerApi.java +++ b/cs-restful/src/main/java/com/cf/cs/restful/controller/UserManagerApi.java @@ -58,7 +58,7 @@ public class UserManagerApi { @PostMapping("/userInfo") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "用户管理模块", OperationType = "读取", OperationDesc = "获取用户信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_USER_MGR", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_USER") public ProtocolResp getUserInfoById(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.OperationLogReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -82,7 +82,7 @@ public class UserManagerApi { @PostMapping("/userList") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "用户管理模块", OperationType = "读取", OperationDesc = "获取用户列表") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_USER_MGR", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_USER_LIST") public ProtocolResp getAllUserInfoPaged(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.BasePagedReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -106,7 +106,7 @@ public class UserManagerApi { */ @GetMapping("/userInfo") @EncryptionProtocol - @OperationLogAnnotation(OperationModule = "用户管理模块", OperationType = "读取", OperationDesc = "获取当前用户信息") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_USER_MGR", OperationType = "SYSLOG_TYPE_READ", OperationDesc = "SYSLOG_DESC_GET_CUR_USER") public ProtocolResp getCurrentUserInfo() { return ProtocolResp.result(GetUserInfoResp.builder() .userInfo(userDbService.getCurrentUserInfo()) @@ -122,7 +122,7 @@ public class UserManagerApi { @PutMapping("/register") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "用户管理模块", OperationType = "创建", OperationDesc = "创建新用户") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_USER_MGR", OperationType = "SYSLOG_TYPE_CREATE", OperationDesc = "SYSLOG_DESC_CREATE_USER") public ProtocolResp createNewUser(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.UserReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项 @@ -148,7 +148,7 @@ public class UserManagerApi { @DeleteMapping("/remove") @EncryptionProtocol @DecryptionProtocol - @OperationLogAnnotation(OperationModule = "用户管理模块", OperationType = "删除", OperationDesc = "删除用户") + @OperationLogAnnotation(OperationModule = "SYSLOG_MOD_USER_MGR", OperationType = "SYSLOG_TYPE_DEL", OperationDesc = "SYSLOG_DESC_DEL_USER") public ProtocolResp removeUser(@RequestBody ProtocolReq mr) { List validate = HelperUtils.validate(mr, ValidGroups.ProtocolCommonValid.class, ValidGroups.UserIdReqValid.class); // 如果校验通过,validate为空;否则,validate包含未校验通过项