访问日志的管理功能的迁移
This commit is contained in:
parent
e1e42c0ce0
commit
4ed8d5fcf2
@ -33,8 +33,11 @@ public class ServiceExceptionUtil {
|
||||
public interface Enumerable<V extends Enum> {
|
||||
|
||||
int getCode();
|
||||
|
||||
String getMessage();
|
||||
|
||||
int getGroup();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
0
docs/sql/mall_system_data.sql
Normal file
0
docs/sql/mall_system_data.sql
Normal file
227
docs/sql/mall_system_schema.sql
Normal file
227
docs/sql/mall_system_schema.sql
Normal file
@ -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;
|
@ -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<Integer> createDataDict(@Valid DataDictCreateDTO createDTO) {
|
||||
return success(dataDictManager.createDataDict(createDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新数据字典")
|
||||
@RequiresPermissions("system:data-dict:update")
|
||||
public CommonResult<Boolean> 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<Boolean> 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<DataDictVO> 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<List<DataDictVO>> listDataDicts(@RequestParam("dataDictIds") List<Integer> dataDictIds) {
|
||||
return success(dataDictManager.listDataDicts(dataDictIds));
|
||||
}
|
||||
|
||||
@GetMapping("/list-all")
|
||||
@ApiOperation("获得全部数据字典列表")
|
||||
@RequiresPermissions("system:data-dict:list")
|
||||
public CommonResult<List<DataDictVO>> listDataDicts() {
|
||||
return success(dataDictManager.listDataDicts());
|
||||
}
|
||||
|
||||
@GetMapping("/list-all-simple")
|
||||
@ApiOperation(value = "获得全部数据字典列表", notes = "一般用于管理后台缓存数据字典在本地")
|
||||
// 无需添加权限认证,因为前端全局都需要
|
||||
public CommonResult<List<DataDictSimpleVO>> listSimpleDataDicts() {
|
||||
return success(dataDictManager.listSimpleDataDicts());
|
||||
}
|
||||
|
@ -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}}
|
||||
|
||||
###
|
||||
|
@ -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<PageResult<SystemAccessLogVO>> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
return success(systemAccessLogManager.pageSystemAccessLog(pageDTO));
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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<SystemAccessLogVO> convertPage(PageResult<cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO> page);
|
||||
|
||||
}
|
@ -21,7 +21,7 @@ public class DataDictManager {
|
||||
|
||||
private static final Comparator<cn.iocoder.mall.systemservice.rpc.datadict.vo.DataDictVO> 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());
|
||||
|
@ -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<SystemAccessLogVO> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
CommonResult<PageResult<cn.iocoder.mall.systemservice.rpc.systemlog.vo.SystemAccessLogVO>> pageSystemAccessLogResult =
|
||||
systemAccessLogRpc.pageSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(pageDTO));
|
||||
pageSystemAccessLogResult.checkError();
|
||||
return SystemAccessLogConvert.INSTANCE.convertPage(pageSystemAccessLogResult.getData());
|
||||
}
|
||||
|
||||
}
|
@ -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:
|
||||
|
@ -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<Boolean> createSystemAccessLog(SystemAccessLogCreateDTO createDTO);
|
||||
|
||||
/**
|
||||
* 获得系统访问日志分页
|
||||
*
|
||||
* @param pageDTO 系统访问日志分页查询
|
||||
* @return 系统访问日志分页结果
|
||||
*/
|
||||
CommonResult<PageResult<SystemAccessLogVO>> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO);
|
||||
|
||||
}
|
@ -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<Boolean> createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO);
|
||||
|
||||
}
|
@ -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<Boolean> addAccessLog(AccessLogAddDTO accessLogAddDTO);
|
||||
|
||||
CommonResult<Boolean> addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO);
|
||||
|
||||
}
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 账号编号
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 账号编号
|
@ -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;
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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<SystemAccessLogBO> convertPage(IPage<SystemAccessLogDO> page);
|
||||
|
||||
SystemAccessLogPageBO convert(SystemAccessLogPageDTO bean);
|
||||
|
||||
PageResult<SystemAccessLogVO> convertPage(PageResult<SystemAccessLogBO> page);
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
@ -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<AccessLogBO> convertPage(IPage<AccessLogDO> page);
|
||||
//
|
||||
// AccessLogBO convert(AccessLogDO bean);
|
||||
|
||||
}
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 编号
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 编号
|
@ -13,16 +13,16 @@ public interface DataDictMapper extends BaseMapper<DataDictDO> {
|
||||
|
||||
default DataDictDO selectByEnumValueAndValue(String enumValue, String value) {
|
||||
return selectOne(new QueryWrapper<DataDictDO>()
|
||||
.eq("enumValue", enumValue).eq("value", value));
|
||||
.eq("enum_value", enumValue).eq("value", value));
|
||||
}
|
||||
|
||||
default List<DataDictDO> selectByEnumValueAndValues(String enumValue, Collection<String> values) {
|
||||
return selectList(new QueryWrapper<DataDictDO>()
|
||||
.eq("enumValue", enumValue).in("value", values));
|
||||
.eq("enum_value", enumValue).in("value", values));
|
||||
}
|
||||
|
||||
default List<DataDictDO> selectByEnumValue(String enumValue) {
|
||||
return selectList(new QueryWrapper<DataDictDO>().eq("enumValue", enumValue));
|
||||
return selectList(new QueryWrapper<DataDictDO>().eq("enum_value", enumValue));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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<AccessLogDO> {
|
||||
|
||||
// default IPage<AccessLogDO> selectPage(AccessLogPageDTO accessLogPageDTO) {
|
||||
// return selectPage(new Page<>(accessLogPageDTO.getPageNo(), accessLogPageDTO.getPageSize()),
|
||||
// new QueryWrapperX<AccessLogDO>().eqIfPresent("account_id", accessLogPageDTO.getAccountId()));
|
||||
// }
|
||||
|
||||
}
|
@ -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<SystemAccessLogDO> {
|
||||
|
||||
default IPage<SystemAccessLogDO> selectPage(SystemAccessLogPageBO pageBO) {
|
||||
return selectPage(new Page<>(pageBO.getPageNo(), pageBO.getPageSize()),
|
||||
new QueryWrapperX<SystemAccessLogDO>()
|
||||
.eqIfPresent("user_id", pageBO.getUserId())
|
||||
.eqIfPresent("user_type", pageBO.getUserType())
|
||||
.eqIfPresent("application_name", pageBO.getApplicationName())
|
||||
.orderByDesc("start_time"));
|
||||
}
|
||||
|
||||
}
|
@ -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<ExceptionLogDO> {
|
||||
public interface SystemExceptionLogMapper extends BaseMapper<SystemExceptionLogDO> {
|
||||
|
||||
}
|
@ -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<SystemAccessLogVO> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
PageResult<SystemAccessLogBO> pageResultBO = systemAccessLogService.pageSystemAccessLog(SystemAccessLogConvert.INSTANCE.convert(pageDTO));
|
||||
return SystemAccessLogConvert.INSTANCE.convertPage(pageResultBO);
|
||||
}
|
||||
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
@ -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<Boolean> createSystemAccessLog(SystemAccessLogCreateDTO createDTO) {
|
||||
systemAccessLogManager.createSystemAccessLog(createDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<SystemAccessLogVO>> pageSystemAccessLog(SystemAccessLogPageDTO pageDTO) {
|
||||
return success(systemAccessLogManager.pageSystemAccessLog(pageDTO));
|
||||
}
|
||||
|
||||
}
|
@ -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<Boolean> createSystemExceptionLog(SystemExceptionLogCreateDTO createDTO) {
|
||||
systemExceptionLogManager.createSystemExceptionLog(createDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
@ -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<Boolean> addAccessLog(AccessLogAddDTO accessLogAddDTO) {
|
||||
systemLogManager.addAccessLog(accessLogAddDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO) {
|
||||
systemLogManager.addExceptionLog(exceptionLogAddDTO);
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
@ -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<SystemAccessLogBO> pageSystemAccessLog(SystemAccessLogPageBO pageBO) {
|
||||
IPage<SystemAccessLogDO> systemAccessLogDOPage = systemAccessLogMapper.selectPage(pageBO);
|
||||
return SystemAccessLogConvert.INSTANCE.convertPage(systemAccessLogDOPage);
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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<AccessLogBO> getAccessLogPage(AccessLogPageDTO accessLogPageDTO) {
|
||||
// PageResult<AccessLogBO> accessLogPageBOPageResult = SystemLogConvert.INSTANCE.convertPage(
|
||||
// accessLogMapper.selectPage(accessLogPageDTO)); // TODO FROM 芋艿 to 2447007062:可以考虑直接 return,简洁 + IDEA 不告警;
|
||||
// return accessLogPageBOPageResult;
|
||||
// }
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 账号编号
|
@ -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;
|
||||
|
||||
}
|
@ -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 {
|
||||
|
||||
/**
|
||||
* 账号编号
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
@ -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<DataDictBO>> list() {
|
||||
return success( dataDictService.selectDataDictList());
|
||||
}
|
||||
|
||||
@GetMapping("/tree")
|
||||
@RequiresPermissions({}) // 因为是通用的接口,所以无需权限标识
|
||||
@ApiOperation(value = "数据字典树结构", notes = "该接口返回的信息更为精简。一般用于前端缓存数据字典到本地。")
|
||||
public CommonResult<List<DataDictEnumVO>> tree() {
|
||||
// 查询数据字典全列表
|
||||
List<DataDictBO> dataDicts = dataDictService.selectDataDictList();
|
||||
// 构建基于 enumValue 聚合的 Multimap
|
||||
ImmutableListMultimap<String, DataDictBO> dataDictMap = Multimaps.index(dataDicts, DataDictBO::getEnumValue); // KEY 是 enumValue ,VALUE 是 DataDictBO 数组
|
||||
// 构建返回结果
|
||||
List<DataDictEnumVO> 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<DataDictBO> add(DataDictAddDTO dataDictAddDTO) {
|
||||
return success(dataDictService.addDataDict(AdminSecurityContextHolder.getContext().getAdminId(), dataDictAddDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@RequiresPermissions("system.dataDict.update")
|
||||
@ApiOperation(value = "更新数据字典")
|
||||
public CommonResult<Boolean> 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<Boolean> delete(@RequestParam("id") Integer id) {
|
||||
return success(dataDictService.deleteDataDict(AdminSecurityContextHolder.getContext().getAdminId(), id));
|
||||
}
|
||||
|
||||
}
|
@ -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<AccessLogPageVo> 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));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
|
||||
|
||||
}
|
@ -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<DataDictEnumVO.Value> convert2(List<DataDictBO> dataDictBOs);
|
||||
|
||||
}
|
@ -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<AccessLogVo> list;
|
||||
@ApiModelProperty(value = "访问总数")
|
||||
private Integer total;
|
||||
}
|
@ -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;
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user