diff --git a/src/main/java/com/glxp/api/entity/monitor/SysOperLog.java b/src/main/java/com/glxp/api/entity/monitor/SysOperLog.java index 2daccd35..bce15531 100644 --- a/src/main/java/com/glxp/api/entity/monitor/SysOperLog.java +++ b/src/main/java/com/glxp/api/entity/monitor/SysOperLog.java @@ -1,5 +1,8 @@ package com.glxp.api.entity.monitor; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import lombok.Data; import java.util.Date; diff --git a/src/main/java/com/glxp/api/entity/system/ScheduledEntity.java b/src/main/java/com/glxp/api/entity/system/ScheduledEntity.java index 3c75b24e..68bda562 100644 --- a/src/main/java/com/glxp/api/entity/system/ScheduledEntity.java +++ b/src/main/java/com/glxp/api/entity/system/ScheduledEntity.java @@ -1,12 +1,16 @@ package com.glxp.api.entity.system; import lombok.Data; +import com.baomidou.mybatisplus.annotation.TableField; @Data public class ScheduledEntity { private int id; + + @TableField(value = "cron_name") private String cronName; + private String cron; private String customerId; } diff --git a/src/main/java/com/glxp/api/handler/MybatisDmHandler.java b/src/main/java/com/glxp/api/handler/MybatisDmHandler.java index 465d9e19..70164084 100644 --- a/src/main/java/com/glxp/api/handler/MybatisDmHandler.java +++ b/src/main/java/com/glxp/api/handler/MybatisDmHandler.java @@ -20,11 +20,11 @@ public class MybatisDmHandler implements Interceptor { // 获取 SQL 语句 String sql = (String) metaObject.getValue("delegate.boundSql.sql"); - System.out.println("拦截到的 SQL: " + sql); +// System.out.println("拦截到的 SQL: " + sql); String processedSql = camelToSnake(sql); -// // 可在此对 SQL 进行处理,例如修改 SQL、添加日志等 + // 可在此对 SQL 进行处理,例如修改 SQL、添加日志等 // String processedSql = sql.toUpperCase(); - System.out.println("处理后的 SQL: " + processedSql); +// System.out.println("处理后的 SQL: " + processedSql); metaObject.setValue("delegate.boundSql.sql", processedSql); // 继续执行原方法 @@ -42,8 +42,8 @@ public class MybatisDmHandler implements Interceptor { // 可在此设置拦截器的属性 } public String camelToSnake(String camelCase) { - // 使用正则表达式替换大写字母为下划线加小写字母 - return camelCase.replaceAll("(?<=[a-z])([A-Z])", "_$1").toLowerCase(); + // 先去除所有反引号,再将驼峰转换为蛇形并转小写 + return camelCase.replaceAll("`", "").replaceAll("(?<=[a-z])([A-Z])", "_$1").toLowerCase(); } } diff --git a/src/main/java/com/glxp/api/service/monitor/impl/SysOperLogServiceImpl.java b/src/main/java/com/glxp/api/service/monitor/impl/SysOperLogServiceImpl.java index c864f4d0..60ab98fd 100644 --- a/src/main/java/com/glxp/api/service/monitor/impl/SysOperLogServiceImpl.java +++ b/src/main/java/com/glxp/api/service/monitor/impl/SysOperLogServiceImpl.java @@ -1,6 +1,7 @@ package com.glxp.api.service.monitor.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.IdUtil; import com.glxp.api.dao.monitor.SysOperLogMapper; import com.glxp.api.entity.monitor.OperLogDTO; import com.glxp.api.entity.monitor.SysOperLog; @@ -56,6 +57,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService, OperLogService @Override public void insertOperlog(SysOperLog operLog) { operLog.setOperTime(new Date()); + operLog.setOperId(IdUtil.getSnowflakeNextId()); baseMapper.insert(operLog); } diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 724139e7..148f77b9 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -3,9 +3,9 @@ server: spring: datasource: driver-class-name: dm.jdbc.driver.DmDriver - jdbc-url: jdbc:dm://127.0.0.1:5236/UDI_SPMS_DM?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&useSSL=false + jdbc-url: jdbc:dm://127.0.0.1:5236/UDI_SPMS_DM?CHARSET=UTF8&COLLATION_CONNECTION=utf8_general_ci username: SYSDBA - password: Wykj@6066 + password: Chc180069 hikari: connection-timeout: 60000 maximum-pool-size: 60 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 1a9ae623..0f022fb6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -10,12 +10,17 @@ spring: location: D:/tmp mybatis-plus: mapper-locations: classpath:mybatis/mapper/*/*.xml + global-config: + db-config: + column-underline: false # 开启驼峰转下划线 + capital-mode: true # 开启强制大写(字段名全大写) configuration: use-generated-keys: true use-column-label: true - map-underscore-to-camel-case: false + map-underscore-to-camel-case: true # 关闭 MyBatis 原生驼峰映射 log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + pagehelper: helperDialect: mysql support-methods-arguments: false diff --git a/src/main/resources/mybatis/mapper/auth/AuthAdminDao.xml b/src/main/resources/mybatis/mapper/auth/AuthAdminDao.xml index 4c97ea56..239c8925 100644 --- a/src/main/resources/mybatis/mapper/auth/AuthAdminDao.xml +++ b/src/main/resources/mybatis/mapper/auth/AuthAdminDao.xml @@ -45,7 +45,7 @@