diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java
index b51a838c69..d6051e85fe 100644
--- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/DateUtils.java
@@ -74,30 +74,30 @@ public class DateUtils {
* 创建指定时间
*
* @param year 年
- * @param mouth 月
+ * @param month 月
* @param day 日
* @return 指定时间
*/
- public static Date buildTime(int year, int mouth, int day) {
- return buildTime(year, mouth, day, 0, 0, 0);
+ public static Date buildTime(int year, int month, int day) {
+ return buildTime(year, month, day, 0, 0, 0);
}
/**
* 创建指定时间
*
* @param year 年
- * @param mouth 月
+ * @param month 月
* @param day 日
* @param hour 小时
* @param minute 分钟
* @param second 秒
* @return 指定时间
*/
- public static Date buildTime(int year, int mouth, int day,
+ public static Date buildTime(int year, int month, int day,
int hour, int minute, int second) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
- calendar.set(Calendar.MONTH, mouth - 1);
+ calendar.set(Calendar.MONTH, month - 1);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, hour);
calendar.set(Calendar.MINUTE, minute);
diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
index 8d18479c81..26b3961685 100644
--- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
+++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
@@ -69,17 +69,17 @@ public class LocalDateTimeUtils {
* 创建指定时间
*
* @param year 年
- * @param mouth 月
+ * @param month 月
* @param day 日
* @return 指定时间
*/
- public static LocalDateTime buildTime(int year, int mouth, int day) {
- return LocalDateTime.of(year, mouth, day, 0, 0, 0);
+ public static LocalDateTime buildTime(int year, int month, int day) {
+ return LocalDateTime.of(year, month, day, 0, 0, 0);
}
- public static LocalDateTime[] buildBetweenTime(int year1, int mouth1, int day1,
- int year2, int mouth2, int day2) {
- return new LocalDateTime[]{buildTime(year1, mouth1, day1), buildTime(year2, mouth2, day2)};
+ public static LocalDateTime[] buildBetweenTime(int year1, int month1, int day1,
+ int year2, int month2, int day2) {
+ return new LocalDateTime[]{buildTime(year1, month1, day1), buildTime(year2, month2, day2)};
}
/**
diff --git a/yudao-framework/yudao-spring-boot-starter-excel/pom.xml b/yudao-framework/yudao-spring-boot-starter-excel/pom.xml
index 0413986a64..0316c62e50 100644
--- a/yudao-framework/yudao-spring-boot-starter-excel/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-excel/pom.xml
@@ -46,6 +46,12 @@
easyexcel
+
+ jakarta.validation
+ jakarta.validation-api
+ provided
+
+
com.google.guava
guava
diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/core/DictFrameworkUtils.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/core/DictFrameworkUtils.java
index 9fc67bfe7f..2a2350f02b 100644
--- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/core/DictFrameworkUtils.java
+++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/core/DictFrameworkUtils.java
@@ -76,4 +76,9 @@ public class DictFrameworkUtils {
return dictData!= null ? dictData.getValue(): null;
}
+ @SneakyThrows
+ public static List getDictDataValueList(String dictType) {
+ List dictDatas = GET_DICT_DATA_CACHE.get(dictType);
+ return convertList(dictDatas, DictDataRespDTO::getValue);
+ }
}
diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDict.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDict.java
new file mode 100644
index 0000000000..dab0af782f
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDict.java
@@ -0,0 +1,38 @@
+package cn.iocoder.yudao.framework.dict.validation;
+
+import jakarta.validation.Constraint;
+import jakarta.validation.Payload;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({
+ ElementType.METHOD,
+ ElementType.FIELD,
+ ElementType.ANNOTATION_TYPE,
+ ElementType.CONSTRUCTOR,
+ ElementType.PARAMETER,
+ ElementType.TYPE_USE
+})
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@Constraint(
+ validatedBy = {InDictValidator.class, InDictCollectionValidator.class}
+)
+public @interface InDict {
+
+ /**
+ * 数据字典type
+ */
+ String type();
+
+ String message() default "必须在指定范围 {value}";
+
+ Class>[] groups() default {};
+
+ Class extends Payload>[] payload() default {};
+
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDictCollectionValidator.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDictCollectionValidator.java
new file mode 100644
index 0000000000..ab036171e2
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDictCollectionValidator.java
@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.framework.dict.validation;
+
+import cn.iocoder.yudao.framework.common.util.string.StrUtils;
+import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
+import jakarta.validation.ConstraintValidator;
+import jakarta.validation.ConstraintValidatorContext;
+
+import java.util.Collection;
+import java.util.List;
+
+public class InDictCollectionValidator implements ConstraintValidator> {
+
+ private String dictType;
+
+ @Override
+ public void initialize(InDict annotation) {
+ this.dictType = annotation.type();
+ }
+
+ @Override
+ public boolean isValid(Collection> list, ConstraintValidatorContext context) {
+ if (list == null) {
+ return true;
+ }
+ List dbValues = DictFrameworkUtils.getDictDataValueList(dictType);
+ boolean match = list.stream().allMatch(v -> dbValues.stream()
+ .anyMatch(dbValue -> dbValue.equalsIgnoreCase(v.toString())));
+ if (match) {
+ return true;
+ }
+ // 校验不通过,自定义提示语句
+ context.disableDefaultConstraintViolation(); // 禁用默认的 message 的值
+ context.buildConstraintViolationWithTemplate(
+ context.getDefaultConstraintMessageTemplate().replaceAll("\\{value}",dbValues.toString())
+ ).addConstraintViolation(); // 重新添加错误提示语句
+ return false;
+ }
+
+}
+
diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDictValidator.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDictValidator.java
new file mode 100644
index 0000000000..05f50cb839
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/dict/validation/InDictValidator.java
@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.framework.dict.validation;
+
+import cn.iocoder.yudao.framework.common.util.string.StrUtils;
+import cn.iocoder.yudao.framework.dict.core.DictFrameworkUtils;
+import jakarta.validation.ConstraintValidator;
+import jakarta.validation.ConstraintValidatorContext;
+
+import java.util.List;
+
+public class InDictValidator implements ConstraintValidator {
+
+ private String dictType;
+
+ @Override
+ public void initialize(InDict annotation) {
+ this.dictType = annotation.type();
+ }
+
+ @Override
+ public boolean isValid(Object value, ConstraintValidatorContext context) {
+ // 为空时,默认不校验,即认为通过
+ if (value == null) {
+ return true;
+ }
+ // 校验通过
+ final List values = DictFrameworkUtils.getDictDataValueList(dictType);
+ boolean match = values.stream().anyMatch(v -> v.equalsIgnoreCase(value.toString()));
+ if (match) {
+ return true;
+ }
+ // 校验不通过,自定义提示语句
+ context.disableDefaultConstraintViolation(); // 禁用默认的 message 的值
+ context.buildConstraintViolationWithTemplate(
+ context.getDefaultConstraintMessageTemplate().replaceAll("\\{value}", values.toString())
+ ).addConstraintViolation(); // 重新添加错误提示语句
+ return false;
+ }
+
+}
+
diff --git a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/filter/CacheRequestBodyFilter.java b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/filter/CacheRequestBodyFilter.java
index 09ffbbcc4f..6ddca049e0 100644
--- a/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/filter/CacheRequestBodyFilter.java
+++ b/yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/web/core/filter/CacheRequestBodyFilter.java
@@ -23,7 +23,7 @@ public class CacheRequestBodyFilter extends OncePerRequestFilter {
* 1. 排除 Spring Boot Admin 相关请求,避免客户端连接中断导致的异常。
* 例如说:795 ISSUE
*/
- private static final String[] IGNORE_URIS = {"/admin", "/actuator"};
+ private static final String[] IGNORE_URIS = {"/admin/", "/actuator/"};
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
@@ -35,7 +35,7 @@ public class CacheRequestBodyFilter extends OncePerRequestFilter {
protected boolean shouldNotFilter(HttpServletRequest request) {
// 1. 校验是否为排除的 URL
String requestURI = request.getRequestURI();
- if (StrUtil.containsAny(requestURI, IGNORE_URIS)) {
+ if (StrUtil.startWithAny(requestURI, IGNORE_URIS)) {
return true;
}