| | |
| | | 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 void addData(ZAuthority za) |
| | | { |
| | | //判断是否重复授权 |
| | | |
| | | // |
| | | 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); |
| | | } |
| | | // 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); |
| | | |
| | | 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<>(); |
| | | lq.in(ZInfoUser::getUserId, allUserListId); |
| | | |
| | | List<ZInfoUser> userInfo = zInfoUserService.list(lq); |
| | | // Map<Long, String> usi = userInfo.stream().collect(Collectors.toMap(ZInfoUser::getUserId,ZInfoUser::getNickName)); |
| | | return AjaxResult.success(userInfo); |
| | | } |
| | | } |