diff --git a/common/service-utils/pom.xml b/common/service-utils/pom.xml
index 23a0cf0..9131699 100644
--- a/common/service-utils/pom.xml
+++ b/common/service-utils/pom.xml
@@ -40,11 +40,26 @@
redisson
3.26.1
+
+
+ io.minio
+ minio
+
org.lionsoul
ip2region
2.6.5
+
+
+ org.springframework
+ spring-websocket
+
+
+
+ org.springframework.boot
+ spring-boot-starter-mail
+
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/MyBatisPlusFieldConfig.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/MyBatisPlusFieldConfig.java
index d32b125..b441e16 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/config/MyBatisPlusFieldConfig.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/MyBatisPlusFieldConfig.java
@@ -19,12 +19,12 @@ public class MyBatisPlusFieldConfig implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
// 设置属性值
+ this.strictInsertFill(metaObject, "isDeleted", Integer.class, 0);
this.setFieldValByName("createTime", new Date(), metaObject);
this.setFieldValByName("updateTime", new Date(), metaObject);
- this.setFieldValByName("deleteStatus", 1, metaObject);
if (BaseContext.getUsername() != null) {
- this.setFieldValByName("createBy", BaseContext.getUsername(), metaObject);
- this.setFieldValByName("updateBy", BaseContext.getUsername(), metaObject);
+ this.setFieldValByName("createUser", BaseContext.getUsername(), metaObject);
+ this.setFieldValByName("updateUser", BaseContext.getUsername(), metaObject);
}
}
@@ -33,7 +33,9 @@ public class MyBatisPlusFieldConfig implements MetaObjectHandler {
*/
@Override
public void updateFill(MetaObject metaObject) {
- this.setFieldValByName("updateTime", new Date(), metaObject);
- this.setFieldValByName("updateBy", BaseContext.getUsername(), metaObject);
+ if (BaseContext.getUserId() != null) {
+ this.setFieldValByName("updateTime", new Date(), metaObject);
+ this.setFieldValByName("updateUser", BaseContext.getUsername(), metaObject);
+ }
}
}
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java b/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java
index c82936b..0c67fee 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/config/RedisConfiguration.java
@@ -45,11 +45,14 @@ public class RedisConfiguration {
redisTemplate.setConnectionFactory(connectionFactory);
// 设置key序列化为string
redisTemplate.setKeySerializer(new StringRedisSerializer());
+
// 设置value序列化为JSON,使用GenericJackson2JsonRedisSerializer替换默认序列化
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer());
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
+ // 开启Redis事务
+ redisTemplate.setEnableTransactionSupport(true);
return redisTemplate;
}
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/context/BaseContext.java b/common/service-utils/src/main/java/cn/bunny/common/service/context/BaseContext.java
index aaae16c..afb5454 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/context/BaseContext.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/context/BaseContext.java
@@ -1,12 +1,10 @@
package cn.bunny.common.service.context;
-import cn.bunny.vo.system.login.LoginVo;
+import cn.bunny.vo.user.LoginVo;
public class BaseContext {
private static final ThreadLocal userId = new ThreadLocal<>();
private static final ThreadLocal username = new ThreadLocal();
- private static final ThreadLocal adminId = new ThreadLocal<>();
- private static final ThreadLocal adminName = new ThreadLocal<>();
private static final ThreadLocal loginVo = new ThreadLocal<>();
// 用户id相关
@@ -39,26 +37,4 @@ public class BaseContext {
userId.remove();
loginVo.remove();
}
-
- // adminId 相关
- public static Long getAdminId() {
- return adminId.get();
- }
-
- public static void setAdminId(Long _adminId) {
- adminId.set(_adminId);
- }
-
- public static String getAdminName() {
- return adminName.get();
- }
-
- public static void setAdminName(String _adminName) {
- adminName.set(_adminName);
- }
-
- public static void removeAdmin() {
- adminName.remove();
- adminId.remove();
- }
}
\ No newline at end of file
diff --git a/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java b/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
index 30ec51c..14532e6 100644
--- a/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
+++ b/common/service-utils/src/main/java/cn/bunny/common/service/exception/GlobalExceptionHandler.java
@@ -1,10 +1,12 @@
package cn.bunny.common.service.exception;
+import cn.bunny.pojo.constant.ExceptionConstant;
import cn.bunny.pojo.result.Result;
import cn.bunny.pojo.result.ResultCodeEnum;
-import cn.bunny.pojo.result.constant.ExceptionConstant;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.support.DefaultMessageSourceResolvable;
+import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -12,6 +14,9 @@ import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.io.FileNotFoundException;
import java.nio.file.AccessDeniedException;
import java.sql.SQLIntegrityConstraintViolationException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
@RestControllerAdvice
@Slf4j
@@ -32,18 +37,42 @@ public class GlobalExceptionHandler {
public Result