feat: There is no way the User Menu auth

This commit is contained in:
super_liu
2021-08-18 16:30:58 +08:00
parent 3906456daa
commit 150e2c96d2
6 changed files with 38 additions and 15 deletions
@@ -97,4 +97,7 @@ public class TsResource extends BaseEntity {
@TableField(exist=false)
private List<String> childMenuIds;
@TableField(exist=false)
private String userId;
}
@@ -167,20 +167,22 @@ public class TsResourceServiceImpl extends ServiceImpl<TsResourceDao, TsResource
public List<TsResource> getList(TsResource tsResource) {
List<TsResource> TsResources = new ArrayList<>();
List<String> getMenuIdList = tsUserService.getResourceId(new TsResource());
if(tsResource.getUserId() != null){
List<String> getMenuIdList = tsUserService.getResourceUserId(tsResource.getUserId());
if(!getMenuIdList.isEmpty()){
QueryWrapper<TsResource> tsResourceQueryWrapper=new QueryWrapper<>();
if(tsResource.getSorDivide()!=null){
tsResourceQueryWrapper.eq("sor_divide",tsResource.getSorDivide());
}
tsResourceQueryWrapper.isNull("PARENT_ID");
tsResourceQueryWrapper.in("ID",getMenuIdList);
tsResourceQueryWrapper.orderByAsc("DISPLAY_SEQ");
TsResources=dao.selectList(tsResourceQueryWrapper);
if(!getMenuIdList.isEmpty()){
QueryWrapper<TsResource> tsResourceQueryWrapper=new QueryWrapper<>();
if(tsResource.getSorDivide()!=null){
tsResourceQueryWrapper.eq("sor_divide",tsResource.getSorDivide());
}
tsResourceQueryWrapper.isNull("PARENT_ID");
tsResourceQueryWrapper.in("ID",getMenuIdList);
tsResourceQueryWrapper.orderByAsc("DISPLAY_SEQ");
TsResources=dao.selectList(tsResourceQueryWrapper);
for(TsResource TsResource:TsResources){
TsResource.setChildren(recursionGetListChildren((TsResource),(getMenuIdList)));
for(TsResource TsResource:TsResources){
TsResource.setChildren(recursionGetListChildren((TsResource),(getMenuIdList)));
}
}
}
@@ -13,5 +13,6 @@ public class StandardsInfoExcelVO {
String standSort;
String standNumber;
String collectMenuId;
String userId;
}
@@ -267,13 +267,13 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
*/
public List<SarStandardsInfo> getSarStandardsInfoPage(SarStandardsInfoEOPage page) throws Exception {
//查询当前登录人角色拥有权限的菜单
if(page.getMenuId() != null ){
if(page.getMenuId() != null && page.getUserId() != null && StringUtils.isNotBlank(page.getUserId())){
QueryWrapper<TsResource> qw = new QueryWrapper<>();
qw.eq("ID",page.getMenuId());
qw.isNull("PARENT_ID");
List<TsResource> children = iTsResourceService.list(qw);
if(children.isEmpty() && !page.getMenuId().equals("nomenu")){
List<String> getMenuIdList = tsUserService.getResourceId(new TsResource());
List<String> getMenuIdList = tsUserService.getResourceUserId(page.getUserId());
if (getMenuIdList != null && !getMenuIdList.isEmpty()) {
page.setMenuRoleList(getMenuIdList);
} else {
@@ -1349,7 +1349,10 @@ public class SarStandardsInfoServiceImpl extends ServiceImpl<SarStandardsInfoDao
page = (SarStandardsInfoEOPage) JSONObject.toBean(jsonObject, SarStandardsInfoEOPage.class);
page.setStandType(standardsInfoExcelVO.getStandType());
//查询当前登录人角色拥有权限的菜单
List<String> getMenuIdList=tsUserService.getResourceId(new TsResource());
List<String> getMenuIdList = new ArrayList<>();
if(standardsInfoExcelVO.getUserId() != null){
getMenuIdList= tsUserService.getResourceUserId(standardsInfoExcelVO.getUserId());
}
// List<String> getMenuIdList = sarMenuEOService.queryRoleMenuIdList(page.getStandType() + "_STAND", null);
if (getMenuIdList != null && !getMenuIdList.isEmpty()) {
page.setMenuRoleList(getMenuIdList);
@@ -65,6 +65,8 @@ public interface ITsUserService extends IService<TsUser> {
List<String> getResourceId(TsResource tsResource);
List<String> getResourceUserId(String userId);
/**
* 导入人员数据
*/
@@ -195,6 +195,18 @@ public class TsUserServiceImpl extends ServiceImpl<TsUserDao, TsUser> implements
}
/**
* 查询当前登录的用户资源
* @return List<SarMenu>
*/
@Override
public List<String> getResourceUserId(String userId) {
List<String> positionIds=tsUserDao.selectPositionIds(userId);
List<String> roleIds=tsPositionService.getRoleIdsByPositionIds(positionIds);
return tsRoleService.getResourceIdsByRoleIds(roleIds);
}
/**
* 导入人员数据
*/