diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 05e5c200a4..89e8a70ab3 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -101,7 +101,7 @@ public class RedisKeys { * epmet:sys:security:user:token字符串 */ public static String getCpUserKey(String app, String client, String userId) { - return rootPrefix.concat("sys:security:user:").concat(app).concat(":").concat(client).concat(":").concat(userId); + return rootPrefix.concat("sys:security:user:").concat(app).concat(StrConstant.COLON).concat(client).concat(StrConstant.COLON).concat(userId); } /** @@ -200,7 +200,7 @@ public class RedisKeys { * @return */ public static String getRoleOpeScopesKey(String roleId, String opeKey) { - return rootPrefix.concat("gov:access:role:opescopes:").concat(roleId).concat(":").concat(opeKey); + return rootPrefix.concat("gov:access:role:opescopes:").concat(roleId).concat(StrConstant.COLON).concat(opeKey); } /** @@ -338,7 +338,7 @@ public class RedisKeys { * @return */ public static String getCustomerStatsCalFlag(String customerId) { - return getCustomerStatsCalKeyPrefix().concat(":").concat(customerId); + return getCustomerStatsCalKeyPrefix().concat(StrConstant.COLON).concat(customerId); } /** @@ -364,7 +364,7 @@ public class RedisKeys { * @return */ public static String getCustomerFootbarKey(String customerId, String appType) { - return rootPrefix.concat("footbar").concat(":").concat(customerId).concat(":").concat(appType); + return rootPrefix.concat("footbar").concat(StrConstant.COLON).concat(customerId).concat(StrConstant.COLON).concat(appType); } @@ -397,7 +397,7 @@ public class RedisKeys { * @date 2020.11.05 13:34 */ public static String getResiUserBadgeKey(String customerId, String userId) { - return rootPrefix.concat("badge:user:").concat(customerId).concat(":").concat(StringUtils.isBlank(userId) ? "*" : userId); + return rootPrefix.concat("badge:user:").concat(customerId).concat(StrConstant.COLON).concat(StringUtils.isBlank(userId) ? "*" : userId); } /** @@ -483,7 +483,7 @@ public class RedisKeys { **/ public static String getGroupMsgReadKey(String source, String groupId, String sourceId) { String currentMonth= DateUtils.getBeforeNMonth(NumConstant.ZERO); - return "groupread:".concat(currentMonth).concat(":").concat(source).concat(":").concat(groupId).concat(":").concat(sourceId); + return "groupread:".concat(currentMonth).concat(StrConstant.COLON).concat(source).concat(StrConstant.COLON).concat(groupId).concat(StrConstant.COLON).concat(sourceId); } /** @@ -497,7 +497,7 @@ public class RedisKeys { **/ public static String getGroupMsgShouldReadUser(String source, String groupId, String sourceId) { String currentMonth= DateUtils.getBeforeNMonth(NumConstant.ZERO); - return "groupread:user:".concat(currentMonth).concat(":").concat(source).concat(":").concat(groupId).concat(":").concat(sourceId); + return "groupread:user:".concat(currentMonth).concat(StrConstant.COLON).concat(source).concat(StrConstant.COLON).concat(groupId).concat(StrConstant.COLON).concat(sourceId); } /** @@ -560,7 +560,7 @@ public class RedisKeys { * @date 2021.09.23 17:38:37 */ public static String getQuestionnaireAccessKey(String userId, String qKey) { - return rootPrefix.concat("questionnaire:accesskey:").concat(userId).concat(":").concat(qKey); + return rootPrefix.concat("questionnaire:accesskey:").concat(userId).concat(StrConstant.COLON).concat(qKey); } /** @@ -594,7 +594,7 @@ public class RedisKeys { * @date 2021.10.25 17:49:43 */ public static String loginTicket(String app, String ticket) { - return rootPrefix.concat("sys:security:ticket:").concat(app).concat(":").concat(ticket); + return rootPrefix.concat("sys:security:ticket:").concat(app).concat(StrConstant.COLON).concat(ticket); } /** @@ -649,7 +649,7 @@ public class RedisKeys { } public static String getHouseInfoCacheKey(String houseId,String customerId){ - return rootPrefix.concat("house:").concat(customerId).concat(":").concat(houseId); + return rootPrefix.concat("house:").concat(customerId).concat(StrConstant.COLON).concat(houseId); } /** @@ -671,7 +671,7 @@ public class RedisKeys { * @return */ public static String icResiImportTypeKey(String importTag, String type) { - return icResiImportBaseKey(importTag).concat(":").concat(type); + return icResiImportBaseKey(importTag).concat(StrConstant.COLON).concat(type); } /** @@ -682,7 +682,7 @@ public class RedisKeys { * @return */ public static String icResiImportResiCategoryKey(String importTag, String type, String resiId) { - return icResiImportTypeKey(importTag, type).concat(":").concat(resiId); + return icResiImportTypeKey(importTag, type).concat(StrConstant.COLON).concat(resiId); } /** @@ -693,7 +693,7 @@ public class RedisKeys { * @date 2022/2/14 9:38 上午 */ public static String getTemporaryHouseInfoCacheKey(String customerId,String userId){ - return rootPrefix.concat("temporary:").concat("temporaryHouse:").concat(customerId).concat(":").concat(userId); + return rootPrefix.concat("temporary:").concat("temporaryHouse:").concat(customerId).concat(StrConstant.COLON).concat(userId); } /** @@ -704,7 +704,7 @@ public class RedisKeys { * @date 2022/2/14 9:38 上午 */ public static String getTemporaryGridInfoCacheKey(String customerId,String userId){ - return rootPrefix.concat("temporary:").concat("temporaryGrid:").concat(customerId).concat(":").concat(userId); + return rootPrefix.concat("temporary:").concat("temporaryGrid:").concat(customerId).concat(StrConstant.COLON).concat(userId); } /** @@ -715,7 +715,7 @@ public class RedisKeys { * @date 2022/2/14 9:39 上午 */ public static String getTemporaryNeighborHoodInfoCacheKey(String customerId,String userId){ - return rootPrefix.concat("temporary:").concat("temporaryNeighborHood:").concat(customerId).concat(":").concat(userId); + return rootPrefix.concat("temporary:").concat("temporaryNeighborHood:").concat(customerId).concat(StrConstant.COLON).concat(userId); } /** @@ -726,7 +726,7 @@ public class RedisKeys { * @date 2022/2/14 9:39 上午 */ public static String getTemporaryBuildingInfoCacheKey(String customerId,String userId){ - return rootPrefix.concat("temporary:").concat("temporaryBuilding:").concat(customerId).concat(":").concat(userId); + return rootPrefix.concat("temporary:").concat("temporaryBuilding:").concat(customerId).concat(StrConstant.COLON).concat(userId); } /** @@ -737,15 +737,15 @@ public class RedisKeys { * @date 2022/2/14 1:54 下午 */ public static String getTemporaryBuildingUnitInfoCacheKey(String customerId,String userId){ - return rootPrefix.concat("temporary:").concat("temporaryBuildingUnit:").concat(customerId).concat(":").concat(userId); + return rootPrefix.concat("temporary:").concat("temporaryBuildingUnit:").concat(customerId).concat(StrConstant.COLON).concat(userId); } public static String getTemporaryImportResultCacheKey(String customerId,String userId){ - return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId); + return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(StrConstant.COLON).concat(userId); } - public static String getCustomerMenuList(String customerId, Integer type) { - return getCustomerMenuListPrefix().concat(customerId).concat(":type:")+type; + public static String getCustomerMenuList(String customerId, Integer type, String tableName) { + return getCustomerMenuListPrefix().concat("type:").concat(type.toString()).concat(":tableName:").concat(tableName).concat(StrConstant.COLON).concat(customerId); } /** @@ -753,7 +753,7 @@ public class RedisKeys { * @return */ public static String getCustomerMenuListPrefix() { - return rootPrefix.concat("oper:access:nav:customerId:"); + return rootPrefix.concat("gov:access:nav:"); } /** diff --git a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java index fb130e9c65..91ef00b75a 100644 --- a/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java +++ b/epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java @@ -22,7 +22,6 @@ import com.epmet.dto.result.MenuResourceDTO; import lombok.Data; import java.io.Serializable; -import java.util.Date; import java.util.List; @@ -77,36 +76,6 @@ public class GovMenuDTO extends TreeStringNode implements Serializab */ private Integer sort; - /** - * 删除标识:0.未删除 1.已删除 - */ - private Integer delFlag; - - /** - * 乐观锁 - */ - private Integer revision; - - /** - * 创建人 - */ - private String createdBy; - - /** - * 创建时间 - */ - private Date createdTime; - - /** - * 更新人 - */ - private String updatedBy; - - /** - * 更新时间 - */ - private Date updatedTime; - /** * 菜单资源 */ @@ -121,4 +90,9 @@ public class GovMenuDTO extends TreeStringNode implements Serializab * 是否显示,1:显示 0不显示 */ private Integer showFlag; -} \ No newline at end of file + + /** + * 用于区分哪个端的菜单 eg:管理平台(gov_menu)、数据分析平台(data_menu) + */ + private String tableName; +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/GovMenuController.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/GovMenuController.java index d3a67c889f..20636cfc3a 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/GovMenuController.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/GovMenuController.java @@ -11,7 +11,6 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.GovMenuDTO; -import com.epmet.dto.result.MenuResourceDTO; import com.epmet.service.GovMenuService; import com.epmet.service.GovResourceService; import org.springframework.beans.factory.annotation.Autowired; @@ -45,11 +44,8 @@ public class GovMenuController { } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ - GovMenuDTO data = govMenuService.get(id); - - //菜单资源列表 - List resourceList = govResourceService.getMenuResourceList(id); + public Result get(@PathVariable("id") String id,String tableName){ + GovMenuDTO data = govMenuService.get(id,tableName); return new Result().ok(data); } @@ -101,8 +97,8 @@ public class GovMenuController { * @return Result> */ @GetMapping("list") - public Result> list(Integer type){ - List list = govMenuService.getMenuList(type); + public Result> list(Integer type,String tableName){ + List list = govMenuService.getMenuList(type,tableName); return new Result>().ok(list); } @@ -113,8 +109,8 @@ public class GovMenuController { * @return List */ @GetMapping("nav") - public Result> nav(@LoginUser TokenDto tokenDto){ - List list = govMenuService.getUserMenuNavList(tokenDto); + public Result> nav(@LoginUser TokenDto tokenDto, String tableName){ + List list = govMenuService.getUserMenuNavList(tokenDto,tableName); return new Result>().ok(list); } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/GovMenuDao.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/GovMenuDao.java index ba05556dc1..d1902baca6 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/GovMenuDao.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/GovMenuDao.java @@ -1,8 +1,8 @@ /** * Copyright (c) 2018 人人开源 All rights reserved. - * + *

* https://www.renren.io - * + *

* 版权所有,侵权必究! */ @@ -24,21 +24,22 @@ import java.util.List; @Mapper public interface GovMenuDao extends BaseDao { - GovMenuEntity getById(@Param("id") String id, @Param("language") String language); + GovMenuEntity getById(@Param("id") String id, @Param("language") String language, @Param("tableName") String tableName); /** * 查询所有菜单列表 * - * @param type 菜单类型 - * @param language 语言 + * @param type 菜单类型 + * @param language 语言 + * @param tableName */ - List getMenuList(@Param("type") Integer type, @Param("language") String language); + List getMenuList(@Param("type") Integer type, @Param("language") String language, @Param("tableName") String tableName); /** * 查询用户菜单列表 * - * @param userId 用户ID - * @param type 菜单类型 + * @param userId 用户ID + * @param type 菜单类型 * @param language 语言 */ List getUserMenuList(@Param("userId") String userId, @Param("type") Integer type, @Param("language") String language); @@ -46,7 +47,8 @@ public interface GovMenuDao extends BaseDao { /** * 根据父菜单,查询子菜单 - * @param pid 父菜单ID + * + * @param pid 父菜单ID */ List getListPid(String pid); @@ -54,8 +56,9 @@ public interface GovMenuDao extends BaseDao { * 查询客户菜单列表 * * @param customerId 客户id - * @param type 菜单类型 - * @param language 语言 + * @param type 菜单类型 + * @param language 语言 + * @param tableName */ - List getCustomerMenuList(@Param("customerId") String customerId, @Param("type") Integer type, @Param("language") String language); + List getCustomerMenuList(@Param("customerId") String customerId, @Param("type") Integer type, @Param("language") String language, @Param("tableName") String tableName); } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java index 911e42f59a..64dcb0fb1c 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java @@ -45,11 +45,12 @@ public class GovCustomerMenuRedis { * desc:保存客户菜单缓存 * @param customerId * @param type + * @param tableName * @see com.epmet.enums.MenuTypeEnum */ - public void setCustomerMenuList(String customerId, Integer type, List govMenuDTOS) { + public void setCustomerMenuList(String customerId, Integer type, List govMenuDTOS, String tableName) { if (checkParam(customerId, type) && !CollectionUtils.isEmpty(govMenuDTOS) && StringUtils.isNotBlank(govMenuDTOS.get(NumConstant.ZERO).getName())) { - String key = RedisKeys.getCustomerMenuList(customerId, type); + String key = RedisKeys.getCustomerMenuList(customerId, type, tableName); redisUtils.set(key, govMenuDTOS, RedisUtils.DEFAULT_EXPIRE); } } @@ -57,11 +58,12 @@ public class GovCustomerMenuRedis { * desc:获取客户菜单缓存 * @param customerId * @param type + * @param tableName * @see com.epmet.enums.MenuTypeEnum */ - public List getCustomerMenuList(String customerId, Integer type) { + public List getCustomerMenuList(String customerId, Integer type, String tableName) { if (checkParam(customerId, type)) { - String key = RedisKeys.getCustomerMenuList(customerId, type); + String key = RedisKeys.getCustomerMenuList(customerId, type, tableName); return (List) redisUtils.get(key); } return null; diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/GovMenuService.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/GovMenuService.java index b5c0cf12a3..0e87946dc5 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/GovMenuService.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/GovMenuService.java @@ -59,11 +59,12 @@ public interface GovMenuService extends BaseService { * 单条查询 * * @param id + * @param tableName * @return GovMenuDTO * @author generator * @date 2020-03-18 */ - GovMenuDTO get(String id); + GovMenuDTO get(String id, String tableName); /** * 默认保存 @@ -117,15 +118,17 @@ public interface GovMenuService extends BaseService { * 菜单列表 * * @param type 菜单类型 + * @param tableName */ - List getMenuList(Integer type); + List getMenuList(Integer type, String tableName); /** * 用户菜单导航 * @param tokenDto 用户信息 + * @param tableName * @return java.util.List */ - List getUserMenuNavList(TokenDto tokenDto); + List getUserMenuNavList(TokenDto tokenDto, String tableName); /** * 获取用户权限标识 @@ -141,4 +144,4 @@ public interface GovMenuService extends BaseService { List getListPid(String pid); void clearOperUserAccess(String app, String client, String userId); -} \ No newline at end of file +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java index 63bde3c678..2dbb4abe05 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java @@ -94,8 +94,9 @@ public class GovMenuServiceImpl extends BaseServiceImpl getMenuList(Integer type) { - List menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage()); + public List getMenuList(Integer type, String tableName) { + tableName = getTableName(tableName); + List menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage(), tableName); List dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); @@ -189,7 +208,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl getUserMenuNavList(TokenDto tokenDto) { + public List getUserMenuNavList(TokenDto tokenDto, String tableName) { // List menuList = govMenuRedis.getUserMenuNavList(tokenDto.getCustomerId(), tokenDto.getApp(), tokenDto.getClient()); // if(menuList == null){ // menuList = getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value()); @@ -198,7 +217,8 @@ public class GovMenuServiceImpl extends BaseServiceImpl * @Author zhangyong * @Date 15:51 2021-03-16 **/ - private List getCustomerMenuList(String customerId, Integer type) { - List govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type); + private List getCustomerMenuList(String customerId, Integer type, String tableName) { + List govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type,tableName); if (!CollectionUtils.isEmpty(govMenuDTOS)){ return govMenuDTOS; } - List menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage()); + List menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage(),tableName); List dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); govMenuDTOS = TreeUtils.buildTree(dtoList); - govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS); + govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS,tableName); return govMenuDTOS; } @@ -235,7 +256,8 @@ public class GovMenuServiceImpl extends BaseServiceImpl menuList; // if(govUserDTOResult.getData().getSuperAdmin() == SuperAdminEnum.YES.value()){ - menuList = baseDao.getMenuList(MenuTypeEnum.BUTTON.value(), HttpContextUtils.getLanguage()); + //目前不支持角色 菜单 + menuList = baseDao.getMenuList(MenuTypeEnum.BUTTON.value(), HttpContextUtils.getLanguage(), null); // }else{ // menuList = baseDao.getUserMenuList(tokenDto.getUserId(), MenuTypeEnum.BUTTON.value(), HttpContextUtils.getLanguage()); // } @@ -267,7 +289,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl select t1.*, - (select lang.field_value from gov_language lang where lang.table_name='gov_menu' and lang.field_name='name' + (select lang.field_value from gov_language lang where lang.table_name=#{tableName} and lang.field_name='name' and lang.table_id=t1.pid and lang.language=#{language}) as parentName, - (select lang.field_value from gov_language lang where lang.table_name='gov_menu' and lang.field_name='name' + (select lang.field_value from gov_language lang where lang.table_name=#{tableName} and lang.field_name='name' and lang.table_id=t1.id and lang.language=#{language}) as name from gov_menu t1 where t1.id = #{id} and t1.del_flag = 0