refactor(menu):优化菜单排序逻辑并移除未使用导入
- 移除未使用的 Collectors 导入 - 修改菜单排序逻辑,先按父菜单 ID 升序,再按排序号升序 - 删除冗余的字典加载到 Redis 的方法实现
Showing
2 changed files
with
1 additions
and
29 deletions
| ... | @@ -11,7 +11,6 @@ import org.springframework.stereotype.Service; | ... | @@ -11,7 +11,6 @@ import org.springframework.stereotype.Service; |
| 11 | 11 | ||
| 12 | import java.util.ArrayList; | 12 | import java.util.ArrayList; |
| 13 | import java.util.List; | 13 | import java.util.List; |
| 14 | -import java.util.stream.Collectors; | ||
| 15 | 14 | ||
| 16 | /** | 15 | /** |
| 17 | * 系统菜单Service实现类 | 16 | * 系统菜单Service实现类 |
| ... | @@ -77,7 +76,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl | ... | @@ -77,7 +76,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl |
| 77 | wrapper.eq(SysMenu::getDelFlag, "0"); | 76 | wrapper.eq(SysMenu::getDelFlag, "0"); |
| 78 | 77 | ||
| 79 | // 排序:按父菜单ID和排序号升序 | 78 | // 排序:按父菜单ID和排序号升序 |
| 80 | - wrapper.orderByAsc(SysMenu::getParentId, SysMenu::getSort); | 79 | + wrapper.orderByAsc(SysMenu::getParentId).orderByAsc(SysMenu::getSort); |
| 81 | 80 | ||
| 82 | return wrapper; | 81 | return wrapper; |
| 83 | } | 82 | } | ... | ... |
| ... | @@ -198,33 +198,6 @@ public class DictValueConverter { | ... | @@ -198,33 +198,6 @@ public class DictValueConverter { |
| 198 | } | 198 | } |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | - /** | ||
| 202 | - * 加载指定字典类型到Redis | ||
| 203 | - */ | ||
| 204 | - private static void loadDictToRedis(String dictType) { | ||
| 205 | - if (staticDictItemService == null) { | ||
| 206 | - return; | ||
| 207 | - } | ||
| 208 | - | ||
| 209 | - try { | ||
| 210 | - // 根据字典类型获取字典项 | ||
| 211 | - List<SysDictItem> dictItems = staticDictItemService.getDictItemsByType(dictType); | ||
| 212 | - | ||
| 213 | - Map<String, String> mapping = new HashMap<>(); | ||
| 214 | - for (SysDictItem item : dictItems) { | ||
| 215 | - if (item.getDelFlag() == null || "0".equals(item.getDelFlag())) { | ||
| 216 | - mapping.put(item.getDictValue(), item.getDictLabel()); | ||
| 217 | - } | ||
| 218 | - } | ||
| 219 | - | ||
| 220 | - // 存储到Redis | ||
| 221 | - String cacheKey = DICT_CACHE_PREFIX + dictType; | ||
| 222 | - staticRedisTemplate.opsForValue().set(cacheKey, mapping, CACHE_EXPIRE_HOURS, TimeUnit.HOURS); | ||
| 223 | - | ||
| 224 | - } catch (Exception e) { | ||
| 225 | - System.err.println("加载字典到Redis失败: " + e.getMessage()); | ||
| 226 | - } | ||
| 227 | - } | ||
| 228 | 201 | ||
| 229 | /** | 202 | /** |
| 230 | * 根据字典类型ID获取字典类型编码 | 203 | * 根据字典类型ID获取字典类型编码 | ... | ... |
-
Please register or login to post a comment