| | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.core.domain.entity.SysUser; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.domain.ZAuthority; |
| | | import com.ruoyi.domain.ZInfoUser; |
| | | import com.ruoyi.domain.ZfCode; |
| | | import com.ruoyi.domain.ZfFamily; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.domain.*; |
| | | import com.ruoyi.domain.dto.AuthorityDto; |
| | | import com.ruoyi.domain.dto.AuthorityDto2; |
| | | import com.ruoyi.domain.dto.AuthorityDtoWithName; |
| | | import com.ruoyi.domain.dto.EmpowerDto; |
| | | import com.ruoyi.mapper.ZAuthorityMapper; |
| | | import com.ruoyi.service.ZAuthorityService; |
| | | import com.ruoyi.service.ZInfoUserService; |
| | |
| | | public List<ZAuthority> getAuthority() { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | ZInfoUser zInfoUser = zInfoUserService.getInfoBysysId(userId); |
| | | LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZAuthority::getUid,userId); |
| | | lqw.eq(ZAuthority::getUid,zInfoUser.getUserId()); |
| | | |
| | | return list(lqw); |
| | | } |
| | |
| | | public AuthorityDto getByCondition(AuthorityDto authorityDto) { |
| | | SysUser user = SecurityUtils.getLoginUser().getUser(); |
| | | Long userId = user.getUserId(); |
| | | |
| | | Integer clanId = user.getClanId(); |
| | | String familyName = authorityDto.getFamilyName(); |
| | | String modelName = authorityDto.getModelName(); |
| | | |
| | | //根据家庭的名字查出家庭的id |
| | | Long familyId = zfFamilyService.getByName(familyName).getId(); |
| | | // Integer clanId = 0; |
| | | Long familyId = zfFamilyService.getByName(familyName, clanId).getId(); |
| | | |
| | | //根据模块的名字查出对应的权限码 |
| | | List<ZfCode> zfCodeList = zfCodeService.likeGetByName(modelName); |
| | |
| | | return AjaxResult.success(returnData); |
| | | |
| | | } |
| | | private LambdaQueryWrapper<ZAuthority> uniqueCondition(ZAuthority zAuthority) { |
| | | LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(zAuthority.getUid()!=null,ZAuthority::getUid,zAuthority.getUid()); |
| | | lqw.eq(zAuthority.getFid()!=null,ZAuthority::getFid,zAuthority.getFid()); |
| | | |
| | | lqw.eq(zAuthority.getAuthority()!=null,ZAuthority::getAuthority,zAuthority.getAuthority()); |
| | | |
| | | return lqw; |
| | | } |
| | | public void addData(ZAuthority za) |
| | | { |
| | | //判断是否重复授权 |
| | | LambdaQueryWrapper<ZAuthority> lqw = uniqueCondition(za); |
| | | List<ZAuthority> list = list(lqw); |
| | | // |
| | | if(list.size()>0){ |
| | | throw new RuntimeException("请勿新增重复数据"); |
| | | } |
| | | zAuthorityService.save(za); |
| | | |
| | | } |
| | | public AjaxResult saveZa(EmpowerDto zAuthority) |
| | | { |
| | | // boolean bl = zAuthorityService.saveOrUpdate(zAuthority); |
| | | Long [] uids = zAuthority.getUids(); |
| | | Long [] authoritys = zAuthority.getAuthoritys(); |
| | | for(Long uid : uids) |
| | | for(Long auri: authoritys) |
| | | { |
| | | ZAuthority za = new ZAuthority(); |
| | | za.setAuthority(auri); |
| | | za.setFid(zAuthority.getFid()); |
| | | za.setUid(uid); |
| | | addData(za); |
| | | System.out.println(za); |
| | | } |
| | | // Long [] |
| | | // if(bl) |
| | | return AjaxResult.success("权限新增成功!"); |
| | | // else |
| | | // return AjaxResult.error("权限新增失败!"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult deleteZa(EmpowerDto empowerDto) { |
| | | Long [] uids = empowerDto.getUids(); |
| | | Long [] authoritys = empowerDto.getAuthoritys(); |
| | | for(Long uid : uids) |
| | | for(Long auri: authoritys) |
| | | { |
| | | |
| | | LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZAuthority::getFid,empowerDto.getFid()) |
| | | .eq(ZAuthority::getAuthority, auri) |
| | | .eq(ZAuthority::getUid, uid); |
| | | System.out.println("11111111111111111111"+list(lqw)); |
| | | zAuthorityService.remove(lqw); |
| | | // addData(za); |
| | | } |
| | | return AjaxResult.success("权限收回成功!"); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public AjaxResult listByFidAid(ZAuthority zAuthority) { |
| | | //找到对应家庭以及权限模块对应的用户 |
| | | LambdaQueryWrapper<ZAuthority> lqw = new LambdaQueryWrapper<>(); |
| | | lqw.eq(ZAuthority::getFid,zAuthority.getFid()) |
| | | .eq(ZAuthority::getAuthority, zAuthority.getAuthority()); |
| | | |
| | | List<ZAuthority> authorityList = list(lqw); |
| | | |
| | | List<Long> allUserListId = authorityList.stream().map(ZAuthority::getUid).collect(Collectors.toList());//授权用户数组数组 |
| | | |
| | | |
| | | LambdaQueryWrapper<ZInfoUser> lq = new LambdaQueryWrapper<>(); |
| | | List<ZInfoUser> userInfo = new ArrayList<>(); |
| | | if(allUserListId.size()!=0) { |
| | | lq.in(ZInfoUser::getUserId, allUserListId); |
| | | |
| | | userInfo = zInfoUserService.list(lq); |
| | | } |
| | | // Map<Long, String> usi = userInfo.stream().collect(Collectors.toMap(ZInfoUser::getUserId,ZInfoUser::getNickName)); |
| | | return AjaxResult.success(userInfo); |
| | | } |
| | | } |