|
@@ -1,8 +1,8 @@
|
|
|
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,28 +12,41 @@ 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.DynamicDataUtil;
|
|
|
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;
|
|
|
|
|
|
- public MenuSettingsService(MenuSettingsDao dao, RedisServer redisServer, 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;
|
|
|
}
|
|
|
|
|
|
+ public void menuPushRedis() {
|
|
|
+ String redisProdUrl = "172.16.32.167";
|
|
|
+ String dbName = redisProdUrl.equals(redisUrl) ? "his" : currentDbName;
|
|
|
+ List<IntergrationMenu> list = DynamicDataUtil.db(dbName, dao::getAll);
|
|
|
+ redisServer.setData("IntergrationPlatformMenu", list);
|
|
|
+ }
|
|
|
|
|
|
public List<IntergrationMenu> getMenuSettings() {
|
|
|
return menuListByTree(dao.getAll());
|
|
@@ -48,7 +61,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 {
|
|
@@ -57,7 +70,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) {
|
|
@@ -110,7 +123,6 @@ public class MenuSettingsService {
|
|
|
return menuListByTree(passRule);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public ResultVo<String> updateMenuSettings(IntergrationMenu menuList) {
|
|
|
if (menuList.getId() == null) {
|
|
|
dao.insert(menuList);
|