| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ycl.dto.UmsMenuNode; |
| | | import com.ycl.entity.dict.DataDictionary; |
| | | import com.ycl.entity.user.*; |
| | | import com.ycl.mapper.dict.DataDictionaryMapper; |
| | | import com.ycl.mapper.user.UmsMenuMapper; |
| | | import com.ycl.mapper.user.UmsResourceMapper; |
| | | import com.ycl.mapper.user.UmsRoleMapper; |
| | | import com.ycl.service.user.UmsAdminCacheService; |
| | | import com.ycl.service.user.UmsRoleMenuRelationService; |
| | | import com.ycl.service.user.UmsRoleResourceRelationService; |
| | | import com.ycl.service.user.UmsRoleService; |
| | | import com.ycl.service.user.*; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 后台角色管理Service实现类 |
| | |
| | | private UmsRoleMenuRelationService roleMenuRelationService; |
| | | @Autowired |
| | | private UmsRoleResourceRelationService roleResourceRelationService; |
| | | |
| | | private UmsMenuService umsMenuService; |
| | | @Autowired |
| | | public void setUmsMenuService(UmsMenuService umsMenuService) { |
| | | this.umsMenuService = umsMenuService; |
| | | } |
| | | |
| | | @Resource |
| | | private UmsMenuMapper umsMenuMapper; |
| | | @Resource |
| | | private UmsResourceMapper umsResourceMapper; |
| | | @Resource |
| | | private DataDictionaryMapper dataDictionaryMapper; |
| | | @Override |
| | | public boolean create(UmsRole role) { |
| | | role.setCreateTime(new Date()); |
| | |
| | | if(StrUtil.isNotEmpty(keyword)){ |
| | | lambda.like(UmsRole::getName,keyword); |
| | | } |
| | | return page(page,wrapper); |
| | | Page<UmsRole> resultPage = page(page, wrapper); |
| | | List<UmsRole> roles = resultPage.getRecords(); |
| | | List<Long> types = roles.stream().map(UmsRole::getType).collect(Collectors.toList()); |
| | | |
| | | LambdaQueryWrapper<DataDictionary> dicQuery = new LambdaQueryWrapper<>(); |
| | | dicQuery.in(DataDictionary::getId, types); |
| | | List<DataDictionary> dics = dataDictionaryMapper.selectList(dicQuery); |
| | | for (UmsRole role : roles) { |
| | | for (DataDictionary dic : dics) { |
| | | if (dic.getId().equals(role.getType())) { |
| | | role.setTypeText(dic.getName()); |
| | | } |
| | | } |
| | | } |
| | | return resultPage; |
| | | } |
| | | |
| | | @Override |
| | | public List<UmsMenu> getMenuList(Long adminId) { |
| | | return umsMenuMapper.getMenuList(adminId); |
| | | public List<UmsMenuNode> getMenuList(Long adminId) { |
| | | List<UmsMenu> menuList = umsMenuMapper.getMenuList(adminId); |
| | | List<UmsMenuNode> result = menuList.stream() |
| | | .filter(menu -> menu.getParentId().equals(0L)) |
| | | .map(menu -> umsMenuService.covertMenuNode(menu, menuList)).collect(Collectors.toList()); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<UmsMenu> listMenu(Long roleId) { |
| | |
| | | adminCacheService.delResourceListByRole(roleId); |
| | | return resourceIds.size(); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean updateStatusBatch(List<Long> ids, Integer status) { |
| | | List<UmsRole> roles = new ArrayList<>(); |
| | | for (Long id : ids) { |
| | | UmsRole umsRole = UmsRole.builder(). |
| | | id(id).status(status).build(); |
| | | roles.add(umsRole); |
| | | } |
| | | updateBatchById(roles,roles.size()); |
| | | adminCacheService.delResourceListByRoleIds(ids); |
| | | return true; |
| | | } |
| | | } |