| | |
| | | import com.ycl.service.user.UmsDepartManageService; |
| | | import com.ycl.vo.depart.DepartVO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | |
| | | } |
| | | } |
| | | //绑定菜单于用户 |
| | | ArrayList<UmsRoleMenuRelation> umsRoleMenuRelations = new ArrayList<>(); |
| | | for (Long role : roles) { |
| | | umsRoleMenuRelations.addAll(roleMenuRelationMapper |
| | | .selectList(new LambdaQueryWrapper<UmsRoleMenuRelation>() |
| | | .eq(UmsRoleMenuRelation::getRoleId, role))); |
| | | } |
| | | umsRoleMenuRelations |
| | | .stream() |
| | | .map(item->item.getMenuId()) |
| | | .collect(Collectors.toList()) |
| | | .stream() |
| | | .distinct() |
| | | .collect(Collectors.toList()) |
| | | .stream() |
| | | .forEach(item -> { |
| | | AdminMenuRelation adminMenuRelation = new AdminMenuRelation(); |
| | | adminMenuRelation.setAdminId(id); |
| | | adminMenuRelation.setMenuId(item); |
| | | adminMenuRelationMapper.insert(adminMenuRelation); |
| | | }); |
| | | ArrayList<UmsRoleMenuRelation> umsRoleMenuRelations = new ArrayList<>(); |
| | | for (Long role : roles) { |
| | | umsRoleMenuRelations.addAll(roleMenuRelationMapper |
| | | .selectList(new LambdaQueryWrapper<UmsRoleMenuRelation>() |
| | | .eq(UmsRoleMenuRelation::getRoleId, role))); |
| | | } |
| | | umsRoleMenuRelations |
| | | .stream() |
| | | .map(item -> item.getMenuId()) |
| | | .collect(Collectors.toList()) |
| | | .stream() |
| | | .distinct() |
| | | .collect(Collectors.toList()) |
| | | .stream() |
| | | .forEach(item -> { |
| | | AdminMenuRelation adminMenuRelation = new AdminMenuRelation(); |
| | | adminMenuRelation.setAdminId(id); |
| | | adminMenuRelation.setMenuId(item); |
| | | adminMenuRelationMapper.insert(adminMenuRelation); |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void userUpdateDepart(Long id, List<UmsDepartManage> departIds) { |
| | | umsDepartManageMapper.delete(new LambdaQueryWrapper<UmsDepartManage>().eq(UmsDepartManage::getUserId,id)); |
| | | departIds |
| | | .stream() |
| | | .forEach(item->{ |
| | | UmsDepartManage umsDepartManage = new UmsDepartManage(); |
| | | umsDepartManage.setDepartId(item.getDepartId()); |
| | | umsDepartManage.setUserId(id); |
| | | umsDepartManage.setIsLeader(item.getIsLeader()); |
| | | umsDepartManage.setCreateTime(new Date()); |
| | | umsDepartManageMapper.insert(umsDepartManage); |
| | | }); |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void userUpdateDepart(Long userId,Long departId) { |
| | | umsDepartManageMapper.delete(new LambdaQueryWrapper<UmsDepartManage>().eq(UmsDepartManage::getUserId,userId)); |
| | | UmsDepartManage umsDepartManage = new UmsDepartManage(); |
| | | umsDepartManage.setUserId(userId); |
| | | umsDepartManage.setCreateTime(new Date()); |
| | | umsDepartManage.setDepartId(departId); |
| | | umsDepartManageMapper.insert(umsDepartManage); |
| | | } |
| | | } |