Browse Source

pc端菜单添加 数据分析菜单

dev
jianjun 3 years ago
parent
commit
dd5d2b94df
  1. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 5
      epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java
  3. 8
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/GovMenuController.java
  4. 25
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/dao/GovMenuDao.java
  5. 10
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java
  6. 6
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/GovMenuService.java
  7. 29
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java
  8. 4
      epmet-module/gov-access/gov-access-server/src/main/resources/mapper/GovMenuDao.xml

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -744,8 +744,8 @@ public class RedisKeys {
return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").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(customerId).concat(":type:").concat(type.toString()).concat(":tableName:").concat(tableName);
}
/**

5
epmet-module/gov-access/gov-access-client/src/main/java/com/epmet/dto/GovMenuDTO.java

@ -121,4 +121,9 @@ public class GovMenuDTO extends TreeStringNode<GovMenuDTO> implements Serializab
* 是否显示1显示 0不显示
*/
private Integer showFlag;
/**
* 用于区分哪个端的菜单 eg:管理平台(gov_menu)数据分析平台(data_menu)
*/
private String tableName;
}

8
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/controller/GovMenuController.java

@ -101,8 +101,8 @@ public class GovMenuController {
* @return Result<List<GovMenuDTO>>
*/
@GetMapping("list")
public Result<List<GovMenuDTO>> list(Integer type){
List<GovMenuDTO> list = govMenuService.getMenuList(type);
public Result<List<GovMenuDTO>> list(Integer type,String tableName){
List<GovMenuDTO> list = govMenuService.getMenuList(type,tableName);
return new Result<List<GovMenuDTO>>().ok(list);
}
@ -113,8 +113,8 @@ public class GovMenuController {
* @return List<GovMenuDTO>
*/
@GetMapping("nav")
public Result<List<GovMenuDTO>> nav(@LoginUser TokenDto tokenDto){
List<GovMenuDTO> list = govMenuService.getUserMenuNavList(tokenDto);
public Result<List<GovMenuDTO>> nav(@LoginUser TokenDto tokenDto, String tableName){
List<GovMenuDTO> list = govMenuService.getUserMenuNavList(tokenDto,tableName);
return new Result<List<GovMenuDTO>>().ok(list);
}

25
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.
*
* <p>
* https://www.renren.io
*
* <p>
* 版权所有侵权必究
*/
@ -29,16 +29,17 @@ public interface GovMenuDao extends BaseDao<GovMenuEntity> {
/**
* 查询所有菜单列表
*
* @param type 菜单类型
* @param language 语言
* @param type 菜单类型
* @param language 语言
* @param tableName
*/
List<GovMenuEntity> getMenuList(@Param("type") Integer type, @Param("language") String language);
List<GovMenuEntity> 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<GovMenuEntity> getUserMenuList(@Param("userId") String userId, @Param("type") Integer type, @Param("language") String language);
@ -46,7 +47,8 @@ public interface GovMenuDao extends BaseDao<GovMenuEntity> {
/**
* 根据父菜单查询子菜单
* @param pid 父菜单ID
*
* @param pid 父菜单ID
*/
List<GovMenuEntity> getListPid(String pid);
@ -54,8 +56,9 @@ public interface GovMenuDao extends BaseDao<GovMenuEntity> {
* 查询客户菜单列表
*
* @param customerId 客户id
* @param type 菜单类型
* @param language 语言
* @param type 菜单类型
* @param language 语言
* @param tableName
*/
List<GovMenuEntity> getCustomerMenuList(@Param("customerId") String customerId, @Param("type") Integer type, @Param("language") String language);
List<GovMenuEntity> getCustomerMenuList(@Param("customerId") String customerId, @Param("type") Integer type, @Param("language") String language, @Param("tableName") String tableName);
}

10
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<GovMenuDTO> govMenuDTOS) {
public void setCustomerMenuList(String customerId, Integer type, List<GovMenuDTO> 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<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) {
public List<GovMenuDTO> 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<GovMenuDTO>) redisUtils.get(key);
}
return null;

6
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/GovMenuService.java

@ -117,15 +117,17 @@ public interface GovMenuService extends BaseService<GovMenuEntity> {
* 菜单列表
*
* @param type 菜单类型
* @param tableName
*/
List<GovMenuDTO> getMenuList(Integer type);
List<GovMenuDTO> getMenuList(Integer type, String tableName);
/**
* 用户菜单导航
* @param tokenDto 用户信息
* @param tableName
* @return java.util.List<GovMenuDTO>
*/
List<GovMenuDTO> getUserMenuNavList(TokenDto tokenDto);
List<GovMenuDTO> getUserMenuNavList(TokenDto tokenDto, String tableName);
/**
* 获取用户权限标识

29
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java

@ -169,7 +169,8 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
// //系统管理员,拥有最高权限
// if(govUserDTOResult.getData().getSuperAdmin() == SuperAdminEnum.YES.value()){
menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage());
//目前不支持角色 菜单
menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage(), null);
// }else {
// menuList = baseDao.getUserMenuList(tokenDto.getUserId(), type, HttpContextUtils.getLanguage());
// }
@ -180,8 +181,11 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
}
@Override
public List<GovMenuDTO> getMenuList(Integer type) {
List<GovMenuEntity> menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage());
public List<GovMenuDTO> getMenuList(Integer type, String tableName) {
if (StringUtils.isBlank(tableName)){
tableName = "gov_menu";
}
List<GovMenuEntity> menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage(), tableName);
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class);
@ -189,7 +193,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
}
@Override
public List<GovMenuDTO> getUserMenuNavList(TokenDto tokenDto) {
public List<GovMenuDTO> getUserMenuNavList(TokenDto tokenDto, String tableName) {
// List<GovMenuDTO> menuList = govMenuRedis.getUserMenuNavList(tokenDto.getCustomerId(), tokenDto.getApp(), tokenDto.getClient());
// if(menuList == null){
// menuList = getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value());
@ -198,7 +202,10 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
// }
// PC端 每个客户的菜单信息,不放入缓存,每次登陆重新查询。
// 或者 你可以选择,在给每个客户 配置可见菜单的时候, 在saveCustomerMenu方法中,增加更新缓存的逻辑
return getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value());
if (StringUtils.isBlank(tableName)){
tableName = "gov_menu";
}
return getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value(),tableName);
}
/**
@ -206,19 +213,20 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
*
* @param customerId
* @param type
* @param tableName
* @return java.util.List<com.epmet.dto.GovMenuDTO>
* @Author zhangyong
* @Date 15:51 2021-03-16
**/
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) {
List<GovMenuDTO> govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type);
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type, String tableName) {
List<GovMenuDTO> govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type,tableName);
if (!CollectionUtils.isEmpty(govMenuDTOS)){
return govMenuDTOS;
}
List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage());
List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage(),tableName);
List<GovMenuDTO> 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 +243,8 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
//超级管理员,拥有最高权限
List<GovMenuEntity> 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());
// }

4
epmet-module/gov-access/gov-access-server/src/main/resources/mapper/GovMenuDao.xml

@ -14,7 +14,7 @@
</select>
<select id="getMenuList" resultType="com.epmet.entity.GovMenuEntity">
select t1.*, (select lang.field_value from gov_language lang where lang.table_name='gov_menu' and lang.field_name='name'
select t1.*, (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.del_flag = 0
<if test="type != null">
@ -40,7 +40,7 @@
</select>
<select id="getCustomerMenuList" resultType="com.epmet.entity.GovMenuEntity">
select t1.*, (select lang.field_value from gov_language lang where lang.table_name='gov_menu' and lang.field_name='name'
select t1.*, (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
RIGHT JOIN gov_customer_menu m ON t1.id = m.TABLE_ID

Loading…
Cancel
Save