浏览代码

菜单的小优化

xiaochan 1 年之前
父节点
当前提交
c77d9bf97c

+ 0 - 6
src/main/java/thyyxxk/webserver/dao/his/settings/MenuSettingsDao.java

@@ -12,10 +12,4 @@ public interface MenuSettingsDao extends BaseMapper<IntergrationMenu> {
 
     @Select("select * from t_intergration_menu order by type , sort  ")
     List<IntergrationMenu> getAll();
-
-
-
-    @Select("select * from yz_act_order where inpatient_no = '023594' and admiss_times = 6 and enter_oper = '02896'")
-    List<Object> test();
-
 }

+ 5 - 5
src/main/java/thyyxxk/webserver/service/settings/MenuSettingsService.java

@@ -1,6 +1,5 @@
 package thyyxxk.webserver.service.settings;
 
-import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
@@ -13,7 +12,7 @@ import thyyxxk.webserver.entity.settings.IntergrationMenu;
 import thyyxxk.webserver.entity.settings.IntergrationPlatformRoleMenu;
 import thyyxxk.webserver.service.RedisServer;
 import thyyxxk.webserver.service.redislike.RedisLikeService;
-import thyyxxk.webserver.utils.DynamicDataUtils;
+import thyyxxk.webserver.utils.DynamicDataUtil;
 import thyyxxk.webserver.utils.ResultVoUtil;
 import thyyxxk.webserver.utils.TokenUtil;
 import thyyxxk.webserver.utils.TreeUtil;
@@ -34,7 +33,9 @@ public class MenuSettingsService {
     @Value("${spring.datasource.dynamic.primary}")
     private String currentDbName = "";
 
-    public MenuSettingsService(MenuSettingsDao dao, RedisServer redisServer, RedisLikeService redisLikeService) {
+    public MenuSettingsService(MenuSettingsDao dao,
+                               RedisServer redisServer,
+                               RedisLikeService redisLikeService) {
         this.dao = dao;
         this.redisServer = redisServer;
         this.redisLikeService = redisLikeService;
@@ -43,7 +44,7 @@ public class MenuSettingsService {
     public void menuPushRedis() {
         String redisProdUrl = "172.16.32.167";
         String dbName = redisProdUrl.equals(redisUrl) ? "his" : currentDbName;
-        List<IntergrationMenu> list = DynamicDataUtils.changeByName(dbName, dao::getAll);
+        List<IntergrationMenu> list = DynamicDataUtil.db(dbName, dao::getAll);
         redisServer.setData("IntergrationPlatformMenu", list);
     }
 
@@ -122,7 +123,6 @@ public class MenuSettingsService {
         return menuListByTree(passRule);
     }
 
-
     public ResultVo<String> updateMenuSettings(IntergrationMenu menuList) {
         if (menuList.getId() == null) {
             dao.insert(menuList);

+ 3 - 5
src/main/java/thyyxxk/webserver/utils/DynamicDataUtils.java → src/main/java/thyyxxk/webserver/utils/DynamicDataUtil.java

@@ -1,15 +1,13 @@
 package thyyxxk.webserver.utils;
 
-
 import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
 
 import java.util.function.Supplier;
 
+public class DynamicDataUtil {
 
-public class DynamicDataUtils {
-
-    public static <T> T changeByName(String name, Supplier<T> supplier) {
-        DynamicDataSourceContextHolder.push(name);
+    public static <T> T db(String dbName, Supplier<T> supplier) {
+        DynamicDataSourceContextHolder.push(dbName);
         try {
             return supplier.get();
         } finally {