| | |
| | | import com.ycl.utils.common.LiveTimeMillisecond; |
| | | import com.ycl.utils.common.MacUtils; |
| | | import com.ycl.utils.common.PojoUtils; |
| | | import com.ycl.utils.common.RandomUtils; |
| | | import com.ycl.utils.redis.RedisKey; |
| | | import com.ycl.vo.user.UserVO; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | UmsRoleMenuRelationMapper umsRoleMenuRelationMapper; |
| | | @Resource |
| | | AdminMenuRelationMapper adminMenuRelationMapper; |
| | | @Resource |
| | | UmsMenuMapper umsMenuMapper; |
| | | |
| | | @Override |
| | | public UmsAdmin getAdminByUsername(String username) { |
| | |
| | | } |
| | | //绑定菜单于用户 |
| | | if (!ids.isEmpty()) { |
| | | Integer size = 0; |
| | | Long maxId = null; |
| | | ArrayList<UmsRoleMenuRelation> umsRoleMenuRelations = new ArrayList<>(); |
| | | for (Long id : ids) { |
| | | if (size < umsRoleMenuRelationMapper |
| | | umsRoleMenuRelations.addAll(umsRoleMenuRelationMapper |
| | | .selectList(new LambdaQueryWrapper<UmsRoleMenuRelation>() |
| | | .eq(UmsRoleMenuRelation::getRoleId, id)).size()) { |
| | | size = umsRoleMenuRelationMapper |
| | | .selectList(new LambdaQueryWrapper<UmsRoleMenuRelation>() |
| | | .eq(UmsRoleMenuRelation::getRoleId, id)).size(); |
| | | maxId = id; |
| | | } |
| | | .eq(UmsRoleMenuRelation::getRoleId, id))); |
| | | } |
| | | umsRoleMenuRelationMapper |
| | | .selectList(new LambdaQueryWrapper<UmsRoleMenuRelation>() |
| | | .eq(UmsRoleMenuRelation::getRoleId, maxId)) |
| | | umsRoleMenuRelations |
| | | .stream() |
| | | .forEach(item->{ |
| | | .map(item->item.getMenuId()) |
| | | .collect(Collectors.toList()) |
| | | .stream() |
| | | .distinct() |
| | | .collect(Collectors.toList()) |
| | | .stream() |
| | | .forEach(item -> { |
| | | AdminMenuRelation adminMenuRelation = new AdminMenuRelation(); |
| | | adminMenuRelation.setAdminId(umsAdmin.getId()); |
| | | adminMenuRelation.setMenuId(item.getMenuId()); |
| | | adminMenuRelation.setMenuId(item); |
| | | adminMenuRelationMapper.insert(adminMenuRelation); |
| | | }); |
| | | } |
| | | //对用户名系统默认添加 |
| | | umsAdmin.setNickName(RandomUtils.getUserId(umsAdmin.getId())); |
| | | baseMapper.updateById(umsAdmin); |
| | | //umsAdmin.setNickName(RandomUtils.getUserId(umsAdmin.getId())); |
| | | //添加部门 |
| | | UmsDepartManage departManage = new UmsDepartManage(); |
| | | departManage.setUserId(umsAdmin.getId()); |
| | | departManage.setDepartId(umsAdmin.getDepartmentId()); |
| | | departManage.setCreateTime(new Date()); |
| | | departManage.setUpdateTime(new Date()); |
| | | umsDepartManageMapper.insert(departManage); |
| | | |
| | | baseMapper.updateById(umsAdmin); |
| | | return umsAdmin; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<UmsResource> getResourceList(Long adminId) { |
| | | List<UmsResource> resourceList = getCacheService().getResourceList(adminId); |
| | | if (CollUtil.isNotEmpty(resourceList)) { |
| | | return resourceList; |
| | | public List<UmsMenu> getResourceList(Long adminId) { |
| | | List<UmsMenu> umsMenuList = getCacheService().getResourceList(adminId); |
| | | if (CollUtil.isNotEmpty(umsMenuList)) { |
| | | return umsMenuList; |
| | | } |
| | | resourceList = umsResourceMapper.getResourceList(adminId); |
| | | if (CollUtil.isNotEmpty(resourceList)) { |
| | | getCacheService().setResourceList(adminId, resourceList); |
| | | } |
| | | return resourceList; |
| | | umsMenuList = umsMenuMapper.getMenuList(adminId); |
| | | getCacheService().setResourceList(adminId, umsMenuList); |
| | | return umsMenuList; |
| | | } |
| | | |
| | | @Override |
| | |
| | | //获取用户信息 |
| | | UmsAdmin admin = getAdminByUsername(username); |
| | | if (admin != null) { |
| | | List<UmsResource> resourceList = getResourceList(admin.getId()); |
| | | List<UmsMenu> resourceList = getResourceList(admin.getId()); |
| | | return new AdminUserDetails(admin, resourceList); |
| | | } |
| | | throw new UsernameNotFoundException("用户名或密码错误"); |
| | |
| | | QueryWrapper<UmsAdmin> wrapperUser = new QueryWrapper<>(); |
| | | wrapperUser.in("id", arr); |
| | | List<UmsAdmin> adminList = baseMapper.selectList(wrapperUser); |
| | | if (adminList == null||adminList.isEmpty()) { |
| | | if (adminList == null || adminList.isEmpty()) { |
| | | throw new ApiException("未查询到用户"); |
| | | } |
| | | if ("02".equals(sendType)) { |
| | | str = adminList.stream().map(UmsAdmin::getEmail).collect(Collectors.joining(",")); |
| | | str = adminList.stream().map(UmsAdmin::getEmail).collect(Collectors.joining(",")); |
| | | } else { |
| | | str = adminList.stream().map(UmsAdmin::getMobile).collect(Collectors.joining(",")); |
| | | } |