|
@ -30,6 +30,9 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.HttpContextUtils; |
|
|
import com.epmet.commons.tools.utils.HttpContextUtils; |
|
|
import com.epmet.commons.tools.utils.TreeUtils; |
|
|
import com.epmet.commons.tools.utils.TreeUtils; |
|
|
import com.epmet.dao.GovMenuDao; |
|
|
import com.epmet.dao.GovMenuDao; |
|
|
|
|
|
import com.epmet.dao.GovRoleDao; |
|
|
|
|
|
import com.epmet.dao.GovRoleMenuDao; |
|
|
|
|
|
import com.epmet.dao.GovRoleUserDao; |
|
|
import com.epmet.dto.GovMenuDTO; |
|
|
import com.epmet.dto.GovMenuDTO; |
|
|
import com.epmet.entity.GovMenuEntity; |
|
|
import com.epmet.entity.GovMenuEntity; |
|
|
import com.epmet.enums.MenuTypeEnum; |
|
|
import com.epmet.enums.MenuTypeEnum; |
|
@ -45,6 +48,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 菜单管理 |
|
|
* 菜单管理 |
|
@ -67,6 +71,12 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
private GovLanguageService govLanguageService; |
|
|
private GovLanguageService govLanguageService; |
|
|
@Autowired |
|
|
@Autowired |
|
|
private GovCustomerMenuService govCustomerMenuService; |
|
|
private GovCustomerMenuService govCustomerMenuService; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GovRoleDao govRoleDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GovRoleMenuDao govRoleMenuDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GovRoleUserDao govRoleUserDao; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<GovMenuDTO> page(Map<String, Object> params) { |
|
|
public PageData<GovMenuDTO> page(Map<String, Object> params) { |
|
@ -218,7 +228,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
// PC端 每个客户的菜单信息,不放入缓存,每次登陆重新查询。
|
|
|
// PC端 每个客户的菜单信息,不放入缓存,每次登陆重新查询。
|
|
|
// 或者 你可以选择,在给每个客户 配置可见菜单的时候, 在saveCustomerMenu方法中,增加更新缓存的逻辑
|
|
|
// 或者 你可以选择,在给每个客户 配置可见菜单的时候, 在saveCustomerMenu方法中,增加更新缓存的逻辑
|
|
|
tableName = getTableName(tableName); |
|
|
tableName = getTableName(tableName); |
|
|
return getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value(),tableName); |
|
|
return getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value(),tableName,tokenDto.getUserId()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -231,18 +241,40 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
* @Author zhangyong |
|
|
* @Author zhangyong |
|
|
* @Date 15:51 2021-03-16 |
|
|
* @Date 15:51 2021-03-16 |
|
|
**/ |
|
|
**/ |
|
|
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type, String tableName) { |
|
|
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type, String tableName,String userId) { |
|
|
List<GovMenuDTO> govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type,tableName); |
|
|
/*List<GovMenuDTO> govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type,tableName); |
|
|
if (!CollectionUtils.isEmpty(govMenuDTOS)){ |
|
|
if (!CollectionUtils.isEmpty(govMenuDTOS)){ |
|
|
return govMenuDTOS; |
|
|
return govMenuDTOS; |
|
|
} |
|
|
}*/ |
|
|
List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage(),tableName); |
|
|
List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage(),tableName); |
|
|
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); |
|
|
disposeGovMenu(menuList,userId); |
|
|
govMenuDTOS = TreeUtils.buildTree(dtoList); |
|
|
Map<Boolean, List<GovMenuEntity>> groupByStatus = menuList.stream().collect(Collectors.groupingBy(GovMenuEntity::getRoleStatus)); |
|
|
govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS,tableName); |
|
|
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(CollectionUtils.isEmpty(groupByStatus.get(true)) ? new ArrayList<>() : groupByStatus.get(true), GovMenuDTO.class); |
|
|
|
|
|
List<GovMenuDTO> govMenuDTOS = TreeUtils.buildTree(dtoList); |
|
|
|
|
|
// govCustomerMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS,tableName);
|
|
|
return govMenuDTOS; |
|
|
return govMenuDTOS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void disposeGovMenu(List<GovMenuEntity> menuList,String userId){ |
|
|
|
|
|
List<String> roleIdList = govRoleUserDao.getRoleIdList(userId); |
|
|
|
|
|
if (CollectionUtils.isEmpty(roleIdList)){ |
|
|
|
|
|
menuList = new ArrayList<>(); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
List<String> menuIdsList = govRoleMenuDao.getMenuIdsList(roleIdList); |
|
|
|
|
|
if (CollectionUtils.isEmpty(menuIdsList)){ |
|
|
|
|
|
menuList = new ArrayList<>(); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
for (String id : menuIdsList) { |
|
|
|
|
|
for (GovMenuEntity m : menuList) { |
|
|
|
|
|
if (m.getId().equals(id)){ |
|
|
|
|
|
m.setRoleStatus(true); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Set<String> getUserPermissions(TokenDto tokenDto) { |
|
|
public Set<String> getUserPermissions(TokenDto tokenDto) { |
|
|
//用户权限列表
|
|
|
//用户权限列表
|
|
|