jiaxing.zhou

refactor(menu):优化菜单排序逻辑并移除未使用导入

- 移除未使用的 Collectors 导入
- 修改菜单排序逻辑,先按父菜单 ID 升序,再按排序号升序
- 删除冗余的字典加载到 Redis 的方法实现
......@@ -11,7 +11,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* 系统菜单Service实现类
......@@ -77,7 +76,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
wrapper.eq(SysMenu::getDelFlag, "0");
// 排序:按父菜单ID和排序号升序
wrapper.orderByAsc(SysMenu::getParentId, SysMenu::getSort);
wrapper.orderByAsc(SysMenu::getParentId).orderByAsc(SysMenu::getSort);
return wrapper;
}
......
......@@ -198,33 +198,6 @@ public class DictValueConverter {
}
}
/**
* 加载指定字典类型到Redis
*/
private static void loadDictToRedis(String dictType) {
if (staticDictItemService == null) {
return;
}
try {
// 根据字典类型获取字典项
List<SysDictItem> dictItems = staticDictItemService.getDictItemsByType(dictType);
Map<String, String> mapping = new HashMap<>();
for (SysDictItem item : dictItems) {
if (item.getDelFlag() == null || "0".equals(item.getDelFlag())) {
mapping.put(item.getDictValue(), item.getDictLabel());
}
}
// 存储到Redis
String cacheKey = DICT_CACHE_PREFIX + dictType;
staticRedisTemplate.opsForValue().set(cacheKey, mapping, CACHE_EXPIRE_HOURS, TimeUnit.HOURS);
} catch (Exception e) {
System.err.println("加载字典到Redis失败: " + e.getMessage());
}
}
/**
* 根据字典类型ID获取字典类型编码
......