|
|
@ -94,8 +94,9 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public GovMenuDTO get(String id) { |
|
|
|
GovMenuEntity entity = baseDao.getById(id, HttpContextUtils.getLanguage()); |
|
|
|
public GovMenuDTO get(String id, String tableName) { |
|
|
|
tableName = getTableName(tableName); |
|
|
|
GovMenuEntity entity = baseDao.getById(id, HttpContextUtils.getLanguage(),tableName); |
|
|
|
|
|
|
|
return ConvertUtils.sourceToTarget(entity, GovMenuDTO.class); |
|
|
|
} |
|
|
@ -107,7 +108,9 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
|
|
|
|
//保存菜单
|
|
|
|
insert(entity); |
|
|
|
saveLanguage(entity.getId(), "name", entity.getName()); |
|
|
|
String tableName = dto.getTableName(); |
|
|
|
tableName = getTableName(tableName); |
|
|
|
saveLanguage(tableName, entity.getId(), "name", entity.getName()); |
|
|
|
|
|
|
|
//保存菜单资源
|
|
|
|
govResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); |
|
|
@ -117,6 +120,18 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
//govMenuRedis.delete(tokenDto.getUserId(), tokenDto.getApp(), tokenDto.getClient());
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* desc:获取tableName 默认 gov_menu |
|
|
|
* @param tableName |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String getTableName(String tableName) { |
|
|
|
if (StringUtils.isBlank(tableName)) { |
|
|
|
tableName = "gov_menu"; |
|
|
|
} |
|
|
|
return tableName; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(GovMenuDTO dto, TokenDto tokenDto) { |
|
|
@ -126,10 +141,12 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
if(entity.getId().equals(entity.getPid())){ |
|
|
|
throw new RenException(ErrorCode.SUPERIOR_MENU_ERROR); |
|
|
|
} |
|
|
|
String tableName = dto.getTableName(); |
|
|
|
tableName = getTableName(tableName); |
|
|
|
|
|
|
|
//更新菜单
|
|
|
|
updateById(entity); |
|
|
|
saveLanguage(entity.getId(), "name", entity.getName()); |
|
|
|
saveLanguage(tableName, entity.getId(), "name", entity.getName()); |
|
|
|
|
|
|
|
//更新菜单资源
|
|
|
|
govResourceService.saveMenuResource(entity.getId(), entity.getName(), dto.getResourceList()); |
|
|
@ -169,7 +186,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 +198,9 @@ 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) { |
|
|
|
tableName = getTableName(tableName); |
|
|
|
List<GovMenuEntity> menuList = baseDao.getMenuList(type, HttpContextUtils.getLanguage(), tableName); |
|
|
|
|
|
|
|
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); |
|
|
|
|
|
|
@ -189,7 +208,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 +217,8 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
// }
|
|
|
|
// PC端 每个客户的菜单信息,不放入缓存,每次登陆重新查询。
|
|
|
|
// 或者 你可以选择,在给每个客户 配置可见菜单的时候, 在saveCustomerMenu方法中,增加更新缓存的逻辑
|
|
|
|
return getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value()); |
|
|
|
tableName = getTableName(tableName); |
|
|
|
return getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value(),tableName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -206,19 +226,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 +256,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());
|
|
|
|
// }
|
|
|
@ -267,7 +289,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
logger.info(String.format("运营端用户退出系统%s,清空菜单、权限成功",userId)); |
|
|
|
} |
|
|
|
|
|
|
|
private void saveLanguage(String tableId, String fieldName, String fieldValue){ |
|
|
|
govLanguageService.saveOrUpdate("gov_menu", tableId, fieldName, fieldValue, HttpContextUtils.getLanguage()); |
|
|
|
private void saveLanguage(String tableName, String tableId, String fieldName, String fieldValue){ |
|
|
|
govLanguageService.saveOrUpdate(tableName, tableId, fieldName, fieldValue, HttpContextUtils.getLanguage()); |
|
|
|
} |
|
|
|
} |
|
|
|