From dc460ed61e3b0688addc8ee179edb0e7ebd953ef Mon Sep 17 00:00:00 2001 From: whywhyo <1511349576@qq.com> Date: 星期一, 23 十月 2023 20:10:15 +0800 Subject: [PATCH] 1892346 --- zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java | 81 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 80 insertions(+), 1 deletions(-) diff --git a/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java b/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java index 50cf44e..bb31f3b 100644 --- a/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java +++ b/zhang-content/src/main/java/com/ruoyi/service/impl/ZAuthorityServiceImpl.java @@ -11,6 +11,7 @@ import com.ruoyi.domain.ZfFamily; import com.ruoyi.domain.dto.AuthorityDto; import com.ruoyi.domain.dto.AuthorityDto2; +import com.ruoyi.domain.dto.AuthorityDtoWithName; import com.ruoyi.mapper.ZAuthorityMapper; import com.ruoyi.service.ZAuthorityService; import com.ruoyi.service.ZInfoUserService; @@ -20,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; /** @@ -196,4 +197,82 @@ } + @Override + public AjaxResult getOtherAuthority(AuthorityDto authorityDto) { + + SysUser user = SecurityUtils.getLoginUser().getUser(); + Long userId = user.getUserId(); + ZInfoUser myself = zInfoUserService.getById(userId); + + //鏌ョ湅褰撳墠鐢ㄦ埛鏄笉鏄鐞嗗憳 + if(myself.getRoleId()!=1 && myself.getRoleId()!=2){ + throw new RuntimeException("浣犱笉鏄搴鐞嗗憳锛屾病鏈夋潈闄愭搷浣�"); + } + + //鍙兘绠$悊鑷繁瀹跺涵鐨勬潈闄� + Long fid = myself.getFamilyId(); + + + //鏍规嵁瀹跺涵鐨勫悕瀛楁煡鍑哄搴殑id +// ZfFamily family = zfFamilyService.getByName(authorityDto.getFamilyName()); +// Long fid = family.getId(); + + //寰楀埌瑕佹悳绱㈢殑妯″潡鍚嶅瓧 + String modelName = authorityDto.getModelName(); + + //鏍规嵁妯″潡鐨勫悕瀛楁煡鍑哄搴旂殑鏉冮檺鐮� + List<ZfCode> zfCodeList = zfCodeService.likeGetByName(modelName); + List<Long> allCodeList = zfCodeList.stream().map(ZfCode::getCode).collect(Collectors.toList());//鏉冮檺鐮佹暟缁� + + //鏌ユ壘瀵瑰簲瀹跺涵鍜屽搴旀ā鍧楃殑鏁版嵁 + LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); + lqw.eq(ZAuthority::getFid,fid).in(ZAuthority::getAuthority,allCodeList); + List<ZAuthority> resultData = zAuthorityService.list(lqw); + + + //鎷垮埌鏈夊叧鐢ㄦ埛鐨刬d鍜屽搴旂殑鏉冮檺鐮佹暟缁� + HashMap<Long, ArrayList<Long>> userAuthMap = new HashMap<>(); + resultData.forEach(authority->{ + if(userAuthMap.get(authority.getUid()) == null){ + ArrayList<Long> codeList = new ArrayList<>(); + codeList.add(authority.getAuthority()); + userAuthMap.put(authority.getUid(),codeList); + }else { + userAuthMap.get(authority.getUid()).add(authority.getAuthority()); + } + }); + + + List<AuthorityDtoWithName> returnData = new ArrayList<>(); + + for (Long uid : userAuthMap.keySet()) { + ArrayList<Long> authCodeList = userAuthMap.get(uid); + List<String> authNameList = zfCodeService.getNameByCode(authCodeList); + + AuthorityDto oneAuth = new AuthorityDto(); + authNameList.forEach(name ->{ + if(name.contains("鏌ョ湅")){ + oneAuth.setSearch(1); + }else if(name.contains("鍒犻櫎")){ + oneAuth.setDelete(1); + }else if(name.contains("娣诲姞")){ + oneAuth.setInsert(1); + }else if(name.contains("淇敼")){ + oneAuth.setUpdate(1); + } + }); + oneAuth.setModelName(modelName); + oneAuth.setFamilyName(zfFamilyService.getById(fid).getName()); + + AuthorityDtoWithName authorityDtoWithName = new AuthorityDtoWithName(); + authorityDtoWithName.setName(zInfoUserService.getInfoById(uid).getNickName()); + authorityDtoWithName.setUserId(uid); + authorityDtoWithName.setAuthorityInfo(oneAuth); + returnData.add(authorityDtoWithName); + } + + return AjaxResult.success(returnData); + + } + } -- Gitblit v1.9.1