timedCache() {
+ // 创建定时缓存,缓存时间与JWT过期时间一致
+ return CacheUtil.newTimedCache(jwtExpirationMs);
+ }
+
/**
* 静态资源处理
*/
@@ -20,9 +36,9 @@ public class WebConfig implements WebMvcConfigurer {
// Swagger UI 静态资源
registry.addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/swagger-ui/");
-
+
// 其他静态资源
registry.addResourceHandler("/static/**")
.addResourceLocations("classpath:/static/");
}
-}
\ No newline at end of file
+}
diff --git a/backend/src/main/java/com/stdproject/controller/AppDictionaryController.java b/backend/src/main/java/com/stdproject/controller/AppDictionaryController.java
index bbce2a5..8f55c14 100644
--- a/backend/src/main/java/com/stdproject/controller/AppDictionaryController.java
+++ b/backend/src/main/java/com/stdproject/controller/AppDictionaryController.java
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.List;
+import java.util.Map;
/**
*
@@ -41,7 +42,7 @@ public class AppDictionaryController {
public Result> page(@RequestBody @Valid PageRequest pageRequest) {
Page page = new Page<>(pageRequest.getCurrent(), pageRequest.getSize());
QueryWrapper queryWrapper = new QueryWrapper<>();
-
+
// 关键字搜索
if (StringUtils.hasText(pageRequest.getKeyword())) {
queryWrapper.and(wrapper -> wrapper
@@ -50,7 +51,7 @@ public class AppDictionaryController {
.or().like("dictdata", pageRequest.getKeyword())
);
}
-
+
// 排序
if (StringUtils.hasText(pageRequest.getOrderBy())) {
if ("asc".equalsIgnoreCase(pageRequest.getOrderDirection())) {
@@ -61,7 +62,7 @@ public class AppDictionaryController {
} else {
queryWrapper.orderByAsc("dictcode", "orderno");
}
-
+
IPage result = appDictionaryService.page(page, queryWrapper);
return Result.success(result);
}
@@ -72,7 +73,7 @@ public class AppDictionaryController {
public Result> list() {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.orderByAsc("dictcode", "orderno");
-
+
List dictionaries = appDictionaryService.list(queryWrapper);
return Result.success(dictionaries);
}
@@ -92,7 +93,7 @@ public class AppDictionaryController {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("dictcode", dictCode);
queryWrapper.orderByAsc("orderno");
-
+
List dictionaries = appDictionaryService.list(queryWrapper);
return Result.success(dictionaries);
}
@@ -106,7 +107,7 @@ public class AppDictionaryController {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("dictcode", dictCode);
queryWrapper.eq("dictdata", dictData);
-
+
AppDictionary dictionary = appDictionaryService.getOne(queryWrapper);
return Result.success(dictionary);
}
@@ -123,18 +124,18 @@ public class AppDictionaryController {
if (existDictionary != null) {
return Result.error("该字典编码下的字典值已存在");
}
-
+
// 设置默认值
if (appDictionary.getOrderno() == null) {
// 获取同一字典编码下的最大序号
QueryWrapper orderQuery = new QueryWrapper<>();
- orderQuery.eq("dictcode", appDictionary.getDictcode());
+ orderQuery.eq("app_id", appDictionary.getAppId());
orderQuery.orderByDesc("orderno");
orderQuery.last("LIMIT 1");
AppDictionary lastDict = appDictionaryService.getOne(orderQuery);
appDictionary.setOrderno(lastDict != null ? lastDict.getOrderno() + 1 : 1);
}
-
+
appDictionary.setLastmodifydate(LocalDateTime.now());
boolean success = appDictionaryService.save(appDictionary);
return success ? Result.success("新增成功") : Result.error("新增失败");
@@ -149,7 +150,7 @@ public class AppDictionaryController {
if (existDictionary == null) {
return Result.error("数据字典不存在");
}
-
+
// 如果修改了字典编码或字典值,检查新的组合是否已被其他字典项使用
if (!existDictionary.getDictcode().equals(appDictionary.getDictcode()) ||
!existDictionary.getDictdata().equals(appDictionary.getDictdata())) {
@@ -162,7 +163,7 @@ public class AppDictionaryController {
return Result.error("该字典编码下的字典数据已被其他字典项使用");
}
}
-
+
appDictionary.setLastmodifydate(LocalDateTime.now());
boolean success = appDictionaryService.updateById(appDictionary);
return success ? Result.success("修改成功") : Result.error("修改失败");
@@ -190,7 +191,7 @@ public class AppDictionaryController {
public Result deleteByDictCode(@Parameter(description = "字典编码") @PathVariable String dictCode) {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("dictcode", dictCode);
-
+
boolean success = appDictionaryService.remove(queryWrapper);
return success ? Result.success("删除成功") : Result.error("删除失败");
}
@@ -202,7 +203,7 @@ public class AppDictionaryController {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.eq("dictname", dictName);
AppDictionary dictionary = appDictionaryService.getOne(queryWrapper);
-
+
if (dictionary != null) {
return Result.success(dictionary.getDictdata());
}
@@ -216,13 +217,13 @@ public class AppDictionaryController {
QueryWrapper queryWrapper = new QueryWrapper<>();
queryWrapper.select("DISTINCT dictcode");
queryWrapper.orderByAsc("dictcode");
-
+
List dictionaries = appDictionaryService.list(queryWrapper);
List dictCodes = dictionaries.stream()
.map(AppDictionary::getDictcode)
.distinct()
.collect(java.util.stream.Collectors.toList());
-
+
return Result.success(dictCodes);
}
@@ -244,14 +245,14 @@ public class AppDictionaryController {
@Operation(summary = "根据字典编码分组查询字典项")
@GetMapping("/grouped")
@OperationLog(type = "06", module = "数据字典管理", description = "根据字典编码分组查询字典项")
- public Result>> getGroupedDictionaries() {
+ public Result