From 301e2c57202e4ff127d01acddea39d684d039434 Mon Sep 17 00:00:00 2001 From: YunaiV <> Date: Sat, 4 Jul 2020 21:00:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=20mall-spring-boot-starter-web=20?= =?UTF-8?q?=E6=8E=A5=E5=85=A5=E6=96=B0=E7=9A=84=20system-service=20?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interceptor/AccountAuthInterceptor.java | 2 +- .../interceptor/AdminSecurityInterceptor.java | 2 +- .../interceptor/UserSecurityInterceptor.java | 2 +- common/mall-spring-boot-starter-web/pom.xml | 2 +- .../config/CommonWebAutoConfiguration.java | 8 +-- .../core/constant/CommonMallConstants.java | 18 +++++- .../core/handler/GlobalExceptionHandler.java | 21 +++---- .../interceptor/AccessLogInterceptor.java | 15 ++--- .../mall/web/core/util/CommonWebUtil.java | 12 +++- mall-dependencies/pom.xml | 1 - management-web-app/pom.xml | 4 +- .../src/main/resources/application.yml | 2 + .../mall/systemservice/rpc/package-info.java | 1 - .../rpc/systemlog/SystemLogRPC.java | 13 ++++ .../rpc/systemlog/dto/AccessLogAddDTO.java | 28 +++++---- .../rpc/systemlog/dto/ExceptionLogAddDTO.java | 15 +++-- .../convert/systemlog/SystemLogConvert.java | 34 ++++++++++ .../dataobject/systemlog/AccessLogDO.java | 22 +++---- .../dataobject/systemlog/ExceptionLogDO.java | 22 +++---- .../dal/mysql/mapper/package-info.java | 1 - .../mapper/systemlog/AccessLogMapper.java | 15 +++++ .../mapper/systemlog}/ExceptionLogMapper.java | 4 +- .../manager/systemlog/SystemLogManager.java | 24 +++++++ .../rpc/systemlog/SystemLogRPCImpl.java | 28 +++++++++ .../service/admin/AdminService.java | 4 ++ .../service/systemlog/SystemLogService.java | 39 ++++++++++++ .../service/systemlog/bo/AccessLogAddBO.java | 55 ++++++++++++++++ .../systemlog/bo/ExceptionLogAddBO.java | 63 +++++++++++++++++++ .../src/main/resources/application.yaml | 2 + .../mall/system/biz/bo/account/AccountBO.java | 26 -------- .../account/AccountUsernameAuthorizeBO.java | 22 ------- .../mall/system/biz/bo/admin/AdminBO.java | 40 ------------ .../biz/bo/ouath2/OAuth2AuthenticateBO.java | 32 ---------- .../system/biz/bo/systemlog/AccessLogBO.java | 41 ------------ .../biz/bo/user/UserAuthenticateBO.java | 15 ----- .../mall/system/biz/bo/user/UserBO.java | 35 ----------- .../biz/convert/account/AccountConvert.java | 18 ------ .../biz/convert/admin/AdminConvert.java | 21 ------- .../biz/convert/oauth2/OAuth2Convert.java | 17 ----- .../convert/systemlog/SystemLogConvert.java | 27 -------- .../biz/dao/system/AccessLogMapper.java | 25 -------- .../biz/service/account/AccountService.java | 19 ------ .../service/account/AccountServiceImpl.java | 49 --------------- .../biz/service/admin/AdminService.java | 30 --------- .../biz/service/admin/AdminServiceImpl.java | 19 ------ .../service/systemlog/SystemLogService.java | 17 ----- .../systemlog/SystemLogServiceImpl.java | 54 ---------------- .../rpc/api/systemlog/SystemLogRPC.java | 13 ---- .../rpc/rpc/systemlog/SystemLogRPCImpl.java | 34 ---------- 49 files changed, 382 insertions(+), 631 deletions(-) delete mode 100644 system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/package-info.java create mode 100644 system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPC.java rename system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/AccessLogAddRequest.java => system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/AccessLogAddDTO.java (76%) rename system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/ExceptionLogAddRequest.java => system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/ExceptionLogAddDTO.java (83%) create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemLogConvert.java rename {system/system-biz/src/main/java/cn/iocoder/mall/system/biz => system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql}/dataobject/systemlog/AccessLogDO.java (84%) rename {system/system-biz/src/main/java/cn/iocoder/mall/system/biz => system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql}/dataobject/systemlog/ExceptionLogDO.java (89%) delete mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/package-info.java create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/AccessLogMapper.java rename {system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/system => system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog}/ExceptionLogMapper.java (56%) create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemLogManager.java create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPCImpl.java create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemLogService.java create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/AccessLogAddBO.java create mode 100644 system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/ExceptionLogAddBO.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/account/AccountBO.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/account/AccountUsernameAuthorizeBO.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/admin/AdminBO.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/ouath2/OAuth2AuthenticateBO.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/systemlog/AccessLogBO.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/user/UserAuthenticateBO.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/user/UserBO.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/account/AccountConvert.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/admin/AdminConvert.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/oauth2/OAuth2Convert.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/systemlog/SystemLogConvert.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/system/AccessLogMapper.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/account/AccountService.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/account/AccountServiceImpl.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/admin/AdminService.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/admin/AdminServiceImpl.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/systemlog/SystemLogService.java delete mode 100644 system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/systemlog/SystemLogServiceImpl.java delete mode 100644 system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/api/systemlog/SystemLogRPC.java delete mode 100644 system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/rpc/systemlog/SystemLogRPCImpl.java diff --git a/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/AccountAuthInterceptor.java b/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/AccountAuthInterceptor.java index b814b6ec2..b45c07c21 100644 --- a/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/AccountAuthInterceptor.java +++ b/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/AccountAuthInterceptor.java @@ -73,7 +73,7 @@ public class AccountAuthInterceptor extends HandlerInterceptorAdapter { } // 设置账号编号 Integer accountId = oauth2AccessTokenResult.getData().getAccountId(); - CommonWebUtil.setAccountId(request, accountId); + CommonWebUtil.setUserId(request, accountId); return accountId; } diff --git a/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/AdminSecurityInterceptor.java b/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/AdminSecurityInterceptor.java index 695d7fb2b..ecb2056a8 100644 --- a/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/AdminSecurityInterceptor.java +++ b/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/AdminSecurityInterceptor.java @@ -22,7 +22,7 @@ public class AdminSecurityInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { - Integer accountId = CommonWebUtil.getAccountId(request); + Integer accountId = CommonWebUtil.getUserId(request); if (accountId != null) { // 获得 Admin 信息 CommonResult adminResult = adminRPC.getAdminByAccountId(accountId); diff --git a/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/UserSecurityInterceptor.java b/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/UserSecurityInterceptor.java index 39eaec627..a360dc696 100644 --- a/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/UserSecurityInterceptor.java +++ b/common/mall-spring-boot-starter-security/src/main/java/cn/iocoder/mall/security/core/interceptor/UserSecurityInterceptor.java @@ -21,7 +21,7 @@ public class UserSecurityInterceptor extends HandlerInterceptorAdapter { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { - Integer accountId = CommonWebUtil.getAccountId(request); + Integer accountId = CommonWebUtil.getUserId(request); if (accountId != null) { // 获得 Admin 信息 CommonResult userResult = userRPC.getUserByAccountId(accountId); diff --git a/common/mall-spring-boot-starter-web/pom.xml b/common/mall-spring-boot-starter-web/pom.xml index c649798cf..0d0e71c89 100644 --- a/common/mall-spring-boot-starter-web/pom.xml +++ b/common/mall-spring-boot-starter-web/pom.xml @@ -15,7 +15,7 @@ cn.iocoder.mall - system-rpc-api + system-service-api 1.0-SNAPSHOT true diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/config/CommonWebAutoConfiguration.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/config/CommonWebAutoConfiguration.java index ffdb369a1..34960dfbb 100644 --- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/config/CommonWebAutoConfiguration.java +++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/config/CommonWebAutoConfiguration.java @@ -1,10 +1,9 @@ package cn.iocoder.mall.web.config; -import cn.iocoder.mall.web.core.servlet.CorsFilter; -import cn.iocoder.mall.web.core.constant.CommonMallConstants; import cn.iocoder.mall.web.core.handler.GlobalExceptionHandler; import cn.iocoder.mall.web.core.handler.GlobalResponseBodyHandler; import cn.iocoder.mall.web.core.interceptor.AccessLogInterceptor; +import cn.iocoder.mall.web.core.servlet.CorsFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -40,7 +39,7 @@ public class CommonWebAutoConfiguration implements WebMvcConfigurer { // ========== 拦截器相关 ========== @Bean - @ConditionalOnClass(name = {"cn.iocoder.mall.system.rpc.api.systemlog.SystemLogRPC", "org.apache.dubbo.config.annotation.Reference"}) + @ConditionalOnClass(name = {"cn.iocoder.mall.systemservice.rpc.systemlog.SystemLogRPC", "org.apache.dubbo.config.annotation.Reference"}) @ConditionalOnMissingBean(AccessLogInterceptor.class) public AccessLogInterceptor accessLogInterceptor() { return new AccessLogInterceptor(); @@ -49,8 +48,7 @@ public class CommonWebAutoConfiguration implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { try { - registry.addInterceptor(this.accessLogInterceptor()) - .addPathPatterns(CommonMallConstants.ROOT_PATH_ADMIN + "/**", CommonMallConstants.ROOT_PATH_USER + "/**"); + registry.addInterceptor(this.accessLogInterceptor()); logger.info("[addInterceptors][加载 AccessLogInterceptor 拦截器完成]"); } catch (NoSuchBeanDefinitionException e) { logger.warn("[addInterceptors][无法获取 AccessLogInterceptor 拦截器,因此不启动 AccessLog 的记录]"); diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/constant/CommonMallConstants.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/constant/CommonMallConstants.java index 499933ae4..ef9fbbefd 100644 --- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/constant/CommonMallConstants.java +++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/constant/CommonMallConstants.java @@ -6,19 +6,33 @@ public interface CommonMallConstants { /** * 根路径 - 用户 */ + @Deprecated String ROOT_PATH_USER = "/users"; /** * 根路径 - 管理员 */ + @Deprecated String ROOT_PATH_ADMIN = "/admins"; // HTTP Request Attr /** - * HTTP Request Attr - 账号编号 + * HTTP Request Attr - 用户编号 + * + * 考虑到 mall-spring-boot-starter-web 不依赖 mall-spring-boot-starter-security,但是又希望拿到认证过的用户编号, + * 因此通过 Request 的 Attribute 进行共享 */ - String REQUEST_ATTR_USER_ID_KEY = "mall_account_id"; + String REQUEST_ATTR_USER_ID_KEY = "mall_user_id"; + /** + * HTTP Request Attr - 用户类型 + * + * 作用同 {@link #REQUEST_ATTR_USER_ID_KEY} + */ + String REQUEST_ATTR_USER_TYPE_KEY = "mall_user_type"; + /** * HTTP Request Attr - Controller 执行返回 + * + * 通过该 Request 的 Attribute,获取到请求执行结果,从而在访问日志中,记录是否成功。 */ String REQUEST_ATTR_COMMON_RESULT = "mall_common_result"; /** diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java index 69abb6e3b..e30b5c04a 100644 --- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java +++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/handler/GlobalExceptionHandler.java @@ -6,8 +6,8 @@ import cn.iocoder.common.framework.util.ExceptionUtil; import cn.iocoder.common.framework.util.HttpUtil; import cn.iocoder.common.framework.util.MallUtils; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.system.rpc.api.systemlog.SystemLogRPC; -import cn.iocoder.mall.system.rpc.request.systemlog.ExceptionLogAddRequest; +import cn.iocoder.mall.systemservice.rpc.systemlog.SystemLogRPC; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO; import cn.iocoder.mall.web.core.util.CommonWebUtil; import com.alibaba.fastjson.JSON; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -33,7 +33,6 @@ public class GlobalExceptionHandler { // TODO 芋艿,应该还有其它的异常,需要进行翻译 - // /** // * 异常总数 Metrics // */ @@ -50,20 +49,20 @@ public class GlobalExceptionHandler { // 逻辑异常 @ExceptionHandler(value = ServiceException.class) - public CommonResult serviceExceptionHandler(HttpServletRequest req, ServiceException ex) { + public CommonResult serviceExceptionHandler(ServiceException ex) { logger.debug("[serviceExceptionHandler]", ex); return CommonResult.error(ex.getCode(), ex.getMessage()); } // Spring MVC 参数不正确 @ExceptionHandler(value = MissingServletRequestParameterException.class) - public CommonResult missingServletRequestParameterExceptionHandler(HttpServletRequest req, MissingServletRequestParameterException ex) { + public CommonResult missingServletRequestParameterExceptionHandler(MissingServletRequestParameterException ex) { logger.warn("[missingServletRequestParameterExceptionHandler]", ex); return CommonResult.error(SysErrorCodeEnum.MISSING_REQUEST_PARAM_ERROR.getCode(), SysErrorCodeEnum.MISSING_REQUEST_PARAM_ERROR.getMessage() + ":" + ex.getMessage()); } @ExceptionHandler(value = ConstraintViolationException.class) - public CommonResult constraintViolationExceptionHandler(HttpServletRequest req, ConstraintViolationException ex) { + public CommonResult constraintViolationExceptionHandler(ConstraintViolationException ex) { logger.info("[constraintViolationExceptionHandler]", ex); // TODO 芋艿,后续要想一个更好的方式。 // 拼接详细报错 @@ -77,7 +76,7 @@ public class GlobalExceptionHandler { public CommonResult exceptionHandler(HttpServletRequest req, Exception e) { logger.error("[exceptionHandler]", e); // 插入异常日志 - ExceptionLogAddRequest exceptionLog = new ExceptionLogAddRequest(); + ExceptionLogAddDTO exceptionLog = new ExceptionLogAddDTO(); try { // 增加异常计数 metrics TODO 暂时去掉 // EXCEPTION_COUNTER.increment(); @@ -92,9 +91,10 @@ public class GlobalExceptionHandler { return CommonResult.error(SysErrorCodeEnum.SYS_ERROR.getCode(), SysErrorCodeEnum.SYS_ERROR.getMessage()); } - private void initExceptionLog(ExceptionLogAddRequest exceptionLog, HttpServletRequest request, Exception e) { + private void initExceptionLog(ExceptionLogAddDTO exceptionLog, HttpServletRequest request, Exception e) { // 设置账号编号 - exceptionLog.setAccountId(CommonWebUtil.getAccountId(request)); + exceptionLog.setUserId(CommonWebUtil.getUserId(request)); + exceptionLog.setUserType(CommonWebUtil.getUserType(request)); // 设置异常字段 exceptionLog.setExceptionName(e.getClass().getName()); exceptionLog.setExceptionMessage(ExceptionUtil.getMessage(e)); @@ -119,13 +119,12 @@ public class GlobalExceptionHandler { } @Async - public void addExceptionLog(ExceptionLogAddRequest exceptionLog) { + public void addExceptionLog(ExceptionLogAddDTO exceptionLog) { try { systemLogRPC.addExceptionLog(exceptionLog); } catch (Throwable th) { logger.error("[addAccessLog][插入异常日志({}) 发生异常({})", JSON.toJSONString(exceptionLog), ExceptionUtils.getRootCauseMessage(th)); } - } } diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java index 0e7f7f65d..27d493786 100644 --- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java +++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/interceptor/AccessLogInterceptor.java @@ -3,8 +3,8 @@ package cn.iocoder.mall.web.core.interceptor; import cn.iocoder.common.framework.util.HttpUtil; import cn.iocoder.common.framework.util.MallUtils; import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.system.rpc.api.systemlog.SystemLogRPC; -import cn.iocoder.mall.system.rpc.request.systemlog.AccessLogAddRequest; +import cn.iocoder.mall.systemservice.rpc.systemlog.SystemLogRPC; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO; import cn.iocoder.mall.web.core.util.CommonWebUtil; import com.alibaba.fastjson.JSON; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -27,7 +27,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { private Logger logger = LoggerFactory.getLogger(getClass()); - @Reference(validation = "true", version = "${dubbo.consumer.SystemLogRPC.version}") + @Reference(validation = "false", version = "${dubbo.consumer.SystemLogRPC.version}") private SystemLogRPC systemLogRPC; @Value("${spring.application.name}") @@ -42,7 +42,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { - AccessLogAddRequest accessLog = new AccessLogAddRequest(); + AccessLogAddDTO accessLog = new AccessLogAddDTO(); try { // 初始化 accessLog initAccessLog(accessLog, request); @@ -54,9 +54,10 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { } } - private void initAccessLog(AccessLogAddRequest accessLog, HttpServletRequest request) { + private void initAccessLog(AccessLogAddDTO accessLog, HttpServletRequest request) { // 设置账号编号 - accessLog.setAccountId(CommonWebUtil.getAccountId(request)); + accessLog.setUserId(CommonWebUtil.getUserId(request)); + accessLog.setUserType(CommonWebUtil.getUserType(request)); // 设置访问结果 CommonResult result = CommonWebUtil.getCommonResult(request); Assert.isTrue(result != null, "result 必须非空"); @@ -75,7 +76,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { } @Async // 异步入库 - public void addAccessLog(AccessLogAddRequest accessLog) { + public void addAccessLog(AccessLogAddDTO accessLog) { try { systemLogRPC.addAccessLog(accessLog); } catch (Throwable th) { diff --git a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/util/CommonWebUtil.java b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/util/CommonWebUtil.java index 92a408d64..41203fa40 100644 --- a/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/util/CommonWebUtil.java +++ b/common/mall-spring-boot-starter-web/src/main/java/cn/iocoder/mall/web/core/util/CommonWebUtil.java @@ -8,14 +8,22 @@ import java.util.Date; public class CommonWebUtil { - public static Integer getAccountId(ServletRequest request) { + public static Integer getUserId(ServletRequest request) { return (Integer) request.getAttribute(CommonMallConstants.REQUEST_ATTR_USER_ID_KEY); } - public static void setAccountId(ServletRequest request, Integer userId) { + public static void setUserId(ServletRequest request, Integer userId) { request.setAttribute(CommonMallConstants.REQUEST_ATTR_USER_ID_KEY, userId); } + public static Integer getUserType(ServletRequest request) { + return (Integer) request.getAttribute(CommonMallConstants.REQUEST_ATTR_USER_TYPE_KEY); + } + + public static void setUserType(ServletRequest request, Integer userType) { + request.setAttribute(CommonMallConstants.REQUEST_ATTR_USER_TYPE_KEY, userType); + } + public static CommonResult getCommonResult(ServletRequest request) { return (CommonResult) request.getAttribute(CommonMallConstants.REQUEST_ATTR_COMMON_RESULT); } diff --git a/mall-dependencies/pom.xml b/mall-dependencies/pom.xml index 6e5f0a5be..c42475a83 100644 --- a/mall-dependencies/pom.xml +++ b/mall-dependencies/pom.xml @@ -17,7 +17,6 @@ - 2.2.4.RELEASE Hoxton.SR1 2.2.1.RELEASE diff --git a/management-web-app/pom.xml b/management-web-app/pom.xml index f45ef6288..7a90b5adf 100644 --- a/management-web-app/pom.xml +++ b/management-web-app/pom.xml @@ -28,8 +28,8 @@ - org.springframework.boot - spring-boot-starter-web + cn.iocoder.mall + mall-spring-boot-starter-web diff --git a/management-web-app/src/main/resources/application.yml b/management-web-app/src/main/resources/application.yml index 66b4691d4..f39a264ba 100644 --- a/management-web-app/src/main/resources/application.yml +++ b/management-web-app/src/main/resources/application.yml @@ -28,3 +28,5 @@ dubbo: version: 1.0.0 AdminRpc: version: 1.0.0 + SystemLogRPC: + version: 1.0.0 diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/package-info.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/package-info.java deleted file mode 100644 index e75b646bd..000000000 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.systemservice.rpc; diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPC.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPC.java new file mode 100644 index 000000000..b4501c907 --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPC.java @@ -0,0 +1,13 @@ +package cn.iocoder.mall.systemservice.rpc.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO; + +public interface SystemLogRPC { + + CommonResult addAccessLog(AccessLogAddDTO accessLogAddDTO); + + CommonResult addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO); + +} diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/AccessLogAddRequest.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/AccessLogAddDTO.java similarity index 76% rename from system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/AccessLogAddRequest.java rename to system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/AccessLogAddDTO.java index 1cf91c23b..d4a7787c5 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/AccessLogAddRequest.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/AccessLogAddDTO.java @@ -1,5 +1,6 @@ -package cn.iocoder.mall.system.rpc.request.systemlog; +package cn.iocoder.mall.systemservice.rpc.systemlog.dto; +import cn.iocoder.common.framework.enums.UserTypeEnum; import lombok.Data; import lombok.experimental.Accessors; @@ -8,25 +9,26 @@ import java.io.Serializable; import java.util.Date; /** - * 访问日志添加 Request + * 访问日志添加 DTO */ @Data @Accessors(chain = true) -public class AccessLogAddRequest implements Serializable { +public class AccessLogAddDTO implements Serializable { - /** - * 用户编号 - 空 - */ - public static final Integer ACCOUNT_ID_NULL = 0; - - /** - * 链路追踪编号 - */ - private String traceId; /** * 账号编号 */ - private Integer accountId; + private Integer userId; + /** + * 用户类型 + * + * 枚举 {@link UserTypeEnum} + */ + private Integer userType; + /** + * 链路编号 + */ + private String traceId; @NotNull(message = "应用名不能为空") private String applicationName; @NotNull(message = "访问地址不能为空") diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/ExceptionLogAddRequest.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/ExceptionLogAddDTO.java similarity index 83% rename from system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/ExceptionLogAddRequest.java rename to system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/ExceptionLogAddDTO.java index 920fdef31..5b39c7cb4 100644 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/request/systemlog/ExceptionLogAddRequest.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/ExceptionLogAddDTO.java @@ -1,5 +1,6 @@ -package cn.iocoder.mall.system.rpc.request.systemlog; +package cn.iocoder.mall.systemservice.rpc.systemlog.dto; +import cn.iocoder.common.framework.enums.UserTypeEnum; import lombok.Data; import lombok.experimental.Accessors; @@ -8,16 +9,22 @@ import java.io.Serializable; import java.util.Date; /** - * 异常日志添加 Request + * 异常日志添加 DTO */ @Data @Accessors(chain = true) -public class ExceptionLogAddRequest implements Serializable { +public class ExceptionLogAddDTO implements Serializable { /** * 账号编号 */ - private Integer accountId; + private Integer userId; + /** + * 用户类型 + * + * 枚举 {@link UserTypeEnum} + */ + private Integer userType; /** * 链路编号 */ diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemLogConvert.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemLogConvert.java new file mode 100644 index 000000000..3831c807a --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemLogConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.mall.systemservice.convert.systemlog; + +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.AccessLogDO; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.ExceptionLogDO; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.AccessLogAddBO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.ExceptionLogAddBO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface SystemLogConvert { + + SystemLogConvert INSTANCE = Mappers.getMapper(SystemLogConvert.class); + + AccessLogDO convert(AccessLogAddBO bean); + + ExceptionLogDO convert(ExceptionLogAddBO bean); + + AccessLogAddBO convert(AccessLogAddDTO bean); + + ExceptionLogAddBO convert(ExceptionLogAddDTO bean); + +// AccessLogDO convert(AccessLogAddDTO bean); +// +// ExceptionLogDO convert(ExceptionLogAddDTO bean); +// +// @Mapping(source = "records", target = "list") +// PageResult convertPage(IPage page); +// +// AccessLogBO convert(AccessLogDO bean); + +} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dataobject/systemlog/AccessLogDO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/AccessLogDO.java similarity index 84% rename from system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dataobject/systemlog/AccessLogDO.java rename to system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/AccessLogDO.java index 7384432e1..02204023f 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dataobject/systemlog/AccessLogDO.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/AccessLogDO.java @@ -1,5 +1,6 @@ -package cn.iocoder.mall.system.biz.dataobject.systemlog; +package cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog; +import cn.iocoder.common.framework.enums.UserTypeEnum; import cn.iocoder.common.framework.vo.CommonResult; import cn.iocoder.mall.mybatis.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.TableName; @@ -12,27 +13,26 @@ import java.util.Date; /** * 访问日志 DO */ +@TableName("system_access_log") @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) -@TableName("access_log") public class AccessLogDO extends BaseDO { - /** - * 账号编号 - 空 - */ - public static final Integer ACCOUNT_ID_NULL = 0; - /** * 编号 */ private Integer id; /** - * 账号编号 - * - * 空值 {@link #ACCOUNT_ID_NULL} + * 用户编号 */ - private Integer accountId; + private Integer userId; + /** + * 用户类型 + * + * 枚举 {@link UserTypeEnum} + */ + private Integer userType; /** * 链路追踪编号 * diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dataobject/systemlog/ExceptionLogDO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/ExceptionLogDO.java similarity index 89% rename from system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dataobject/systemlog/ExceptionLogDO.java rename to system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/ExceptionLogDO.java index e9958dc7b..351ff5122 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dataobject/systemlog/ExceptionLogDO.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/ExceptionLogDO.java @@ -1,5 +1,6 @@ -package cn.iocoder.mall.system.biz.dataobject.systemlog; +package cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog; +import cn.iocoder.common.framework.enums.UserTypeEnum; import cn.iocoder.mall.mybatis.dataobject.BaseDO; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; @@ -11,27 +12,26 @@ import java.util.Date; /** * 异常日志 DO */ +@TableName("system_exception_log") @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) -@TableName("exception_log") public class ExceptionLogDO extends BaseDO { - /** - * 账号编号 - 空 - */ - public static final Integer ACCOUNT_ID_NULL = 0; - /** * 编号 */ private Integer id; /** - * 账号编号 - * - * 空值 {@link #ACCOUNT_ID_NULL} + * 用户编号 */ - private Integer accountId; + private Integer userId; + /** + * 用户类型 + * + * 枚举 {@link UserTypeEnum} + */ + private Integer userType; /** * 链路追踪编号 * diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/package-info.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/package-info.java deleted file mode 100644 index 4b7810037..000000000 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package cn.iocoder.mall.systemservice.dal.mysql.mapper; diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/AccessLogMapper.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/AccessLogMapper.java new file mode 100644 index 000000000..43e3bbb2a --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/AccessLogMapper.java @@ -0,0 +1,15 @@ +package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog; + +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.AccessLogDO; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.springframework.stereotype.Repository; + +@Repository +public interface AccessLogMapper extends BaseMapper { + +// default IPage selectPage(AccessLogPageDTO accessLogPageDTO) { +// return selectPage(new Page<>(accessLogPageDTO.getPageNo(), accessLogPageDTO.getPageSize()), +// new QueryWrapperX().eqIfPresent("account_id", accessLogPageDTO.getAccountId())); +// } + +} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/system/ExceptionLogMapper.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/ExceptionLogMapper.java similarity index 56% rename from system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/system/ExceptionLogMapper.java rename to system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/ExceptionLogMapper.java index 41999c3c1..7ad85c9d5 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/system/ExceptionLogMapper.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/ExceptionLogMapper.java @@ -1,6 +1,6 @@ -package cn.iocoder.mall.system.biz.dao.system; +package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog; -import cn.iocoder.mall.system.biz.dataobject.systemlog.ExceptionLogDO; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.ExceptionLogDO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemLogManager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemLogManager.java new file mode 100644 index 000000000..84d28d8bf --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemLogManager.java @@ -0,0 +1,24 @@ +package cn.iocoder.mall.systemservice.manager.systemlog; + +import cn.iocoder.mall.systemservice.convert.systemlog.SystemLogConvert; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO; +import cn.iocoder.mall.systemservice.service.systemlog.SystemLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SystemLogManager { + + @Autowired + private SystemLogService systemLogService; + + public void addAccessLog(AccessLogAddDTO accessLogAddDTO) { + systemLogService.addAccessLog(SystemLogConvert.INSTANCE.convert(accessLogAddDTO)); + } + + public void addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO) { + systemLogService.addExceptionLog(SystemLogConvert.INSTANCE.convert(exceptionLogAddDTO)); + } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPCImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPCImpl.java new file mode 100644 index 000000000..7c2b4f22c --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPCImpl.java @@ -0,0 +1,28 @@ +package cn.iocoder.mall.systemservice.rpc.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.systemservice.manager.systemlog.SystemLogManager; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO; +import org.apache.dubbo.config.annotation.Service; +import org.springframework.beans.factory.annotation.Autowired; + +@Service(version = "${dubbo.provider.SystemLogRPC.version}", validation = "false") +public class SystemLogRPCImpl implements SystemLogRPC { + + @Autowired + private SystemLogManager systemLogManager; + + @Override + public CommonResult addAccessLog(AccessLogAddDTO accessLogAddDTO) { + systemLogManager.addAccessLog(accessLogAddDTO); + return CommonResult.success(true); + } + + @Override + public CommonResult addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO) { + systemLogManager.addExceptionLog(exceptionLogAddDTO); + return CommonResult.success(true); + } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java index 483a647f1..a7325c94a 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/admin/AdminService.java @@ -36,4 +36,8 @@ public class AdminService { return AdminConvert.INSTANCE.convert(adminDO); } +// public PageResult getAdminPage(AdminPageDTO pageDTO) { +// return AdminConvert.INSTANCE.convertPage(adminMapper.selectPage(pageDTO)); +// } + } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemLogService.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemLogService.java new file mode 100644 index 000000000..36cb24a74 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemLogService.java @@ -0,0 +1,39 @@ +package cn.iocoder.mall.systemservice.service.systemlog; + +import cn.iocoder.mall.systemservice.convert.systemlog.SystemLogConvert; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.AccessLogDO; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.ExceptionLogDO; +import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.AccessLogMapper; +import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.ExceptionLogMapper; +import cn.iocoder.mall.systemservice.service.systemlog.bo.AccessLogAddBO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.ExceptionLogAddBO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class SystemLogService { + + @Autowired + private AccessLogMapper accessLogMapper; + @Autowired + private ExceptionLogMapper exceptionLogMapper; + + public void addAccessLog(AccessLogAddBO accessLogAddBO) { + AccessLogDO logDO = SystemLogConvert.INSTANCE.convert(accessLogAddBO); + accessLogMapper.insert(logDO); + } + + public void addExceptionLog(ExceptionLogAddBO exceptionLogAddBO) { + ExceptionLogDO logDO = SystemLogConvert.INSTANCE.convert(exceptionLogAddBO); + exceptionLogMapper.insert(logDO); + } + +// @Override +// @SuppressWarnings("Duplicates") +// public PageResult getAccessLogPage(AccessLogPageDTO accessLogPageDTO) { +// PageResult accessLogPageBOPageResult = SystemLogConvert.INSTANCE.convertPage( +// accessLogMapper.selectPage(accessLogPageDTO)); // TODO FROM 芋艿 to 2447007062:可以考虑直接 return,简洁 + IDEA 不告警; +// return accessLogPageBOPageResult; +// } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/AccessLogAddBO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/AccessLogAddBO.java new file mode 100644 index 000000000..1f0bca2dc --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/AccessLogAddBO.java @@ -0,0 +1,55 @@ +package cn.iocoder.mall.systemservice.service.systemlog.bo; + +import cn.iocoder.common.framework.enums.UserTypeEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * 访问日志添加 BO + */ +@Data +@Accessors(chain = true) +public class AccessLogAddBO implements Serializable { + + /** + * 账号编号 + */ + private Integer userId; + /** + * 用户类型 + * + * 枚举 {@link UserTypeEnum} + */ + private Integer userType; + /** + * 链路编号 + */ + private String traceId; + @NotNull(message = "应用名不能为空") + private String applicationName; + @NotNull(message = "访问地址不能为空") + private String uri; + @NotNull(message = "请求参数不能为空") + private String queryString; + @NotNull(message = "http 请求方法不能为空") + private String method; + @NotNull(message = "User-Agent 不能为空") + private String userAgent; + @NotNull(message = "ip 不能为空") + private String ip; + @NotNull(message = "请求时间不能为空") + private Date startTime; + @NotNull(message = "响应时长不能为空") + private Integer responseTime; + @NotNull(message = "错误码不能为空") + private Integer errorCode; + /** + * 错误提示 + */ + private String errorMessage; + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/ExceptionLogAddBO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/ExceptionLogAddBO.java new file mode 100644 index 000000000..904326c37 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/ExceptionLogAddBO.java @@ -0,0 +1,63 @@ +package cn.iocoder.mall.systemservice.service.systemlog.bo; + +import cn.iocoder.common.framework.enums.UserTypeEnum; +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.util.Date; + +/** + * 异常日志添加 BO + */ +@Data +@Accessors(chain = true) +public class ExceptionLogAddBO implements Serializable { + + /** + * 账号编号 + */ + private Integer userId; + /** + * 用户类型 + * + * 枚举 {@link UserTypeEnum} + */ + private Integer userType; + /** + * 链路编号 + */ + private String traceId; + @NotNull(message = "应用名不能为空") + private String applicationName; + @NotNull(message = "访问地址不能为空") + private String uri; + @NotNull(message = "请求参数不能为空") + private String queryString; + @NotNull(message = "http 请求方法不能为空") + private String method; + @NotNull(message = "User-Agent 不能为空") + private String userAgent; + @NotNull(message = "ip 不能为空") + private String ip; + @NotNull(message = "异常时间不能为空") + private Date exceptionTime; + @NotNull(message = "异常名不能为空") + private String exceptionName; + @NotNull(message = "异常发生的类全名不能为空") + private String exceptionClassName; + @NotNull(message = "异常发生的类文件不能为空") + private String exceptionFileName; + @NotNull(message = "异常发生的方法名不能为空") + private String exceptionMethodName; + @NotNull(message = "异常发生的方法所在行不能为空") + private Integer exceptionLineNumber; + @NotNull(message = "异常的栈轨迹不能为空") + private String exceptionStackTrace; + @NotNull(message = "异常导致的根消息不能为空") + private String exceptionRootCauseMessage; + @NotNull(message = "异常导致的消息不能为空") + private String exceptionMessage; + +} diff --git a/system-service-project/system-service-app/src/main/resources/application.yaml b/system-service-project/system-service-app/src/main/resources/application.yaml index 349b7252d..1052a4b18 100644 --- a/system-service-project/system-service-app/src/main/resources/application.yaml +++ b/system-service-project/system-service-app/src/main/resources/application.yaml @@ -37,3 +37,5 @@ dubbo: version: 1.0.0 AdminRpc: version: 1.0.0 + SystemLogRPC: + version: 1.0.0 diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/account/AccountBO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/account/AccountBO.java deleted file mode 100644 index e66100a7c..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/account/AccountBO.java +++ /dev/null @@ -1,26 +0,0 @@ -package cn.iocoder.mall.system.biz.bo.account; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 账号模块 - 账号信息 BO - */ -@Data -@Accessors(chain = true) -public class AccountBO { - - /** - * 账号编号 - */ - private Integer id; - /** - * 登陆账号 - */ - private String username; - /** - * 登陆密码 - */ - private String password; - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/account/AccountUsernameAuthorizeBO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/account/AccountUsernameAuthorizeBO.java deleted file mode 100644 index 1dcb0d57a..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/account/AccountUsernameAuthorizeBO.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.iocoder.mall.system.biz.bo.account; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * 账号模块 - 用户名登陆 BO - */ -@Data -@Accessors(chain = true) -public class AccountUsernameAuthorizeBO { - - /** - * 用户名 - */ - private String username; - /** - * 密码 - */ - private String password; - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/admin/AdminBO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/admin/AdminBO.java deleted file mode 100644 index 6a8c03da6..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/admin/AdminBO.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.iocoder.mall.system.biz.bo.admin; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * 管理员模块 - 账号信息 BO - */ -@Data -@Accessors(chain = true) -public class AdminBO { - - /** - * 管理员编号 - */ - private Integer id; - /** - * 账号编号 - */ - private Integer accountId; - /** - * 真实名字 - */ - private String name; - /** - * 部门编号 - */ - private Integer departmentId; - /** - * 在职状态 - */ - private Integer status; - /** - * 创建时间 - */ - private Date createTime; - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/ouath2/OAuth2AuthenticateBO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/ouath2/OAuth2AuthenticateBO.java deleted file mode 100644 index 15234e77b..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/ouath2/OAuth2AuthenticateBO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.mall.system.biz.bo.ouath2; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * 认证模块 - 认证结果 BO - */ -@Data -@Accessors(chain = true) -public class OAuth2AuthenticateBO { - - /** - * 访问令牌 - */ - private String accessToken; - /** - * 刷新令牌 - */ - private String refreshToken; - /** - * 账号编号 - */ - private Integer accountId; - /** - * 过期时间 - */ - private Date expiresTime; - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/systemlog/AccessLogBO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/systemlog/AccessLogBO.java deleted file mode 100644 index ad2f62595..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/systemlog/AccessLogBO.java +++ /dev/null @@ -1,41 +0,0 @@ -package cn.iocoder.mall.system.biz.bo.systemlog; - -import lombok.Data; -import lombok.experimental.Accessors; - -import java.io.Serializable; -import java.util.Date; - -/** // TODO FROM 芋艿 to 2447007062:最好加下字段的注释哈; - * @author:mac - * @descriptio - * @create: 2020-5-12 20:43:00 - */ -@Data -@Accessors(chain = true) -public class AccessLogBO implements Serializable { - - private String traceId; - - private Integer accountId; - - private String applicationName; - - private String uri; - - private String queryString; - - private String method; - - private String userAgent; - - private String ip; - - private Date startTime; - - private Integer responseTime; - - private Integer errorCode; - - private String errorMessage; -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/user/UserAuthenticateBO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/user/UserAuthenticateBO.java deleted file mode 100644 index cef180fbb..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/user/UserAuthenticateBO.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.mall.system.biz.bo.user; - -import cn.iocoder.mall.system.biz.bo.ouath2.OAuth2AuthenticateBO; -import lombok.Data; -import lombok.experimental.Accessors; - -@Data -@Accessors(chain = true) -public class UserAuthenticateBO { - - private UserBO user; - - private OAuth2AuthenticateBO token; - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/user/UserBO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/user/UserBO.java deleted file mode 100644 index e1238b17d..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/bo/user/UserBO.java +++ /dev/null @@ -1,35 +0,0 @@ -package cn.iocoder.mall.system.biz.bo.user; - -import lombok.Data; -import lombok.experimental.Accessors; - -/** - * User 模块 - User 信息 BO - */ -@Data -@Accessors(chain = true) -public class UserBO { - - /** - * 用户编号 - */ - private Integer id; - /** - * 昵称 - */ - private String nickname; - /** - * 手机号 - */ - private String mobile; - /** - * 头像 - */ - private String avatar; - - /** - * 用户状态 1 - 开启;2 - 禁用 - */ - private Integer status; - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/account/AccountConvert.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/account/AccountConvert.java deleted file mode 100644 index de9787d18..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/account/AccountConvert.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.mall.system.biz.convert.account; - -import cn.iocoder.mall.system.biz.bo.account.AccountBO; -import cn.iocoder.mall.system.biz.dataobject.account.AccountDO; -import cn.iocoder.mall.system.biz.dto.account.AccountCreateDTO; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AccountConvert { - - AccountConvert INSTANCE = Mappers.getMapper(AccountConvert.class); - - AccountBO convert(AccountDO bean); - - AccountDO convert(AccountCreateDTO bean); - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/admin/AdminConvert.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/admin/AdminConvert.java deleted file mode 100644 index f7cfb0d45..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/admin/AdminConvert.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.mall.system.biz.convert.admin; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.admin.AdminBO; -import cn.iocoder.mall.system.biz.dataobject.admin.AdminDO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface AdminConvert { - - AdminConvert INSTANCE = Mappers.getMapper(AdminConvert.class); - - AdminBO convert(AdminDO bean); - - @Mapping(source = "records", target = "list") - PageResult convertPage(IPage bean); - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/oauth2/OAuth2Convert.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/oauth2/OAuth2Convert.java deleted file mode 100644 index 08845a6dc..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/oauth2/OAuth2Convert.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.system.biz.convert.oauth2; - -import cn.iocoder.mall.system.biz.bo.ouath2.OAuth2AuthenticateBO; -import cn.iocoder.mall.system.biz.dataobject.oauth2.OAuth2AccessTokenDO; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface OAuth2Convert { - - OAuth2Convert INSTANCE = Mappers.getMapper(OAuth2Convert.class); - - @Mapping(source = "id", target = "accessToken") - OAuth2AuthenticateBO convert(OAuth2AccessTokenDO bean); - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/systemlog/SystemLogConvert.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/systemlog/SystemLogConvert.java deleted file mode 100644 index 6c6aa8bb5..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/systemlog/SystemLogConvert.java +++ /dev/null @@ -1,27 +0,0 @@ -package cn.iocoder.mall.system.biz.convert.systemlog; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.systemlog.AccessLogBO; -import cn.iocoder.mall.system.biz.dataobject.systemlog.AccessLogDO; -import cn.iocoder.mall.system.biz.dataobject.systemlog.ExceptionLogDO; -import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO; -import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO; -import com.baomidou.mybatisplus.core.metadata.IPage; -import org.mapstruct.Mapper; -import org.mapstruct.Mapping; -import org.mapstruct.factory.Mappers; - -@Mapper -public interface SystemLogConvert { - - SystemLogConvert INSTANCE = Mappers.getMapper(SystemLogConvert.class); - - AccessLogDO convert(AccessLogAddDTO bean); - - ExceptionLogDO convert(ExceptionLogAddDTO bean); - - @Mapping(source = "records", target = "list") - PageResult convertPage(IPage page); - - AccessLogBO convert(AccessLogDO bean); -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/system/AccessLogMapper.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/system/AccessLogMapper.java deleted file mode 100644 index 1b627e6d8..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dao/system/AccessLogMapper.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.mall.system.biz.dao.system; - -import cn.iocoder.mall.mybatis.query.QueryWrapperX; -import cn.iocoder.mall.system.biz.dataobject.systemlog.AccessLogDO; -import cn.iocoder.mall.system.biz.dto.system.AccessLogPageDTO; -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.stereotype.Repository; - -/** - * 访问日志 - * @author:mac - * @descriptio - * @create: 2020-5-12 20:43:00 - */ -@Repository -public interface AccessLogMapper extends BaseMapper { - - default IPage selectPage(AccessLogPageDTO accessLogPageDTO) { - return selectPage(new Page<>(accessLogPageDTO.getPageNo(), accessLogPageDTO.getPageSize()), - new QueryWrapperX().eqIfPresent("account_id", accessLogPageDTO.getAccountId())); - } - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/account/AccountService.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/account/AccountService.java deleted file mode 100644 index 75a18d00b..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/account/AccountService.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.mall.system.biz.service.account; - -import cn.iocoder.mall.system.biz.bo.account.AccountBO; -import cn.iocoder.mall.system.biz.dto.account.AccountCreateDTO; - -/** - * 账号模块 - Service 接口 - */ -public interface AccountService { - - AccountBO getByUsername(String username); - - AccountBO getByMobile(String mobile); - - boolean matchPassword(String rawPassword, String encodedPassword); - - AccountBO create(AccountCreateDTO createDTO); - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/account/AccountServiceImpl.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/account/AccountServiceImpl.java deleted file mode 100644 index 6578ab741..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/account/AccountServiceImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -package cn.iocoder.mall.system.biz.service.account; - -import cn.iocoder.common.framework.enums.CommonStatusEnum; -import cn.iocoder.mall.system.biz.bo.account.AccountBO; -import cn.iocoder.mall.system.biz.convert.account.AccountConvert; -import cn.iocoder.mall.system.biz.dao.account.AccountMapper; -import cn.iocoder.mall.system.biz.dataobject.account.AccountDO; -import cn.iocoder.mall.system.biz.dto.account.AccountCreateDTO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.Objects; - -@Service -public class AccountServiceImpl implements AccountService { - - @Autowired - private AccountMapper accountMapper; - - @Override - public AccountBO getByUsername(String username) { - AccountDO accountDO = accountMapper.selectByUsername(username); - return AccountConvert.INSTANCE.convert(accountDO); - } - - @Override - public AccountBO getByMobile(String mobile) { - AccountDO accountDO = accountMapper.selectByMobile(mobile); - return AccountConvert.INSTANCE.convert(accountDO); - } - - @Override - public boolean matchPassword(String rawPassword, String encodedPassword) { - return Objects.equals(rawPassword, encodedPassword); - } - - @Override - public AccountBO create(AccountCreateDTO createDTO) { - // 插入 - AccountDO accountDO = AccountConvert.INSTANCE.convert(createDTO); - accountDO.setStatus(CommonStatusEnum.ENABLE.getValue()); - accountDO.setCreateTime(new Date()); - accountMapper.insert(accountDO); - // 转换返回 - return AccountConvert.INSTANCE.convert(accountDO); - } - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/admin/AdminService.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/admin/AdminService.java deleted file mode 100644 index 04023af38..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/admin/AdminService.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.mall.system.biz.service.admin; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.admin.AdminBO; -import cn.iocoder.mall.system.biz.dto.admin.AdminPageDTO; - -/** - * 管理员模块 - Service 接口 - */ -public interface AdminService { - - /** - * 根据编号获得管理员信息 - * - * @param id 编号 - * @return 管理员 - */ - AdminBO getAdmin(Integer id); - - /** - * 获得账号编号获得管理员信息 - * - * @param accountId 账号编号 - * @return 管理员 - */ - AdminBO getAdminByAccountId(Integer accountId); - - PageResult getAdminPage(AdminPageDTO pageDTO); - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/admin/AdminServiceImpl.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/admin/AdminServiceImpl.java deleted file mode 100644 index 8416ae3f2..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/admin/AdminServiceImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.mall.system.biz.service.admin; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.admin.AdminBO; -import cn.iocoder.mall.system.biz.convert.admin.AdminConvert; -import cn.iocoder.mall.system.biz.dao.admin.AdminMapper; -import cn.iocoder.mall.system.biz.dto.admin.AdminPageDTO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class AdminServiceImpl implements AdminService { - - @Override - public PageResult getAdminPage(AdminPageDTO pageDTO) { - return AdminConvert.INSTANCE.convertPage(adminMapper.selectPage(pageDTO)); - } - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/systemlog/SystemLogService.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/systemlog/SystemLogService.java deleted file mode 100644 index 887d590ea..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/systemlog/SystemLogService.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.mall.system.biz.service.systemlog; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.systemlog.AccessLogBO; -import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO; -import cn.iocoder.mall.system.biz.dto.system.AccessLogPageDTO; -import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO; - -public interface SystemLogService { - - void addAccessLog(AccessLogAddDTO accessLogAddDTO); - - void addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO); - - PageResult getAccessLogPage(AccessLogPageDTO accessLogPageDTO); - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/systemlog/SystemLogServiceImpl.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/systemlog/SystemLogServiceImpl.java deleted file mode 100644 index 769f4e5c2..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/service/systemlog/SystemLogServiceImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package cn.iocoder.mall.system.biz.service.systemlog; - -import cn.iocoder.common.framework.vo.PageResult; -import cn.iocoder.mall.system.biz.bo.systemlog.AccessLogBO; -import cn.iocoder.mall.system.biz.convert.systemlog.SystemLogConvert; -import cn.iocoder.mall.system.biz.dao.system.AccessLogMapper; -import cn.iocoder.mall.system.biz.dao.system.ExceptionLogMapper; -import cn.iocoder.mall.system.biz.dataobject.systemlog.AccessLogDO; -import cn.iocoder.mall.system.biz.dataobject.systemlog.ExceptionLogDO; -import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO; -import cn.iocoder.mall.system.biz.dto.system.AccessLogPageDTO; -import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.Date; - -@Service -public class SystemLogServiceImpl implements SystemLogService { - - @Autowired - private AccessLogMapper accessLogMapper; - @Autowired - private ExceptionLogMapper exceptionLogMapper; - - @Override - public void addAccessLog(AccessLogAddDTO accessLogAddDTO) { - AccessLogDO logDO = SystemLogConvert.INSTANCE.convert(accessLogAddDTO); - if (logDO.getAccountId() == null) { - logDO.setAccountId(AccessLogDO.ACCOUNT_ID_NULL); - } - logDO.setCreateTime(new Date()); - accessLogMapper.insert(logDO); - } - - @Override - public void addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO) { - ExceptionLogDO logDO = SystemLogConvert.INSTANCE.convert(exceptionLogAddDTO); - if (logDO.getAccountId() == null) { - logDO.setAccountId(ExceptionLogDO.ACCOUNT_ID_NULL); - } - logDO.setCreateTime(new Date()); - exceptionLogMapper.insert(logDO); - } - - - @Override - @SuppressWarnings("Duplicates") - public PageResult getAccessLogPage(AccessLogPageDTO accessLogPageDTO) { - PageResult accessLogPageBOPageResult = SystemLogConvert.INSTANCE.convertPage( - accessLogMapper.selectPage(accessLogPageDTO)); // TODO FROM 芋艿 to 2447007062:可以考虑直接 return,简洁 + IDEA 不告警; - return accessLogPageBOPageResult; - } -} diff --git a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/api/systemlog/SystemLogRPC.java b/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/api/systemlog/SystemLogRPC.java deleted file mode 100644 index 230230cb4..000000000 --- a/system/system-rpc-api/src/main/java/cn/iocoder/mall/system/rpc/api/systemlog/SystemLogRPC.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.iocoder.mall.system.rpc.api.systemlog; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.system.rpc.request.systemlog.AccessLogAddRequest; -import cn.iocoder.mall.system.rpc.request.systemlog.ExceptionLogAddRequest; - -public interface SystemLogRPC { - - CommonResult addAccessLog(AccessLogAddRequest accessLogAddRequest); - - CommonResult addExceptionLog(ExceptionLogAddRequest exceptionLogAddRequest); - -} diff --git a/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/rpc/systemlog/SystemLogRPCImpl.java b/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/rpc/systemlog/SystemLogRPCImpl.java deleted file mode 100644 index c86617232..000000000 --- a/system/system-rpc/src/main/java/cn/iocoder/mall/system/rpc/rpc/systemlog/SystemLogRPCImpl.java +++ /dev/null @@ -1,34 +0,0 @@ -package cn.iocoder.mall.system.rpc.rpc.systemlog; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.system.biz.dto.system.AccessLogAddDTO; -import cn.iocoder.mall.system.biz.dto.system.ExceptionLogAddDTO; -import cn.iocoder.mall.system.biz.service.systemlog.SystemLogService; -import cn.iocoder.mall.system.rpc.api.systemlog.SystemLogRPC; -import cn.iocoder.mall.system.rpc.convert.systemlog.SystemLogConvert; -import cn.iocoder.mall.system.rpc.request.systemlog.AccessLogAddRequest; -import cn.iocoder.mall.system.rpc.request.systemlog.ExceptionLogAddRequest; -import org.apache.dubbo.config.annotation.Service; -import org.springframework.beans.factory.annotation.Autowired; - -@Service(version = "${dubbo.provider.SystemLogRPC.version}", validation = "true") -public class SystemLogRPCImpl implements SystemLogRPC { - - @Autowired - private SystemLogService systemLogService; - - @Override - public CommonResult addAccessLog(AccessLogAddRequest accessLogAddRequest) { - AccessLogAddDTO accessLogAddDTO = SystemLogConvert.INSTANCE.convert(accessLogAddRequest); - systemLogService.addAccessLog(accessLogAddDTO); - return CommonResult.success(true); - } - - @Override - public CommonResult addExceptionLog(ExceptionLogAddRequest exceptionLogAddRequest) { - ExceptionLogAddDTO exceptionLogAddDTO = SystemLogConvert.INSTANCE.convert(exceptionLogAddRequest); - systemLogService.addExceptionLog(exceptionLogAddDTO); - return CommonResult.success(true); - } - -}