|
|
@@ -3,6 +3,7 @@ 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;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import thyyxxk.webserver.config.exception.ExceptionEnum;
|
|
|
import thyyxxk.webserver.dao.his.settings.MenuSettingsDao;
|
|
|
@@ -12,31 +13,38 @@ 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.ResultVoUtil;
|
|
|
import thyyxxk.webserver.utils.TokenUtil;
|
|
|
import thyyxxk.webserver.utils.TreeUtil;
|
|
|
|
|
|
-import javax.annotation.PostConstruct;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class MenuSettingsService {
|
|
|
-
|
|
|
private final MenuSettingsDao dao;
|
|
|
private final RedisServer redisServer;
|
|
|
private final RedisLikeService redisLikeService;
|
|
|
|
|
|
+ @Value("${spring.redis.host}")
|
|
|
+ private String redisUrl = "";
|
|
|
+
|
|
|
+ @Value("${spring.datasource.dynamic.primary}")
|
|
|
+ private String currentDbName = "";
|
|
|
+
|
|
|
public MenuSettingsService(MenuSettingsDao dao, RedisServer redisServer, RedisLikeService redisLikeService) {
|
|
|
this.dao = dao;
|
|
|
this.redisServer = redisServer;
|
|
|
this.redisLikeService = redisLikeService;
|
|
|
}
|
|
|
|
|
|
- @DS("his")
|
|
|
public void menuPushRedis() {
|
|
|
- redisServer.setData("IntergrationPlatformMenu", dao.getAll());
|
|
|
+ String redisProdUrl = "172.16.32.167";
|
|
|
+ String dbName = redisProdUrl.equals(redisUrl) ? "his" : currentDbName;
|
|
|
+ List<IntergrationMenu> list = DynamicDataUtils.changeByName(dbName, dao::getAll);
|
|
|
+ redisServer.setData("IntergrationPlatformMenu", list);
|
|
|
}
|
|
|
|
|
|
public List<IntergrationMenu> getMenuSettings() {
|
|
|
@@ -52,7 +60,7 @@ public class MenuSettingsService {
|
|
|
}
|
|
|
|
|
|
private List<IntergrationMenu> menuListByTree(List<IntergrationMenu> list) {
|
|
|
- List<IntergrationMenu> res = TreeUtil.ObjectTree(list, (parent, child) -> {
|
|
|
+ List<IntergrationMenu> res = TreeUtil.objectTree(list, (parent, child) -> {
|
|
|
if (parent == null) {
|
|
|
child.setCompletePath(child.getPath());
|
|
|
} else {
|
|
|
@@ -61,7 +69,7 @@ public class MenuSettingsService {
|
|
|
child.setCompletePath(parent.getCompletePath() + "/" + child.getPath());
|
|
|
}
|
|
|
});
|
|
|
- return TreeUtil.ObjectSort(res, "sort");
|
|
|
+ return TreeUtil.objectSort(res, "sort");
|
|
|
}
|
|
|
|
|
|
private List<IntergrationMenu> findParentMenus(List<IntergrationMenu> list, IntergrationMenu item) {
|