From 08afab388a0fdb8e7f14bcb815007f4ca46172ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E6=96=87=E8=B1=AA?= <980287353@qq.com> Date: Tue, 3 Jan 2023 14:05:02 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=A2=9E=E5=8A=A0=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../annotation/operation/OperationLog.java | 24 ++++ .../migration/config/DbMigrationConfig.java | 27 +++- .../service/DbMigrationInitializer.java | 30 +--- .../tiesheng/core/CoreAutoImportSelector.java | 2 + .../exception/SpringExceptionHandler.java | 10 +- .../config/operation/OperationAspect.java | 87 ++++++++++++ .../core/config/token/TokenValidConfig.java | 14 +- .../config/web/TieshengWebConfigurer.java | 41 ++++++ .../core/config/web/bean/CurrentWebUser.java | 36 +++++ .../controller/log/ManagerLogController.java | 47 ++++++ .../core/mapper/CoreLogOperationMapper.java | 8 ++ .../core/pojos/dao/CoreLogOperation.java | 134 ++++++++++++++++++ .../tiesheng/core/service/CoreLogService.java | 42 ++++++ .../resources/db/migration/tiesheng_base.sql | 54 +++++++ .../mapper/CoreLogOperationMapper.xml | 22 +++ 15 files changed, 541 insertions(+), 37 deletions(-) create mode 100644 tiesheng-annotation/src/main/java/com/tiesheng/annotation/operation/OperationLog.java create mode 100644 tiesheng-web/src/main/java/com/tiesheng/core/config/operation/OperationAspect.java create mode 100644 tiesheng-web/src/main/java/com/tiesheng/core/config/web/TieshengWebConfigurer.java create mode 100644 tiesheng-web/src/main/java/com/tiesheng/core/config/web/bean/CurrentWebUser.java create mode 100644 tiesheng-web/src/main/java/com/tiesheng/core/controller/log/ManagerLogController.java create mode 100644 tiesheng-web/src/main/java/com/tiesheng/core/mapper/CoreLogOperationMapper.java create mode 100644 tiesheng-web/src/main/java/com/tiesheng/core/pojos/dao/CoreLogOperation.java create mode 100644 tiesheng-web/src/main/java/com/tiesheng/core/service/CoreLogService.java create mode 100644 tiesheng-web/src/main/resources/db/migration/tiesheng_base.sql create mode 100644 tiesheng-web/src/main/resources/mapper/CoreLogOperationMapper.xml diff --git a/tiesheng-annotation/src/main/java/com/tiesheng/annotation/operation/OperationLog.java b/tiesheng-annotation/src/main/java/com/tiesheng/annotation/operation/OperationLog.java new file mode 100644 index 0000000..eb87fcc --- /dev/null +++ b/tiesheng-annotation/src/main/java/com/tiesheng/annotation/operation/OperationLog.java @@ -0,0 +1,24 @@ +package com.tiesheng.annotation.operation; + +import java.lang.annotation.*; + +/** + * @author hao + */ +@Target(ElementType.METHOD) +@Documented +@Retention(RetentionPolicy.RUNTIME) +public @interface OperationLog { + + String title() default ""; + + String subject() default ""; + + /** + * 如果该值存在,怎会校验参数中是否存在该值,存在则便是更新,不存在则表示添加 + * + * @return + */ + String insertKey() default ""; + +} diff --git a/tiesheng-db-migration/src/main/java/com/tiesheng/migration/config/DbMigrationConfig.java b/tiesheng-db-migration/src/main/java/com/tiesheng/migration/config/DbMigrationConfig.java index c24b957..bc41879 100644 --- a/tiesheng-db-migration/src/main/java/com/tiesheng/migration/config/DbMigrationConfig.java +++ b/tiesheng-db-migration/src/main/java/com/tiesheng/migration/config/DbMigrationConfig.java @@ -2,9 +2,12 @@ package com.tiesheng.migration.config; import cn.hutool.core.collection.CollUtil; +import cn.hutool.db.Db; +import cn.hutool.db.Entity; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; +import java.sql.SQLException; import java.util.List; /** @@ -16,10 +19,32 @@ import java.util.List; @ConfigurationProperties(prefix = "tiesheng.db-migration") public class DbMigrationConfig { - private String table = "ts_db_migration"; + private String table = "core_db_migration"; private List locations = CollUtil.newArrayList("classpath:db/migration/*.sql"); private String ignoreSqls = "drop,delete"; + /** + * 检查数据库是否存在 + * + * @param db + * @throws SQLException + */ + public void checkDbExists(Db db) throws SQLException { + try { + db.count(Entity.create(getTable())); + } catch (SQLException ignored) { + db.execute("CREATE TABLE `" + getTable() + "` (\n" + + " `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,\n" + + " `create_time` datetime(0) NOT NULL,\n" + + " `update_time` datetime(0) NOT NULL,\n" + + " `is_deleted` int(6) NOT NULL DEFAULT 0,\n" + + " `file` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件名称',\n" + + " `checksum` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件checksum',\n" + + " PRIMARY KEY (`id`) USING BTREE\n" + + ") ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'db-合并' ROW_FORMAT = Dynamic;"); + } + } + /////////////////////////////////////////////////////////////////////////// // setter\getter /////////////////////////////////////////////////////////////////////////// diff --git a/tiesheng-db-migration/src/main/java/com/tiesheng/migration/service/DbMigrationInitializer.java b/tiesheng-db-migration/src/main/java/com/tiesheng/migration/service/DbMigrationInitializer.java index ea71f47..e742826 100644 --- a/tiesheng-db-migration/src/main/java/com/tiesheng/migration/service/DbMigrationInitializer.java +++ b/tiesheng-db-migration/src/main/java/com/tiesheng/migration/service/DbMigrationInitializer.java @@ -9,7 +9,6 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.db.Db; import cn.hutool.db.Entity; -import cn.hutool.log.LogFactory; import com.tiesheng.migration.config.DbMigrationConfig; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.ServletContextInitializer; @@ -54,7 +53,7 @@ public class DbMigrationInitializer implements ServletContextInitializer { */ private void startDeal() throws Exception { Db coreDb = Db.use(dataSource); - checkDbMigration(coreDb); + dbMigrationConfig.checkDbExists(coreDb); PathMatchingResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver(); for (String location : dbMigrationConfig.getLocations()) { @@ -95,7 +94,10 @@ public class DbMigrationInitializer implements ServletContextInitializer { if (StrUtil.startWithAnyIgnoreCase(sql, StrUtil.splitToArray(dbMigrationConfig.getIgnoreSqls(), ","))) { continue; } - parameter.execute(sql); + try { + parameter.execute(sql); + } catch (Exception ignore) { + } } }); @@ -132,26 +134,4 @@ public class DbMigrationInitializer implements ServletContextInitializer { } - /** - * 检查数据库是否存在 - * - * @param db - * @throws SQLException - */ - private void checkDbMigration(Db db) throws SQLException { - try { - db.count(Entity.create(dbMigrationConfig.getTable())); - } catch (SQLException ignored) { - db.execute("CREATE TABLE `" + dbMigrationConfig.getTable() + "` (\n" + - " `id` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,\n" + - " `create_time` datetime(0) NOT NULL,\n" + - " `update_time` datetime(0) NOT NULL,\n" + - " `is_deleted` int(6) NOT NULL DEFAULT 0,\n" + - " `file` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件名称',\n" + - " `checksum` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件checksum',\n" + - " PRIMARY KEY (`id`) USING BTREE\n" + - ") ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = 'db-合并' ROW_FORMAT = Dynamic;"); - } - } - } diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/CoreAutoImportSelector.java b/tiesheng-web/src/main/java/com/tiesheng/core/CoreAutoImportSelector.java index 6dd28b0..7876cb8 100644 --- a/tiesheng-web/src/main/java/com/tiesheng/core/CoreAutoImportSelector.java +++ b/tiesheng-web/src/main/java/com/tiesheng/core/CoreAutoImportSelector.java @@ -1,5 +1,6 @@ package com.tiesheng.core; +import org.mybatis.spring.annotation.MapperScan; import org.springframework.context.annotation.ComponentScan; /** @@ -9,5 +10,6 @@ import org.springframework.context.annotation.ComponentScan; @ComponentScan({ "com.tiesheng.core.**.*", }) +@MapperScan("com.tiesheng.core.mapper") public class CoreAutoImportSelector { } diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/config/exception/SpringExceptionHandler.java b/tiesheng-web/src/main/java/com/tiesheng/core/config/exception/SpringExceptionHandler.java index 8fc66b0..25236dd 100644 --- a/tiesheng-web/src/main/java/com/tiesheng/core/config/exception/SpringExceptionHandler.java +++ b/tiesheng-web/src/main/java/com/tiesheng/core/config/exception/SpringExceptionHandler.java @@ -2,10 +2,11 @@ package com.tiesheng.core.config.exception; import cn.hutool.core.exceptions.ValidateException; import cn.hutool.extra.spring.SpringUtil; -import cn.hutool.log.LogFactory; +import com.tiesheng.core.config.web.TieshengWebConfigurer; import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.exception.ApiRespEnum; import com.tiesheng.util.pojos.ApiResp; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.web.servlet.MultipartProperties; import org.springframework.validation.BindException; import org.springframework.validation.FieldError; @@ -24,6 +25,9 @@ import java.io.IOException; @RestControllerAdvice public class SpringExceptionHandler { + @Autowired(required = false) + TieshengWebConfigurer tieshengWebConfigurer; + /** * 全局异常捕获 @@ -70,9 +74,7 @@ public class SpringExceptionHandler { return ApiResp.respCust(ApiRespEnum.ServerError.getCode(), "IO异常"); } - ApiResp apiResp = ApiResp.respCust(ApiRespEnum.ServerError); - LogFactory.get().info(e); - return apiResp; + return tieshengWebConfigurer.addExceptionHandler(e); } } diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/config/operation/OperationAspect.java b/tiesheng-web/src/main/java/com/tiesheng/core/config/operation/OperationAspect.java new file mode 100644 index 0000000..82c0c84 --- /dev/null +++ b/tiesheng-web/src/main/java/com/tiesheng/core/config/operation/OperationAspect.java @@ -0,0 +1,87 @@ +package com.tiesheng.core.config.operation; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.StrUtil; +import com.tiesheng.annotation.operation.OperationLog; +import com.tiesheng.core.config.token.TokenParse; +import com.tiesheng.core.config.token.bean.TokenBean; +import com.tiesheng.core.service.CoreLogService; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + + +/** + * @author hao + * @ProjectName CmccSpring + * @Copyright Hangzhou ShuoChuang Technology Co.,Ltd All Right Reserved + * @Description 这里是对文件的描述 + * @data 2019-07-15 + * @note 这里写文件的详细功能和改动 + * @note + */ +@Aspect +@Component +public class OperationAspect { + + @Autowired + CoreLogService coreLogService; + + + @Pointcut("@annotation(com.tiesheng.annotation.operation.OperationLog)") + public void methodArgs() { + + } + + + /** + * 获取操作日志说明 + * + * @param joinPoint + */ + @Around("methodArgs()") + public Object around(ProceedingJoinPoint joinPoint) throws Throwable { + MethodSignature signature = (MethodSignature) joinPoint.getSignature(); + Method method = signature.getMethod(); + OperationLog operationLog = method.getAnnotation(OperationLog.class); + String subject = operationLog.subject(); + String insertKey = operationLog.insertKey(); + + Object reqObj = null; + Map allParams = new HashMap<>(16); + if (joinPoint.getArgs().length > 0) { + reqObj = joinPoint.getArgs()[0]; + allParams.putAll(BeanUtil.beanToMap(reqObj)); + } + + Object response = joinPoint.proceed(joinPoint.getArgs()); + allParams.putAll(BeanUtil.beanToMap(response)); + + if (!StrUtil.isEmpty(subject)) { + + // 添加、编辑关键字处理 + if (!StrUtil.isEmpty(insertKey)) { + String insertVal = MapUtil.getStr(allParams, insertKey); + subject = (StrUtil.isEmpty(insertVal) ? "添加" : "编辑") + subject; + } + + // 占位符处理 + subject = StrUtil.format(subject, allParams); + } + + coreLogService.addOperationLog(operationLog.title(), subject, reqObj); + + return response; + } + + +} diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/config/token/TokenValidConfig.java b/tiesheng-web/src/main/java/com/tiesheng/core/config/token/TokenValidConfig.java index 1e05f57..4d36684 100644 --- a/tiesheng-web/src/main/java/com/tiesheng/core/config/token/TokenValidConfig.java +++ b/tiesheng-web/src/main/java/com/tiesheng/core/config/token/TokenValidConfig.java @@ -16,7 +16,7 @@ import java.util.Map; @ConfigurationProperties("tiesheng.token") public class TokenValidConfig { - private Map list = MapUtil.newHashMap(); + private Map ignores = MapUtil.newHashMap(); /** @@ -26,21 +26,21 @@ public class TokenValidConfig { * @return */ public TokenBean getTokenBean(String token) { - if (list == null) { + if (ignores == null) { return null; } - return list.get(token); + return ignores.get(token); } /////////////////////////////////////////////////////////////////////////// // setter\getter /////////////////////////////////////////////////////////////////////////// - public Map getList() { - return list; + public Map getIgnores() { + return ignores; } - public void setList(Map list) { - this.list = list; + public void setIgnores(Map ignores) { + this.ignores = ignores; } } diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/config/web/TieshengWebConfigurer.java b/tiesheng-web/src/main/java/com/tiesheng/core/config/web/TieshengWebConfigurer.java new file mode 100644 index 0000000..7b9ef26 --- /dev/null +++ b/tiesheng-web/src/main/java/com/tiesheng/core/config/web/TieshengWebConfigurer.java @@ -0,0 +1,41 @@ +package com.tiesheng.core.config.web; + +import cn.hutool.log.LogFactory; +import com.tiesheng.core.config.token.TokenParse; +import com.tiesheng.core.config.web.bean.CurrentWebUser; +import com.tiesheng.util.exception.ApiRespEnum; +import com.tiesheng.util.pojos.ApiResp; +import org.springframework.context.annotation.Configuration; + +/** + * WEB配置 + * + * @author hao + */ +@Configuration +public interface TieshengWebConfigurer { + + + /** + * 获取当前用户的姓名 + * + * @return + */ + default CurrentWebUser getCurrentUserName() { + CurrentWebUser webUser = new CurrentWebUser(); + webUser.setId(TokenParse.getWithoutThr().getId()); + return webUser; + } + + + /** + * 添加其他异常处理 + * + * @param e 异常 + */ + default ApiResp addExceptionHandler(Exception e) { + LogFactory.get().info(e); + return ApiResp.respCust(ApiRespEnum.ServerError); + } + +} diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/config/web/bean/CurrentWebUser.java b/tiesheng-web/src/main/java/com/tiesheng/core/config/web/bean/CurrentWebUser.java new file mode 100644 index 0000000..b330d66 --- /dev/null +++ b/tiesheng-web/src/main/java/com/tiesheng/core/config/web/bean/CurrentWebUser.java @@ -0,0 +1,36 @@ +package com.tiesheng.core.config.web.bean; + +public class CurrentWebUser { + + private String id; + private String name; + private Object data; + + /////////////////////////////////////////////////////////////////////////// + // setter\getter + /////////////////////////////////////////////////////////////////////////// + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Object getData() { + return data; + } + + public void setData(Object data) { + this.data = data; + } +} diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/controller/log/ManagerLogController.java b/tiesheng-web/src/main/java/com/tiesheng/core/controller/log/ManagerLogController.java new file mode 100644 index 0000000..d917b94 --- /dev/null +++ b/tiesheng-web/src/main/java/com/tiesheng/core/controller/log/ManagerLogController.java @@ -0,0 +1,47 @@ +package com.tiesheng.core.controller.log; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tiesheng.core.pojos.dao.CoreLogOperation; +import com.tiesheng.core.pojos.dto.PageDTO; +import com.tiesheng.core.service.CoreLogService; +import com.tiesheng.util.pojos.ApiResp; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * @author hao + */ +@RestController +@RequestMapping("/manager/log") +public class ManagerLogController { + + @Autowired + CoreLogService coreLogService; + + + /** + * 操作日志列表 + * + * @return + */ + @GetMapping("/operation/page") + public ApiResp> operationList(@Valid PageDTO dto) { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_deleted", 0); + dto.likeColumns(queryWrapper, "user_name", "title", "subject", "params"); + queryWrapper.orderByDesc("create_time"); + + Page page = dto.pageObj(); + coreLogService.page(page, queryWrapper); + + return ApiResp.respOK(page.getRecords(), page.getTotal()); + } + +} diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/mapper/CoreLogOperationMapper.java b/tiesheng-web/src/main/java/com/tiesheng/core/mapper/CoreLogOperationMapper.java new file mode 100644 index 0000000..0691a59 --- /dev/null +++ b/tiesheng-web/src/main/java/com/tiesheng/core/mapper/CoreLogOperationMapper.java @@ -0,0 +1,8 @@ +package com.tiesheng.core.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.tiesheng.core.pojos.dao.CoreLogOperation; + +public interface CoreLogOperationMapper extends BaseMapper { + +} diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/pojos/dao/CoreLogOperation.java b/tiesheng-web/src/main/java/com/tiesheng/core/pojos/dao/CoreLogOperation.java new file mode 100644 index 0000000..8a8b2c0 --- /dev/null +++ b/tiesheng-web/src/main/java/com/tiesheng/core/pojos/dao/CoreLogOperation.java @@ -0,0 +1,134 @@ +package com.tiesheng.core.pojos.dao; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.tiesheng.core.pojos.DaoBase; +import java.util.Date; + +/** + * 日志-操作 + */ +@TableName(value = "core_log_operation") +public class CoreLogOperation extends DaoBase { + /** + * 用户id + */ + @TableField(value = "user_id") + private String userId; + + /** + * 用户名称 + */ + @TableField(value = "user_name") + private String userName; + + /** + * 标题 + */ + @TableField(value = "title") + private String title; + + /** + * 小标题 + */ + @TableField(value = "subject") + private String subject; + + /** + * 其他参数 + */ + @TableField(value = "params") + private String params; + + /** + * 获取用户id + * + * @return user_id - 用户id + */ + public String getUserId() { + return userId; + } + + /** + * 设置用户id + * + * @param userId 用户id + */ + public void setUserId(String userId) { + this.userId = userId; + } + + /** + * 获取用户名称 + * + * @return user_name - 用户名称 + */ + public String getUserName() { + return userName; + } + + /** + * 设置用户名称 + * + * @param userName 用户名称 + */ + public void setUserName(String userName) { + this.userName = userName; + } + + /** + * 获取标题 + * + * @return title - 标题 + */ + public String getTitle() { + return title; + } + + /** + * 设置标题 + * + * @param title 标题 + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * 获取小标题 + * + * @return subject - 小标题 + */ + public String getSubject() { + return subject; + } + + /** + * 设置小标题 + * + * @param subject 小标题 + */ + public void setSubject(String subject) { + this.subject = subject; + } + + /** + * 获取其他参数 + * + * @return params - 其他参数 + */ + public String getParams() { + return params; + } + + /** + * 设置其他参数 + * + * @param params 其他参数 + */ + public void setParams(String params) { + this.params = params; + } +} \ No newline at end of file diff --git a/tiesheng-web/src/main/java/com/tiesheng/core/service/CoreLogService.java b/tiesheng-web/src/main/java/com/tiesheng/core/service/CoreLogService.java new file mode 100644 index 0000000..ae343ff --- /dev/null +++ b/tiesheng-web/src/main/java/com/tiesheng/core/service/CoreLogService.java @@ -0,0 +1,42 @@ +package com.tiesheng.core.service; + +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.tiesheng.core.config.web.bean.CurrentWebUser; +import com.tiesheng.core.config.web.TieshengWebConfigurer; +import com.tiesheng.core.mapper.CoreLogOperationMapper; +import com.tiesheng.core.pojos.dao.CoreLogOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author hao + */ +@Service +public class CoreLogService extends ServiceImpl { + + @Autowired(required = false) + TieshengWebConfigurer tieshengWebConfigurer; + + /////////////////////////////////////////////////////////////////////////// + // 操作日志 + /////////////////////////////////////////////////////////////////////////// + + + /** + * 添加操作日志 + */ + public void addOperationLog(String title, String subject, Object params) { + CoreLogOperation operation = new CoreLogOperation(); + CurrentWebUser currentWebUser = tieshengWebConfigurer.getCurrentUserName(); + operation.setUserId(currentWebUser.getId()); + operation.setUserName(currentWebUser.getName()); + operation.setTitle(title); + operation.setSubject(subject); + if (params != null) { + operation.setParams(JSONUtil.toJsonStr(params)); + } + save(operation); + } + +} diff --git a/tiesheng-web/src/main/resources/db/migration/tiesheng_base.sql b/tiesheng-web/src/main/resources/db/migration/tiesheng_base.sql new file mode 100644 index 0000000..ecb7570 --- /dev/null +++ b/tiesheng-web/src/main/resources/db/migration/tiesheng_base.sql @@ -0,0 +1,54 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for core_log_operation +-- ---------------------------- +CREATE TABLE `core_log_operation` +( + `id` varchar(50) NOT NULL, + `create_time` datetime NOT NULL, + `update_time` datetime NOT NULL, + `is_deleted` int(6) NOT NULL DEFAULT '0', + `user_id` varchar(50) DEFAULT NULL COMMENT '用户id', + `user_name` varchar(255) DEFAULT NULL COMMENT '用户名称', + `title` varchar(255) DEFAULT NULL COMMENT '标题', + `subject` varchar(500) DEFAULT NULL COMMENT '小标题', + `params` text COMMENT '其他参数', + PRIMARY KEY (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='日志-操作'; + +CREATE TABLE `core_config_system` +( + `id` varchar(50) NOT NULL, + `create_time` datetime NOT NULL, + `update_time` datetime NOT NULL, + `is_deleted` int(4) NOT NULL DEFAULT '0', + `config_key` varchar(255) NOT NULL, + `config_val` text NOT NULL, + `config_type` int(6) NOT NULL DEFAULT '0' COMMENT '类型:0-文本,1-图片,2-文件', + `remark` varchar(500) DEFAULT NULL COMMENT '说明', + `extra` varchar(255) DEFAULT NULL COMMENT '额外配置', + `read_only` int(6) NOT NULL DEFAULT '0' COMMENT '0-否,1-是', + PRIMARY KEY (`id`), + UNIQUE KEY `uni_key` (`config_key`(50)) USING BTREE +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='配置-系统'; + +INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`, + `config_type`, `remark`, `extra`, `read_only`) +VALUES ('manager_web_copyright', '2022-02-23 16:52:48', '2022-02-23 16:52:49', 0, 'manager_web_copyright', + '杭州铁晟提供技术支持', 0, '网站底部版权信息', '', 0); + +INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`, + `config_type`, `remark`, `extra`, `read_only`) +VALUES ('manager_web_title', '2022-02-24 11:56:53', '2022-02-24 11:56:53', 0, 'manager_web_title', '网站名称', 0, + '网站名称', '', 0); + +INSERT INTO `core_config_system`(`id`, `create_time`, `update_time`, `is_deleted`, `config_key`, `config_val`, + `config_type`, `remark`, `extra`, `read_only`) +VALUES ('manager_web_logo', '2022-02-24 11:56:53', '2022-02-24 11:56:53', 0, 'manager_web_logo', '', 1, + '网站LOGO', '', 0); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/tiesheng-web/src/main/resources/mapper/CoreLogOperationMapper.xml b/tiesheng-web/src/main/resources/mapper/CoreLogOperationMapper.xml new file mode 100644 index 0000000..d65f0e4 --- /dev/null +++ b/tiesheng-web/src/main/resources/mapper/CoreLogOperationMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + id, create_time, update_time, is_deleted, user_id, user_name, title, subject, params + + +