diff --git a/common/common-framework/src/main/java/cn/iocoder/common/framework/util/ServiceExceptionUtil.java b/common/common-framework/src/main/java/cn/iocoder/common/framework/util/ServiceExceptionUtil.java index 71beedce4..d3b8642d6 100644 --- a/common/common-framework/src/main/java/cn/iocoder/common/framework/util/ServiceExceptionUtil.java +++ b/common/common-framework/src/main/java/cn/iocoder/common/framework/util/ServiceExceptionUtil.java @@ -33,8 +33,11 @@ public class ServiceExceptionUtil { public interface Enumerable { int getCode(); + String getMessage(); + int getGroup(); + } /** 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 b050734dd..29d777b75 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 @@ -48,7 +48,7 @@ public class CommonWebAutoConfiguration implements WebMvcConfigurer { // ========== 拦截器相关 ========== @Bean - @ConditionalOnClass(name = {"cn.iocoder.mall.systemservice.rpc.systemlog.SystemLogRPC", "org.apache.dubbo.config.annotation.Reference"}) + @ConditionalOnClass(name = {"cn.iocoder.mall.systemservice.rpc.systemlog.SystemExceptionLogRpc", "org.apache.dubbo.config.annotation.Reference"}) @ConditionalOnMissingBean(AccessLogInterceptor.class) public AccessLogInterceptor accessLogInterceptor() { return new AccessLogInterceptor(); 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 e30b5c04a..61c13549f 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.systemservice.rpc.systemlog.SystemLogRPC; -import cn.iocoder.mall.systemservice.rpc.systemlog.dto.ExceptionLogAddDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.SystemExceptionLogRpc; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO; import cn.iocoder.mall.web.core.util.CommonWebUtil; import com.alibaba.fastjson.JSON; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -44,8 +44,8 @@ public class GlobalExceptionHandler { private String applicationName; // TODO 目前存在一个问题,如果未引入 system-rpc-api 依赖,GlobalExceptionHandler 会报类不存在。未来封装出 Repository 解决该问题 - @Reference(validation = "true", version = "${dubbo.consumer.SystemLogRPC.version}") - private SystemLogRPC systemLogRPC; + @Reference(validation = "true", version = "${dubbo.consumer.SystemExceptionLogRpc.version}") + private SystemExceptionLogRpc systemExceptionLogRpc; // 逻辑异常 @ExceptionHandler(value = ServiceException.class) @@ -76,7 +76,7 @@ public class GlobalExceptionHandler { public CommonResult exceptionHandler(HttpServletRequest req, Exception e) { logger.error("[exceptionHandler]", e); // 插入异常日志 - ExceptionLogAddDTO exceptionLog = new ExceptionLogAddDTO(); + SystemExceptionLogCreateDTO exceptionLog = new SystemExceptionLogCreateDTO(); try { // 增加异常计数 metrics TODO 暂时去掉 // EXCEPTION_COUNTER.increment(); @@ -91,7 +91,7 @@ public class GlobalExceptionHandler { return CommonResult.error(SysErrorCodeEnum.SYS_ERROR.getCode(), SysErrorCodeEnum.SYS_ERROR.getMessage()); } - private void initExceptionLog(ExceptionLogAddDTO exceptionLog, HttpServletRequest request, Exception e) { + private void initExceptionLog(SystemExceptionLogCreateDTO exceptionLog, HttpServletRequest request, Exception e) { // 设置账号编号 exceptionLog.setUserId(CommonWebUtil.getUserId(request)); exceptionLog.setUserType(CommonWebUtil.getUserType(request)); @@ -119,9 +119,9 @@ public class GlobalExceptionHandler { } @Async - public void addExceptionLog(ExceptionLogAddDTO exceptionLog) { + public void addExceptionLog(SystemExceptionLogCreateDTO exceptionLog) { try { - systemLogRPC.addExceptionLog(exceptionLog); + systemExceptionLogRpc.createSystemExceptionLog(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 0a7632cb0..d3ec9fb59 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.systemservice.rpc.systemlog.SystemLogRPC; -import cn.iocoder.mall.systemservice.rpc.systemlog.dto.AccessLogAddDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.SystemAccessLogRpc; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO; import cn.iocoder.mall.web.core.util.CommonWebUtil; import com.alibaba.fastjson.JSON; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -26,8 +26,8 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { private Logger logger = LoggerFactory.getLogger(getClass()); - @Reference(validation = "false", version = "${dubbo.consumer.SystemLogRPC.version}") - private SystemLogRPC systemLogRPC; + @Reference(validation = "false", version = "${dubbo.consumer.SystemAccessLogRpc.version}") + private SystemAccessLogRpc systemAccessLogRpc; @Value("${spring.application.name}") private String applicationName; @@ -41,7 +41,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { - AccessLogAddDTO accessLog = new AccessLogAddDTO(); + SystemAccessLogCreateDTO accessLog = new SystemAccessLogCreateDTO(); try { // 初始化 accessLog initAccessLog(accessLog, request); @@ -53,7 +53,7 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { } } - private void initAccessLog(AccessLogAddDTO accessLog, HttpServletRequest request) { + private void initAccessLog(SystemAccessLogCreateDTO accessLog, HttpServletRequest request) { // 设置账号编号 accessLog.setUserId(CommonWebUtil.getUserId(request)); accessLog.setUserType(CommonWebUtil.getUserType(request)); @@ -78,9 +78,9 @@ public class AccessLogInterceptor extends HandlerInterceptorAdapter { } @Async // 异步入库 - public void addAccessLog(AccessLogAddDTO accessLog) { + public void addAccessLog(SystemAccessLogCreateDTO accessLog) { try { - systemLogRPC.addAccessLog(accessLog); + systemAccessLogRpc.createSystemAccessLog(accessLog); } catch (Throwable th) { logger.error("[addAccessLog][插入访问日志({}) 发生异常({})", JSON.toJSONString(accessLog), ExceptionUtils.getRootCauseMessage(th)); } diff --git a/docs/sql/mall_system_data.sql b/docs/sql/mall_system_data.sql new file mode 100644 index 000000000..e69de29bb diff --git a/docs/sql/mall_system_schema.sql b/docs/sql/mall_system_schema.sql new file mode 100644 index 000000000..66b206f29 --- /dev/null +++ b/docs/sql/mall_system_schema.sql @@ -0,0 +1,227 @@ +/* + Navicat Premium Data Transfer + + Source Server : onemall-huawei + Source Server Type : MySQL + Source Server Version : 50730 + Source Host : 400-infra.server.iocoder.cn:3306 + Source Schema : mall_system + + Target Server Type : MySQL + Target Server Version : 50730 + File Encoding : 65001 + + Date: 15/07/2020 20:59:37 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for admin +-- ---------------------------- +DROP TABLE IF EXISTS `admin`; +CREATE TABLE `admin` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '管理员编号', + `name` varchar(10) NOT NULL COMMENT '真实名字', + `avatar` varchar(255) DEFAULT NULL COMMENT '头像', + `department_id` int(11) DEFAULT NULL COMMENT '部门id', + `status` tinyint(4) NOT NULL COMMENT '在职状态', + `username` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '登陆账号', + `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '加密后的密码', + `password_salt` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '密码的盐', + `create_admin_id` int(11) NOT NULL COMMENT '创建管理员编号', + `create_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建 IP', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + PRIMARY KEY (`id`) USING BTREE, + UNIQUE KEY `uk_username` (`username`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=34 DEFAULT CHARSET=utf8mb4 COMMENT='管理员'; + +-- ---------------------------- +-- Table structure for admin_department +-- ---------------------------- +DROP TABLE IF EXISTS `admin_department`; +CREATE TABLE `admin_department` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '部门编号', + `name` varchar(100) COLLATE utf8mb4_bin NOT NULL COMMENT '部门名称', + `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序字段', + `pid` int(11) NOT NULL DEFAULT '0' COMMENT '父级部门编号', + `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '删除标记', + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='部门'; + +-- ---------------------------- +-- Table structure for oauth2_access_token +-- ---------------------------- +DROP TABLE IF EXISTS `oauth2_access_token`; +CREATE TABLE `oauth2_access_token` ( + `id` varchar(32) NOT NULL COMMENT '访问令牌', + `user_id` int(11) NOT NULL COMMENT '用户编号', + `user_type` tinyint(4) NOT NULL COMMENT '用户类型', + `refresh_token` varchar(32) NOT NULL COMMENT '刷新令牌', + `expires_time` datetime NOT NULL COMMENT '过期时间', + `create_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建 IP', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_userId` (`user_id`) USING BTREE, + KEY `idx_refreshToken` (`refresh_token`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='访问令牌'; + +-- ---------------------------- +-- Table structure for oauth2_refresh_token +-- ---------------------------- +DROP TABLE IF EXISTS `oauth2_refresh_token`; +CREATE TABLE `oauth2_refresh_token` ( + `id` varchar(32) NOT NULL COMMENT '编号,刷新令牌', + `user_id` int(11) NOT NULL COMMENT '用户编号', + `user_type` tinyint(4) NOT NULL COMMENT '用户类型', + `expires_time` datetime NOT NULL COMMENT '过期时间', + `create_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL COMMENT '创建 IP', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + PRIMARY KEY (`id`) USING BTREE, + KEY `idx_userId` (`user_id`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='刷新令牌'; + +-- ---------------------------- +-- Table structure for permission_admin_role +-- ---------------------------- +DROP TABLE IF EXISTS `permission_admin_role`; +CREATE TABLE `permission_admin_role` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号', + `admin_id` int(11) NOT NULL COMMENT '管理员编号', + `role_id` int(11) NOT NULL COMMENT '角色编号', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) DEFAULT b'0' COMMENT '是否删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=40 DEFAULT CHARSET=utf8mb4 COMMENT='管理员角色'; + +-- ---------------------------- +-- Table structure for permission_resource +-- ---------------------------- +DROP TABLE IF EXISTS `permission_resource`; +CREATE TABLE `permission_resource` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '资源编号', + `name` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单名', + `permission` varchar(255) DEFAULT NULL COMMENT '权限标识', + `type` int(11) NOT NULL COMMENT '资源类型', + `sort` int(11) NOT NULL COMMENT '排序', + `pid` int(11) NOT NULL DEFAULT '0' COMMENT '父级资源编号(外键:{@link ResourceDO#id})', + `route` varchar(50) DEFAULT NULL COMMENT '前端路由', + `icon` varchar(50) DEFAULT NULL COMMENT '菜单图标', + `view` varchar(50) DEFAULT NULL COMMENT '前端界面', + `create_admin_id` int(11) NOT NULL COMMENT '创建管理员编号', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '添加时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8mb4 COMMENT='资源'; + +-- ---------------------------- +-- Table structure for permission_role +-- ---------------------------- +DROP TABLE IF EXISTS `permission_role`; +CREATE TABLE `permission_role` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '角色编号', + `name` varchar(50) NOT NULL DEFAULT '' COMMENT '角色名', + `code` varchar(50) DEFAULT NULL COMMENT '角色编码', + `type` tinyint(4) NOT NULL COMMENT '角色类型', + `create_admin_id` int(11) NOT NULL COMMENT '创建管理员编号', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COMMENT='角色'; + +-- ---------------------------- +-- Table structure for permission_role_resource +-- ---------------------------- +DROP TABLE IF EXISTS `permission_role_resource`; +CREATE TABLE `permission_role_resource` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号', + `role_id` int(11) NOT NULL DEFAULT '-1' COMMENT '角色编号(外键:{@link RoleDO}', + `resource_id` int(11) NOT NULL DEFAULT '-1' COMMENT '资源编号', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=860 DEFAULT CHARSET=utf8mb4 COMMENT='角色资源'; + +-- ---------------------------- +-- Table structure for system_access_log +-- ---------------------------- +DROP TABLE IF EXISTS `system_access_log`; +CREATE TABLE `system_access_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号', + `user_id` int(11) DEFAULT NULL COMMENT '用户编号', + `user_type` tinyint(4) DEFAULT NULL COMMENT '用户类型', + `trace_id` varchar(64) DEFAULT NULL COMMENT '链路追踪编号', + `application_name` varchar(50) NOT NULL COMMENT '应用名', + `uri` varchar(4096) NOT NULL DEFAULT '' COMMENT '访问地址', + `query_string` varchar(4096) NOT NULL DEFAULT '' COMMENT '参数', + `method` varchar(50) NOT NULL DEFAULT '' COMMENT 'http 方法', + `user_agent` varchar(1024) NOT NULL DEFAULT '' COMMENT 'userAgent', + `ip` varchar(50) NOT NULL DEFAULT '' COMMENT 'ip', + `start_time` datetime NOT NULL COMMENT '请求时间', + `response_time` int(11) NOT NULL COMMENT '响应时长 -- 毫秒级', + `error_code` int(11) NOT NULL COMMENT '错误码', + `error_message` varchar(512) DEFAULT NULL COMMENT '错误提示', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=87141 DEFAULT CHARSET=utf8mb4 COMMENT='系统访问日志'; + +-- ---------------------------- +-- Table structure for system_data_dict +-- ---------------------------- +DROP TABLE IF EXISTS `system_data_dict`; +CREATE TABLE `system_data_dict` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号', + `enum_value` varchar(50) NOT NULL DEFAULT '' COMMENT '大类枚举值', + `value` varchar(50) NOT NULL DEFAULT '' COMMENT '小类数值', + `display_name` varchar(50) NOT NULL DEFAULT '' COMMENT '展示名', + `sort` int(11) NOT NULL DEFAULT '-1' COMMENT '排序值', + `memo` varchar(50) DEFAULT '' COMMENT '备注', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8mb4 COMMENT='数据字典'; + +-- ---------------------------- +-- Table structure for system_exception_log +-- ---------------------------- +DROP TABLE IF EXISTS `system_exception_log`; +CREATE TABLE `system_exception_log` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号', + `user_id` int(11) DEFAULT NULL COMMENT '用户编号', + `user_type` tinyint(4) DEFAULT NULL COMMENT '用户类型', + `trace_id` varchar(64) NOT NULL COMMENT '链路追踪编号\n *\n * 一般来说,通过链路追踪编号,可以将访问日志,错误日志,链路追踪日志,logger 打印日志等,结合在一起,从而进行排错。', + `application_name` varchar(50) NOT NULL COMMENT '应用名\n *\n * 目前读取 spring.application.name', + `uri` varchar(4096) NOT NULL COMMENT '访问地址', + `query_string` varchar(4096) NOT NULL COMMENT '参数', + `method` varchar(50) NOT NULL COMMENT 'http 方法', + `user_agent` varchar(1024) NOT NULL COMMENT 'userAgent', + `ip` varchar(50) NOT NULL COMMENT 'ip', + `exception_time` datetime NOT NULL COMMENT '异常发生时间', + `exception_name` varchar(128) NOT NULL DEFAULT '' COMMENT '异常名\n *\n * {@link Throwable#getClass()} 的类全名', + `exception_message` text NOT NULL COMMENT '异常导致的消息\n *\n * {@link cn.iocoder.common.framework.util.ExceptionUtil#getMessage(Throwable)}', + `exception_root_cause_message` text NOT NULL COMMENT '异常导致的根消息\n *\n * {@link cn.iocoder.common.framework.util.ExceptionUtil#getRootCauseMessage(Throwable)}', + `exception_stack_trace` text NOT NULL COMMENT '异常的栈轨迹\n *\n * {@link cn.iocoder.common.framework.util.ExceptionUtil#getServiceException(Exception)}', + `exception_class_name` varchar(512) NOT NULL COMMENT '异常发生的类全名\n *\n * {@link StackTraceElement#getClassName()}', + `exception_file_name` varchar(512) NOT NULL COMMENT '异常发生的类文件\n *\n * {@link StackTraceElement#getFileName()}', + `exception_method_name` varchar(512) NOT NULL COMMENT '异常发生的方法名\n *\n * {@link StackTraceElement#getMethodName()}', + `exception_line_number` int(11) NOT NULL COMMENT '异常发生的方法所在行\n *\n * {@link StackTraceElement#getLineNumber()}', + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后更新时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE=InnoDB AUTO_INCREMENT=1012 DEFAULT CHARSET=utf8mb4 COMMENT='系统异常日志'; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/docs/sql/mall_admin.sql b/docs/sql/old/mall_admin.sql similarity index 100% rename from docs/sql/mall_admin.sql rename to docs/sql/old/mall_admin.sql diff --git a/docs/sql/mall_order.sql b/docs/sql/old/mall_order.sql similarity index 100% rename from docs/sql/mall_order.sql rename to docs/sql/old/mall_order.sql diff --git a/docs/sql/mall_pay.sql b/docs/sql/old/mall_pay.sql similarity index 100% rename from docs/sql/mall_pay.sql rename to docs/sql/old/mall_pay.sql diff --git a/docs/sql/mall_product.sql b/docs/sql/old/mall_product.sql similarity index 100% rename from docs/sql/mall_product.sql rename to docs/sql/old/mall_product.sql diff --git a/docs/sql/mall_promotion.sql b/docs/sql/old/mall_promotion.sql similarity index 100% rename from docs/sql/mall_promotion.sql rename to docs/sql/old/mall_promotion.sql diff --git a/docs/sql/mall_user.sql b/docs/sql/old/mall_user.sql similarity index 100% rename from docs/sql/mall_user.sql rename to docs/sql/old/mall_user.sql diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/datadict/DataDictController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/datadict/DataDictController.java index f0610b992..87328d264 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/datadict/DataDictController.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/datadict/DataDictController.java @@ -6,6 +6,7 @@ import cn.iocoder.mall.managementweb.controller.datadict.dto.DataDictUpdateDTO; import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictSimpleVO; import cn.iocoder.mall.managementweb.controller.datadict.vo.DataDictVO; import cn.iocoder.mall.managementweb.manager.datadict.DataDictManager; +import cn.iocoder.security.annotations.RequiresPermissions; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; @@ -22,7 +23,7 @@ import static cn.iocoder.common.framework.vo.CommonResult.success; * 数据字典 Controller */ @RestController -@RequestMapping("/data_dict") +@RequestMapping("/data-dict") @Api(tags = "数据字典") @Validated public class DataDictController { @@ -32,12 +33,14 @@ public class DataDictController { @PostMapping("/create") @ApiOperation("创建数据字典") + @RequiresPermissions("system:data-dict:create") public CommonResult createDataDict(@Valid DataDictCreateDTO createDTO) { return success(dataDictManager.createDataDict(createDTO)); } @PostMapping("/update") @ApiOperation("更新数据字典") + @RequiresPermissions("system:data-dict:update") public CommonResult updateDataDict(@Valid DataDictUpdateDTO updateDTO) { dataDictManager.updateDataDict(updateDTO); return success(true); @@ -46,6 +49,7 @@ public class DataDictController { @PostMapping("/delete") @ApiOperation("删除数据字典") @ApiImplicitParam(name = "dataDictId", value = "数据字典编号", required = true) + @RequiresPermissions("system:data-dict:delete") public CommonResult deleteDataDict(@RequestParam("dataDictId") Integer dataDictId) { dataDictManager.deleteDataDict(dataDictId); return success(true); @@ -54,6 +58,7 @@ public class DataDictController { @GetMapping("/get") @ApiOperation("获得数据字典") @ApiImplicitParam(name = "dataDictId", value = "数据字典编号", required = true) + @RequiresPermissions("system:data-dict:list") public CommonResult getDataDict(@RequestParam("dataDictId") Integer dataDictId) { return success(dataDictManager.getDataDict(dataDictId)); } @@ -61,18 +66,21 @@ public class DataDictController { @GetMapping("/list") @ApiOperation("获得数据字典列表") @ApiImplicitParam(name = "dataDictIds", value = "数据字典编号列表", required = true) + @RequiresPermissions("system:data-dict:list") public CommonResult> listDataDicts(@RequestParam("dataDictIds") List dataDictIds) { return success(dataDictManager.listDataDicts(dataDictIds)); } @GetMapping("/list-all") @ApiOperation("获得全部数据字典列表") + @RequiresPermissions("system:data-dict:list") public CommonResult> listDataDicts() { return success(dataDictManager.listDataDicts()); } @GetMapping("/list-all-simple") @ApiOperation(value = "获得全部数据字典列表", notes = "一般用于管理后台缓存数据字典在本地") + // 无需添加权限认证,因为前端全局都需要 public CommonResult> listSimpleDataDicts() { return success(dataDictManager.listSimpleDataDicts()); } diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.http new file mode 100644 index 000000000..77a4884dd --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.http @@ -0,0 +1,7 @@ +### /system-access-log/page 成功 +GET {{baseUrl}}/system-access-log/page?pageNo=1&pageSize=10 +Content-Type: application/x-www-form-urlencoded +Authorization: Bearer {{accessToken}} + +### + diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.java new file mode 100644 index 000000000..6c84d6ddf --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/SystemAccessLogController.java @@ -0,0 +1,36 @@ +package cn.iocoder.mall.managementweb.controller.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPageDTO; +import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO; +import cn.iocoder.mall.managementweb.manager.systemlog.SystemAccessLogManager; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** +* 系统访问日志 Controller +*/ +@RestController +@RequestMapping("/system-access-log") +@Api(tags = "系统访问日志") +@Validated +public class SystemAccessLogController { + + @Autowired + private SystemAccessLogManager systemAccessLogManager; + + @GetMapping("/page") + @ApiOperation("获得系统访问日志分页") + public CommonResult> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) { + return success(systemAccessLogManager.pageSystemAccessLog(pageDTO)); + } + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemAccessLogPageDTO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemAccessLogPageDTO.java new file mode 100644 index 000000000..ab2d4c2d3 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/dto/SystemAccessLogPageDTO.java @@ -0,0 +1,19 @@ +package cn.iocoder.mall.managementweb.controller.systemlog.dto; + +import cn.iocoder.common.framework.vo.PageParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@ApiModel("系统访问日志分页 DTO") +@Data +public class SystemAccessLogPageDTO extends PageParam { + + @ApiModelProperty(value = "用户编号") + private Integer userId; + @ApiModelProperty(value = "用户类型") + private Integer userType; + @ApiModelProperty(value = "应用名", required = true) + private String applicationName; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemAccessLogVO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemAccessLogVO.java new file mode 100644 index 000000000..cd998a268 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/systemlog/vo/SystemAccessLogVO.java @@ -0,0 +1,40 @@ +package cn.iocoder.mall.managementweb.controller.systemlog.vo; + +import lombok.*; +import io.swagger.annotations.*; +import java.util.*; + +@ApiModel("系统访问日志 VO") +@Data +public class SystemAccessLogVO { + + @ApiModelProperty(value = "编号", required = true) + private Integer id; + @ApiModelProperty(value = "用户编号", example = "1024") + private Integer userId; + @ApiModelProperty(value = "用户类型", example = "1") + private Integer userType; + @ApiModelProperty(value = "链路追踪编号", example = "89aca178-a370-411c-ae02-3f0d672be4ab") + private String traceId; + @ApiModelProperty(value = "应用名", required = true, example = "user-shop-application") + private String applicationName; + @ApiModelProperty(value = "访问地址", required = true, example = "/management-api/system-access-log/page") + private String uri; + @ApiModelProperty(value = "参数", required = true, example = "pageNo=1&pageSize=10") + private String queryString; + @ApiModelProperty(value = "http 方法", required = true, example = "GET") + private String method; + @ApiModelProperty(value = "userAgent", required = true, example = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0") + private String userAgent; + @ApiModelProperty(value = "ip", required = true, example = "127.0.0.1") + private String ip; + @ApiModelProperty(value = "请求时间", required = true) + private Date startTime; + @ApiModelProperty(value = "响应时长 -- 毫秒级", required = true, example = "1024") + private Integer responseTime; + @ApiModelProperty(value = "错误码", required = true, example = "0") + private Integer errorCode; + @ApiModelProperty(value = "错误提示", example = "你的昵称过长~") + private String errorMessage; + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/systemlog/SystemAccessLogConvert.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/systemlog/SystemAccessLogConvert.java new file mode 100644 index 000000000..67f0659ec --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/convert/systemlog/SystemAccessLogConvert.java @@ -0,0 +1,18 @@ +package cn.iocoder.mall.managementweb.convert.systemlog; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface SystemAccessLogConvert { + + SystemAccessLogConvert INSTANCE = Mappers.getMapper(SystemAccessLogConvert.class); + + SystemAccessLogPageDTO convert(cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPageDTO bean); + + PageResult convertPage(PageResult page); + +} diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/datadict/DataDictManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/datadict/DataDictManager.java index c5555698c..aedde1fbc 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/datadict/DataDictManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/datadict/DataDictManager.java @@ -21,7 +21,7 @@ public class DataDictManager { private static final Comparator COMPARATOR_ENUM_VALUE_SORT = (o1, o2) -> { int cmp = o1.getEnumValue().compareTo(o2.getEnumValue()); - if (cmp == 0) { + if (cmp != 0) { return cmp; } return o1.getSort().compareTo(o2.getSort()); diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemAccessLogManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemAccessLogManager.java new file mode 100644 index 000000000..0528c0fbc --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/systemlog/SystemAccessLogManager.java @@ -0,0 +1,34 @@ +package cn.iocoder.mall.managementweb.manager.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.managementweb.controller.systemlog.dto.SystemAccessLogPageDTO; +import cn.iocoder.mall.managementweb.controller.systemlog.vo.SystemAccessLogVO; +import cn.iocoder.mall.managementweb.convert.systemlog.SystemAccessLogConvert; +import cn.iocoder.mall.systemservice.rpc.systemlog.SystemAccessLogRpc; +import org.apache.dubbo.config.annotation.Reference; +import org.springframework.stereotype.Service; + +/** +* 系统访问日志 Manager +*/ +@Service +public class SystemAccessLogManager { + + @Reference(version = "${dubbo.consumer.SystemAccessLogRpc.version}", validation = "false") + private SystemAccessLogRpc systemAccessLogRpc; + + /** + * 获得系统访问日志分页 + * + * @param pageDTO 系统访问日志分页查询 + * @return 系统访问日志分页结果 + */ + public PageResult pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) { + CommonResult> pageSystemAccessLogResult = + systemAccessLogRpc.pageSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(pageDTO)); + pageSystemAccessLogResult.checkError(); + return SystemAccessLogConvert.INSTANCE.convertPage(pageSystemAccessLogResult.getData()); + } + +} diff --git a/management-web-app/src/main/resources/application.yml b/management-web-app/src/main/resources/application.yml index 447829e33..6dafe1219 100644 --- a/management-web-app/src/main/resources/application.yml +++ b/management-web-app/src/main/resources/application.yml @@ -28,8 +28,6 @@ dubbo: version: 1.0.0 AdminRpc: version: 1.0.0 - SystemLogRPC: - version: 1.0.0 ResourceRpc: version: 1.0.0 RoleRpc: @@ -40,6 +38,10 @@ dubbo: version: 1.0.0 DataDictRpc: version: 1.0.0 + SystemAccessLogRpc: + version: 1.0.0 + SystemExceptionLogRpc: + version: 1.0.0 # Swagger 配置项 swagger: diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemAccessLogRpc.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemAccessLogRpc.java new file mode 100644 index 000000000..d5053e0ec --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemAccessLogRpc.java @@ -0,0 +1,30 @@ +package cn.iocoder.mall.systemservice.rpc.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO; + +/** +* 系统访问日志 Rpc 接口 +*/ +public interface SystemAccessLogRpc { + + /** + * 创建系统访问日志 + * + * @param createDTO 创建系统访问日志 DTO + * @return 系统访问日志编号 + */ + CommonResult createSystemAccessLog(SystemAccessLogCreateDTO createDTO); + + /** + * 获得系统访问日志分页 + * + * @param pageDTO 系统访问日志分页查询 + * @return 系统访问日志分页结果 + */ + CommonResult> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO); + +} diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpc.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpc.java new file mode 100644 index 000000000..8d734f9c8 --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpc.java @@ -0,0 +1,10 @@ +package cn.iocoder.mall.systemservice.rpc.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO; + +public interface SystemExceptionLogRpc { + + CommonResult createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO); + +} 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 deleted file mode 100644 index b4501c907..000000000 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPC.java +++ /dev/null @@ -1,13 +0,0 @@ -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-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/AccessLogAddDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemAccessLogCreateDTO.java similarity index 93% rename from system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/AccessLogAddDTO.java rename to system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemAccessLogCreateDTO.java index d4a7787c5..5627f638c 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/AccessLogAddDTO.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemAccessLogCreateDTO.java @@ -9,11 +9,11 @@ import java.io.Serializable; import java.util.Date; /** - * 访问日志添加 DTO + * 系统访问日志添加 DTO */ @Data @Accessors(chain = true) -public class AccessLogAddDTO implements Serializable { +public class SystemAccessLogCreateDTO implements Serializable { /** * 账号编号 diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/ExceptionLogAddDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogCreateDTO.java similarity index 95% rename from system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/ExceptionLogAddDTO.java rename to system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogCreateDTO.java index 5b39c7cb4..5a7c68eba 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/ExceptionLogAddDTO.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/dto/SystemExceptionLogCreateDTO.java @@ -9,11 +9,11 @@ import java.io.Serializable; import java.util.Date; /** - * 异常日志添加 DTO + * 系统异常日志添加 DTO */ @Data @Accessors(chain = true) -public class ExceptionLogAddDTO implements Serializable { +public class SystemExceptionLogCreateDTO implements Serializable { /** * 账号编号 diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemAccessLogPageDTO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemAccessLogPageDTO.java new file mode 100644 index 000000000..92a7dd2d0 --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemAccessLogPageDTO.java @@ -0,0 +1,29 @@ +package cn.iocoder.mall.systemservice.rpc.systemlog.vo; + +import cn.iocoder.common.framework.vo.PageParam; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** +* 系统访问日志分页 DTO +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class SystemAccessLogPageDTO extends PageParam { + + /** + * 用户编号 + */ + private Integer userId; + /** + * 用户类型 + */ + private Integer userType; + /** + * 应用名 + */ + private String applicationName; + +} diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemAccessLogVO.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemAccessLogVO.java new file mode 100644 index 000000000..d7c86c31c --- /dev/null +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/vo/SystemAccessLogVO.java @@ -0,0 +1,73 @@ +package cn.iocoder.mall.systemservice.rpc.systemlog.vo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.io.Serializable; +import java.util.Date; + +/** +* 系统访问日志 VO +*/ +@Data +@Accessors(chain = true) +public class SystemAccessLogVO implements Serializable { + + /** + * 编号 + */ + private Integer id; + /** + * 用户编号 + */ + private Integer userId; + /** + * 用户类型 + */ + private Integer userType; + /** + * 链路追踪编号 + */ + private String traceId; + /** + * 应用名 + */ + private String applicationName; + /** + * 访问地址 + */ + private String uri; + /** + * 参数 + */ + private String queryString; + /** + * http 方法 + */ + private String method; + /** + * userAgent + */ + private String userAgent; + /** + * ip + */ + private String ip; + /** + * 请求时间 + */ + private Date startTime; + /** + * 响应时长 -- 毫秒级 + */ + private Integer responseTime; + /** + * 错误码 + */ + private Integer errorCode; + /** + * 错误提示 + */ + private String errorMessage; + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemAccessLogConvert.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemAccessLogConvert.java new file mode 100644 index 000000000..014c3a00e --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemAccessLogConvert.java @@ -0,0 +1,32 @@ +package cn.iocoder.mall.systemservice.convert.systemlog; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogCreateBO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface SystemAccessLogConvert { + + SystemAccessLogConvert INSTANCE = Mappers.getMapper(SystemAccessLogConvert.class); + + SystemAccessLogDO convert(SystemAccessLogCreateBO bean); + + SystemAccessLogCreateBO convert(SystemAccessLogCreateDTO bean); + + @Mapping(source = "records", target = "list") + PageResult convertPage(IPage page); + + SystemAccessLogPageBO convert(SystemAccessLogPageDTO bean); + + PageResult convertPage(PageResult page); + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemExceptionLogConvert.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemExceptionLogConvert.java new file mode 100644 index 000000000..cb2fb491d --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemExceptionLogConvert.java @@ -0,0 +1,18 @@ +package cn.iocoder.mall.systemservice.convert.systemlog; + +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogCreateBO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface SystemExceptionLogConvert { + + SystemExceptionLogConvert INSTANCE = Mappers.getMapper(SystemExceptionLogConvert.class); + + SystemExceptionLogDO convert(SystemExceptionLogCreateBO bean); + + SystemExceptionLogCreateBO convert(SystemExceptionLogCreateDTO bean); + +} 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 deleted file mode 100644 index 3831c807a..000000000 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/convert/systemlog/SystemLogConvert.java +++ /dev/null @@ -1,34 +0,0 @@ -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-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/datadict/DataDictDO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/datadict/DataDictDO.java index 61475c347..1ed7eca63 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/datadict/DataDictDO.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/datadict/DataDictDO.java @@ -14,7 +14,7 @@ import lombok.experimental.Accessors; * value:1 男 * value:2 女 */ -@TableName("data_dict") +@TableName("system_data_dict") @Data @Accessors(chain = true) public class DataDictDO extends DeletableDO { diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/AccessLogDO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemAccessLogDO.java similarity index 85% rename from system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/AccessLogDO.java rename to system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemAccessLogDO.java index 02204023f..7775d3c34 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/AccessLogDO.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemAccessLogDO.java @@ -11,13 +11,17 @@ import lombok.experimental.Accessors; import java.util.Date; /** - * 访问日志 DO + * 系统访问日志 DO + * + * 记录用户、管理员对 API 接口的调用 + * + * TODO 优化点:考虑到架构简单,暂时记录到 MySQL。因为访问日志容易比较大,所以建议未来存储到 ES 中,同时能够提供更丰富的检索能力 */ @TableName("system_access_log") @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) -public class AccessLogDO extends BaseDO { +public class SystemAccessLogDO extends BaseDO { /** * 编号 diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/ExceptionLogDO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemExceptionLogDO.java similarity index 97% rename from system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/ExceptionLogDO.java rename to system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemExceptionLogDO.java index 351ff5122..daebe6e95 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/ExceptionLogDO.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/systemlog/SystemExceptionLogDO.java @@ -10,13 +10,13 @@ import lombok.experimental.Accessors; import java.util.Date; /** - * 异常日志 DO + * 系统异常日志 DO */ @TableName("system_exception_log") @Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) -public class ExceptionLogDO extends BaseDO { +public class SystemExceptionLogDO extends BaseDO { /** * 编号 diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/datadict/DataDictMapper.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/datadict/DataDictMapper.java index 9ef3b8859..36949dd36 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/datadict/DataDictMapper.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/datadict/DataDictMapper.java @@ -13,16 +13,16 @@ public interface DataDictMapper extends BaseMapper { default DataDictDO selectByEnumValueAndValue(String enumValue, String value) { return selectOne(new QueryWrapper() - .eq("enumValue", enumValue).eq("value", value)); + .eq("enum_value", enumValue).eq("value", value)); } default List selectByEnumValueAndValues(String enumValue, Collection values) { return selectList(new QueryWrapper() - .eq("enumValue", enumValue).in("value", values)); + .eq("enum_value", enumValue).in("value", values)); } default List selectByEnumValue(String enumValue) { - return selectList(new QueryWrapper().eq("enumValue", enumValue)); + return selectList(new QueryWrapper().eq("enum_value", enumValue)); } } 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 deleted file mode 100644 index 43e3bbb2a..000000000 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/AccessLogMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -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-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemAccessLogMapper.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemAccessLogMapper.java new file mode 100644 index 000000000..3b73048e9 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemAccessLogMapper.java @@ -0,0 +1,26 @@ +package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog; + +import cn.iocoder.mall.mybatis.query.QueryWrapperX; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO; +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; + +/** + * 系统访问日志 Mapper + */ +@Repository +public interface SystemAccessLogMapper extends BaseMapper { + + default IPage selectPage(SystemAccessLogPageBO pageBO) { + return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()), + new QueryWrapperX() + .eqIfPresent("user_id", pageBO.getUserId()) + .eqIfPresent("user_type", pageBO.getUserType()) + .eqIfPresent("application_name", pageBO.getApplicationName()) + .orderByDesc("start_time")); + } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/ExceptionLogMapper.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemExceptionLogMapper.java similarity index 69% rename from system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/ExceptionLogMapper.java rename to system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemExceptionLogMapper.java index 7ad85c9d5..6217139c8 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/ExceptionLogMapper.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/mapper/systemlog/SystemExceptionLogMapper.java @@ -1,10 +1,10 @@ package cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog; -import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.ExceptionLogDO; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; @Repository -public interface ExceptionLogMapper extends BaseMapper { +public interface SystemExceptionLogMapper extends BaseMapper { } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemAccessLogManager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemAccessLogManager.java new file mode 100644 index 000000000..690db17bd --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemAccessLogManager.java @@ -0,0 +1,42 @@ +package cn.iocoder.mall.systemservice.manager.systemlog; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.systemservice.convert.systemlog.SystemAccessLogConvert; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO; +import cn.iocoder.mall.systemservice.service.systemlog.SystemAccessLogService; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 系统访问日志 Manager + */ +@Service +public class SystemAccessLogManager { + + @Autowired + private SystemAccessLogService systemAccessLogService; + + /** + * 创建系统访问日志 + * + * @param createDTO 创建系统访问日志 DTO + */ + public void createSystemAccessLog(SystemAccessLogCreateDTO createDTO) { + systemAccessLogService.createSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(createDTO)); + } + + /** + * 获得系统访问日志分页 + * + * @param pageDTO 系统访问日志分页查询 + * @return 系统访问日志分页结果 + */ + public PageResult pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) { + PageResult pageResultBO = systemAccessLogService.pageSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(pageDTO)); + return SystemAccessLogConvert.INSTANCE.convertPage(pageResultBO); + } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemExceptionLogManager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemExceptionLogManager.java new file mode 100644 index 000000000..cca392913 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemExceptionLogManager.java @@ -0,0 +1,22 @@ +package cn.iocoder.mall.systemservice.manager.systemlog; + +import cn.iocoder.mall.systemservice.convert.systemlog.SystemExceptionLogConvert; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO; +import cn.iocoder.mall.systemservice.service.systemlog.SystemExceptionLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 系统异常日志 Manager + */ +@Service +public class SystemExceptionLogManager { + + @Autowired + private SystemExceptionLogService systemLogService; + + public void createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO) { + systemLogService.createSystemExceptionLog(SystemExceptionLogConvert.INSTANCE.convert(createDTO)); + } + +} 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 deleted file mode 100644 index 84d28d8bf..000000000 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/systemlog/SystemLogManager.java +++ /dev/null @@ -1,24 +0,0 @@ -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/SystemAccessLogRpcImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemAccessLogRpcImpl.java new file mode 100644 index 000000000..e3be8ddd3 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemAccessLogRpcImpl.java @@ -0,0 +1,34 @@ +package cn.iocoder.mall.systemservice.rpc.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.systemservice.manager.systemlog.SystemAccessLogManager; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemAccessLogCreateDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogPageDTO; +import cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO; +import org.apache.dubbo.config.annotation.Service; +import org.springframework.beans.factory.annotation.Autowired; + +import static cn.iocoder.common.framework.vo.CommonResult.success; + +/** +* 系统访问日志 Rpc 实现类 +*/ +@Service(version = "${dubbo.provider.SystemAccessLogRpc.version}", validation = "false") +public class SystemAccessLogRpcImpl implements SystemAccessLogRpc { + + @Autowired + private SystemAccessLogManager systemAccessLogManager; + + @Override + public CommonResult createSystemAccessLog(SystemAccessLogCreateDTO createDTO) { + systemAccessLogManager.createSystemAccessLog(createDTO); + return success(true); + } + + @Override + public CommonResult> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) { + return success(systemAccessLogManager.pageSystemAccessLog(pageDTO)); + } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpcImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpcImpl.java new file mode 100644 index 000000000..4781274a9 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemExceptionLogRpcImpl.java @@ -0,0 +1,21 @@ +package cn.iocoder.mall.systemservice.rpc.systemlog; + +import cn.iocoder.common.framework.vo.CommonResult; +import cn.iocoder.mall.systemservice.manager.systemlog.SystemExceptionLogManager; +import cn.iocoder.mall.systemservice.rpc.systemlog.dto.SystemExceptionLogCreateDTO; +import org.apache.dubbo.config.annotation.Service; +import org.springframework.beans.factory.annotation.Autowired; + +@Service(version = "${dubbo.provider.SystemExceptionLogRpc.version}", validation = "false") +public class SystemExceptionLogRpcImpl implements SystemExceptionLogRpc { + + @Autowired + private SystemExceptionLogManager systemExceptionLogManager; + + @Override + public CommonResult createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO) { + systemExceptionLogManager.createSystemExceptionLog(createDTO); + return CommonResult.success(true); + } + +} 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 deleted file mode 100644 index 7c2b4f22c..000000000 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/systemlog/SystemLogRPCImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -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/systemlog/SystemAccessLogService.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemAccessLogService.java new file mode 100644 index 000000000..d32a7d4d2 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemAccessLogService.java @@ -0,0 +1,44 @@ +package cn.iocoder.mall.systemservice.service.systemlog; + +import cn.iocoder.common.framework.vo.PageResult; +import cn.iocoder.mall.systemservice.convert.systemlog.SystemAccessLogConvert; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemAccessLogDO; +import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.SystemAccessLogMapper; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogBO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogCreateBO; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemAccessLogPageBO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 系统访问日志 Service + */ +@Service +public class SystemAccessLogService { + + @Autowired + private SystemAccessLogMapper systemAccessLogMapper; + + /** + * 创建系统访问日志 + * + * @param createBO 创建系统访问日志 BO + */ + public void createSystemAccessLog(SystemAccessLogCreateBO createBO) { + SystemAccessLogDO logDO = SystemAccessLogConvert.INSTANCE.convert(createBO); + systemAccessLogMapper.insert(logDO); + } + + /** + * 获得系统访问日志分页 + * + * @param pageBO 系统访问日志分页查询 + * @return 系统访问日志分页结果 + */ + public PageResult pageSystemAccessLog(SystemAccessLogPageBO pageBO) { + IPage systemAccessLogDOPage = systemAccessLogMapper.selectPage(pageBO); + return SystemAccessLogConvert.INSTANCE.convertPage(systemAccessLogDOPage); + } + +} diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemExceptionLogService.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemExceptionLogService.java new file mode 100644 index 000000000..af7e7f280 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemExceptionLogService.java @@ -0,0 +1,24 @@ +package cn.iocoder.mall.systemservice.service.systemlog; + +import cn.iocoder.mall.systemservice.convert.systemlog.SystemExceptionLogConvert; +import cn.iocoder.mall.systemservice.dal.mysql.dataobject.systemlog.SystemExceptionLogDO; +import cn.iocoder.mall.systemservice.dal.mysql.mapper.systemlog.SystemExceptionLogMapper; +import cn.iocoder.mall.systemservice.service.systemlog.bo.SystemExceptionLogCreateBO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * 系统异常日志 Service + */ +@Service +public class SystemExceptionLogService { + + @Autowired + private SystemExceptionLogMapper systemExceptionLogMapper; + + public void createSystemExceptionLog(SystemExceptionLogCreateBO createBO) { + SystemExceptionLogDO logDO = SystemExceptionLogConvert.INSTANCE.convert(createBO); + systemExceptionLogMapper.insert(logDO); + } + +} 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 deleted file mode 100644 index 36cb24a74..000000000 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/SystemLogService.java +++ /dev/null @@ -1,39 +0,0 @@ -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/SystemAccessLogBO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemAccessLogBO.java new file mode 100644 index 000000000..fbc191dec --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemAccessLogBO.java @@ -0,0 +1,76 @@ +package cn.iocoder.mall.systemservice.service.systemlog.bo; + +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; + +/** +* 系统访问日志 BO +*/ +@Data +@Accessors(chain = true) +public class SystemAccessLogBO { + + /** + * 编号 + */ + private Integer id; + /** + * 用户编号 + */ + private Integer userId; + /** + * 用户类型 + */ + private Integer userType; + /** + * 链路追踪编号 + */ + private String traceId; + /** + * 应用名 + */ + private String applicationName; + /** + * 访问地址 + */ + private String uri; + /** + * 参数 + */ + private String queryString; + /** + * http 方法 + */ + private String method; + /** + * userAgent + */ + private String userAgent; + /** + * ip + */ + private String ip; + /** + * 请求时间 + */ + private Date startTime; + /** + * 响应时长 -- 毫秒级 + */ + private Integer responseTime; + /** + * 错误码 + */ + private Integer errorCode; + /** + * 错误提示 + */ + private String errorMessage; + /** + * 创建时间 + */ + private Date createTime; + +} 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/SystemAccessLogCreateBO.java similarity index 94% rename from system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/AccessLogAddBO.java rename to system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemAccessLogCreateBO.java index 1f0bca2dc..1dedb76a7 100644 --- 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/SystemAccessLogCreateBO.java @@ -5,7 +5,6 @@ import lombok.Data; import lombok.experimental.Accessors; import javax.validation.constraints.NotNull; -import java.io.Serializable; import java.util.Date; /** @@ -13,7 +12,7 @@ import java.util.Date; */ @Data @Accessors(chain = true) -public class AccessLogAddBO implements Serializable { +public class SystemAccessLogCreateBO { /** * 账号编号 diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemAccessLogPageBO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemAccessLogPageBO.java new file mode 100644 index 000000000..c552b5f81 --- /dev/null +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemAccessLogPageBO.java @@ -0,0 +1,29 @@ +package cn.iocoder.mall.systemservice.service.systemlog.bo; + +import cn.iocoder.common.framework.vo.PageParam; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** +* 系统访问日志分页 BO +*/ +@Data +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +public class SystemAccessLogPageBO extends PageParam { + + /** + * 用户编号 + */ + private Integer userId; + /** + * 用户类型 + */ + private Integer userType; + /** + * 应用名 + */ + private String applicationName; + +} 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/SystemExceptionLogCreateBO.java similarity index 96% rename from system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/ExceptionLogAddBO.java rename to system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/service/systemlog/bo/SystemExceptionLogCreateBO.java index 06d919264..e76d39829 100644 --- 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/SystemExceptionLogCreateBO.java @@ -8,11 +8,11 @@ import javax.validation.constraints.NotNull; import java.util.Date; /** - * 异常日志添加 BO + * 系统异常日志添加 BO */ @Data @Accessors(chain = true) -public class ExceptionLogAddBO { +public class SystemExceptionLogCreateBO { /** * 账号编号 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 81112d069..823916a1f 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,8 +37,6 @@ dubbo: version: 1.0.0 AdminRpc: version: 1.0.0 - SystemLogRPC: - version: 1.0.0 ResourceRpc: version: 1.0.0 RoleRpc: @@ -49,3 +47,7 @@ dubbo: version: 1.0.0 DataDictRpc: version: 1.0.0 + SystemExceptionLogRpc: + version: 1.0.0 + SystemAccessLogRpc: + version: 1.0.0 diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/user/UserConvert.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/user/UserConvert.java index b5bcb06ef..40e783645 100644 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/user/UserConvert.java +++ b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/convert/user/UserConvert.java @@ -18,10 +18,6 @@ public interface UserConvert { UserConvert INSTANCE = Mappers.getMapper(UserConvert.class); - @Mapping(source = "userBO", target = "user") - @Mapping(source = "accessTokenBO", target = "token") - UserAuthenticateBO convert(UserBO userBO, OAuth2AuthenticateBO accessTokenBO); - UserBO convert(UserDO bean); /** diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/AccessLogPageDTO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/AccessLogPageDTO.java deleted file mode 100644 index 6e7a6fe85..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/AccessLogPageDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -package cn.iocoder.mall.system.biz.dto.system; - -import lombok.Data; -import lombok.experimental.Accessors; - -import javax.validation.constraints.NotNull; - -/** - * 访问日志添加 DTO - */ -@Data -@Accessors(chain = true) -public class AccessLogPageDTO { // TODO FROM 芋艿 to 2447007062:有个 PageParams 类哈,可以继承 - - - /** - * 账号编号 - */ - private Integer accountId; - - /** - * 页码,从 1 开始 - */ - @NotNull(message = "页码不能为空") - private Integer pageNo; - - /** - * 每页条数 - */ - @NotNull(message = "每页条数不能为空") - private Integer pageSize; -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/DataDictController.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/DataDictController.java deleted file mode 100644 index 8d8fb9513..000000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/DataDictController.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.iocoder.mall.system.application.controller.admins; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.system.api.DataDictService; -import cn.iocoder.mall.system.api.bo.datadict.DataDictBO; -import cn.iocoder.mall.system.api.dto.datadict.DataDictAddDTO; -import cn.iocoder.mall.system.api.dto.datadict.DataDictUpdateDTO; -import cn.iocoder.mall.system.application.convert.DataDictConvert; -import cn.iocoder.mall.system.application.vo.datadict.DataDictEnumVO; -import cn.iocoder.mall.system.sdk.annotation.RequiresPermissions; -import cn.iocoder.mall.system.sdk.context.AdminSecurityContextHolder; -import com.google.common.collect.ImmutableListMultimap; -import com.google.common.collect.Multimaps; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiOperation; -import org.apache.dubbo.config.annotation.Reference; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.List; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -@RestController -@RequestMapping("admins/data_dict") -@Api("数据字典模块") -public class DataDictController { - - @Reference(validation = "true", version = "${dubbo.provider.DataDictService.version}") - private DataDictService dataDictService; - - @GetMapping("/list") - @ApiOperation(value = "数据字典全列表") - @RequiresPermissions("system.dataDict.list") - public CommonResult> list() { - return success( dataDictService.selectDataDictList()); - } - - @GetMapping("/tree") - @RequiresPermissions({}) // 因为是通用的接口,所以无需权限标识 - @ApiOperation(value = "数据字典树结构", notes = "该接口返回的信息更为精简。一般用于前端缓存数据字典到本地。") - public CommonResult> tree() { - // 查询数据字典全列表 - List dataDicts = dataDictService.selectDataDictList(); - // 构建基于 enumValue 聚合的 Multimap - ImmutableListMultimap dataDictMap = Multimaps.index(dataDicts, DataDictBO::getEnumValue); // KEY 是 enumValue ,VALUE 是 DataDictBO 数组 - // 构建返回结果 - List dataDictEnumVOs = new ArrayList<>(dataDictMap.size()); - dataDictMap.keys().forEach(enumValue -> { - DataDictEnumVO dataDictEnumVO = new DataDictEnumVO().setEnumValue(enumValue) - .setValues(DataDictConvert.INSTANCE.convert2(dataDictMap.get(enumValue))); - dataDictEnumVOs.add(dataDictEnumVO); - }); - return success(dataDictEnumVOs); - } - - @PostMapping("/add") - @RequiresPermissions("system.dataDict.add") - @ApiOperation(value = "创建数据字典") - public CommonResult add(DataDictAddDTO dataDictAddDTO) { - return success(dataDictService.addDataDict(AdminSecurityContextHolder.getContext().getAdminId(), dataDictAddDTO)); - } - - @PostMapping("/update") - @RequiresPermissions("system.dataDict.update") - @ApiOperation(value = "更新数据字典") - public CommonResult update(DataDictUpdateDTO dataDictUpdateDTO) { - return success(dataDictService.updateDataDict(AdminSecurityContextHolder.getContext().getAdminId(), dataDictUpdateDTO)); - } - - @PostMapping("/delete") - @RequiresPermissions("system.dataDict.delete") - @ApiOperation(value = "删除数据字典") - @ApiImplicitParam(name = "id", value = "编号", required = true, example = "100") - public CommonResult delete(@RequestParam("id") Integer id) { - return success(dataDictService.deleteDataDict(AdminSecurityContextHolder.getContext().getAdminId(), id)); - } - -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/SystemLogController.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/SystemLogController.java deleted file mode 100644 index 91b8dee5e..000000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/controller/admins/SystemLogController.java +++ /dev/null @@ -1,56 +0,0 @@ -package cn.iocoder.mall.system.application.controller.admins; - -import cn.iocoder.common.framework.vo.CommonResult; -import cn.iocoder.mall.system.api.SystemLogService; -import cn.iocoder.mall.system.api.bo.systemlog.AccessLogPageBO; -import cn.iocoder.mall.system.api.dto.systemlog.AccessLogPageDTO; -import cn.iocoder.mall.system.application.convert.AccessLogConvert; -import cn.iocoder.mall.system.application.vo.log.AccessLogPageVo; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import org.apache.dubbo.config.annotation.Reference; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import static cn.iocoder.common.framework.vo.CommonResult.success; - -/** - * @author:ycjx - * @descriptio - * @create:2019-06-23 16:42 - */ -@RestController -@RequestMapping("admins/system/logs") -@Api("系统日志") -public class SystemLogController { - - @Reference(validation = "true", version = "${dubbo.provider.AdminAccessLogService.version}") - private SystemLogService systemLogService; - - @GetMapping("access/page") - @ApiOperation(value = "访问日志分页") - @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", value = "用户id", example = "1"), - @ApiImplicitParam(name = "pageNo", value = "页码,从 1 开始", example = "1"), - @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, example = "10"), - }) - public CommonResult page(@RequestParam(value = "userId", required = false) Integer userId, - @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { - - - AccessLogPageDTO accessLogPageDTO = new AccessLogPageDTO().setUserId(userId) - .setPageNo(pageNo).setPageSize(pageSize); - // 查询分页 - AccessLogPageBO result = systemLogService.getAccessLogPage(accessLogPageDTO); - // 转换结果 - return success(AccessLogConvert.INSTANCE.convert(result)); - - } - - -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/convert/AccessLogConvert.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/convert/AccessLogConvert.java deleted file mode 100644 index 93d7b53df..000000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/convert/AccessLogConvert.java +++ /dev/null @@ -1,30 +0,0 @@ -package cn.iocoder.mall.system.application.convert; - -import cn.iocoder.mall.system.api.bo.systemlog.AccessLogBO; -import cn.iocoder.mall.system.api.bo.systemlog.AccessLogPageBO; -import cn.iocoder.mall.system.application.vo.log.AccessLogPageVo; -import cn.iocoder.mall.system.application.vo.log.AccessLogVo; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -/** - * @author:ycjx - * @descriptio - * @create:2019-06-23 17:36 - */ -@Mapper -public interface AccessLogConvert { - - - AccessLogConvert INSTANCE = Mappers.getMapper(AccessLogConvert.class); - - @Mappings({}) - AccessLogPageVo convert(AccessLogPageBO result); - - @Mappings({}) - AccessLogVo convert(AccessLogBO result); - - - -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/convert/DataDictConvert.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/convert/DataDictConvert.java deleted file mode 100644 index 24886799c..000000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/convert/DataDictConvert.java +++ /dev/null @@ -1,19 +0,0 @@ -package cn.iocoder.mall.system.application.convert; - -import cn.iocoder.mall.system.api.bo.datadict.DataDictBO; -import cn.iocoder.mall.system.application.vo.datadict.DataDictEnumVO; -import org.mapstruct.Mapper; -import org.mapstruct.Mappings; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -@Mapper -public interface DataDictConvert { - - DataDictConvert INSTANCE = Mappers.getMapper(DataDictConvert.class); - - @Mappings({}) - List convert2(List dataDictBOs); - -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/log/AccessLogPageVo.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/log/AccessLogPageVo.java deleted file mode 100644 index f518457d1..000000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/log/AccessLogPageVo.java +++ /dev/null @@ -1,25 +0,0 @@ -package cn.iocoder.mall.system.application.vo.log; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.List; - -/** - * @author:ycjx - * @descriptio - * @create:2019-06-23 17:03 - */ -@ApiModel("访问日志分页 VO") -@Data -@Accessors(chain = true) -public class AccessLogPageVo { - - - @ApiModelProperty(value = "访问数据") - private List list; - @ApiModelProperty(value = "访问总数") - private Integer total; -} diff --git a/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/log/AccessLogVo.java b/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/log/AccessLogVo.java deleted file mode 100644 index 35140eed5..000000000 --- a/system/system-start/src/main/java/cn/iocoder/mall/system/application/vo/log/AccessLogVo.java +++ /dev/null @@ -1,58 +0,0 @@ -package cn.iocoder.mall.system.application.vo.log; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.experimental.Accessors; - -import java.util.Date; - -/** - * @author:yuxj - * @descriptio - * @create:2019-06-23 17:04 - */ - -@ApiModel("访问日志 VO") -@Data -@Accessors(chain = true) -public class AccessLogVo { - - - @ApiModelProperty(value = "链路追踪编号", required = true, example = "1") - private String traceId; - - @ApiModelProperty(value = "用户编号", required = true, example = "1") - private Integer userId; - - @ApiModelProperty(value = "用户类型", required = true, example = "1") - private Integer userType; - - @ApiModelProperty(value = "应用名", required = true, example = "1") - private String applicationName; - - @ApiModelProperty(value = "访问地址", required = true, example = "1") - private String uri; - - @ApiModelProperty(value = "请求参数", required = true, example = "1") - private String queryString; - - @ApiModelProperty(value = "http 请求方法", required = true, example = "1") - private String method; - - @ApiModelProperty(value = "User-Agent ", required = true, example = "1") - private String userAgent; - - @ApiModelProperty(value = "ip", required = true, example = "1") - private String ip; - - @ApiModelProperty(value = "请求时间", required = true, example = "1") - private Date startTime; - - @ApiModelProperty(value = "响应时长", required = true, example = "1") - private Integer responseTime; - - @ApiModelProperty(value = "错误码", required = true, example = "1") - private Integer errorCode; - -}