| | |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.mapper.PermitGroupMapper; |
| | | import com.whyc.mapper.PermitGroupUserMapper; |
| | | import com.whyc.mapper.UserInfMapper; |
| | | import com.whyc.pojo.PermitGroup; |
| | | import com.whyc.pojo.PermitGroupUser; |
| | | import com.whyc.pojo.UserInf; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Wrapper; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | @Transactional |
| | |
| | | |
| | | @Resource |
| | | private CommonMapper commonMapper; |
| | | |
| | | @Resource |
| | | private UserInfMapper userInfMapper; |
| | | |
| | | public void add(List<PermitGroup> permitGroupList) { |
| | | //权限组id生成 |
| | |
| | | wrapper.select("distinct permit_group_id,permit_group_name"); |
| | | return mapper.selectList(wrapper); |
| | | } |
| | | |
| | | public Map getPermitGroupInfo(Integer permitGroupId) { |
| | | Map<String,List> resultMap = new HashMap<>(); |
| | | //查询权限组已添加的用户 |
| | | List<UserInf> relatedUserInfList = permitGroupUserMapper.getUserInf(permitGroupId); |
| | | //查询权限组未添加的用户 |
| | | List<UserInf> allUserInfList = userInfMapper.selectList(null); |
| | | List<UserInf> notRelatedUserInfList = allUserInfList.stream().filter(userInf -> !relatedUserInfList.contains(userInf)).collect(Collectors.toList()); |
| | | //查询权限组的明细权限 |
| | | QueryWrapper<PermitGroup> wrapper = Wrappers.query(); |
| | | wrapper.eq("permit_group_id",permitGroupId); |
| | | List<PermitGroup> permitGroupList = mapper.selectList(wrapper); |
| | | |
| | | resultMap.put("usersAdded",relatedUserInfList); |
| | | resultMap.put("usersNotAdded",notRelatedUserInfList); |
| | | resultMap.put("permits",permitGroupList); |
| | | return resultMap; |
| | | } |
| | | } |