| | |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | Page<AdminUserVo> page = new Page<>(adminUserDto.getPageNum(), adminUserDto.getPageSize()); |
| | | UserEntity userEntity = new UserEntity(); |
| | | long belongId = userlogin.getBelongId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getBelongId(); |
| | | if(belongId > UserEntity.USER_BELONG_TOP){ |
| | | userEntity.setBelongId(belongId); |
| | | long companyId = userlogin.getCompanyId() == null ? UserEntity.USER_BELONG_TOP : userlogin.getCompanyId(); |
| | | if(companyId > UserEntity.USER_BELONG_TOP){ |
| | | userEntity.setCompanyId(companyId); |
| | | userEntity.setRoleName(RoleEntity.ROLE_ADMIN_NAME); |
| | | }else if(belongId == UserEntity.USER_BELONG_TOP){ |
| | | }else if(companyId == UserEntity.USER_BELONG_TOP){ |
| | | userEntity.setRoleName(RoleEntity.ROLE_SUPER_NAME); |
| | | } |
| | | if(StrUtil.isNotEmpty(adminUserDto.getUsername())){ |
| | |
| | | public Result addUser(AdminAddUserDto adminAddUserDto) { |
| | | UserEntity userlogin = LoginUserUtil.getLoginUser(); |
| | | String username = adminAddUserDto.getUsername(); |
| | | if(StrUtil.isEmpty(username)){ |
| | | return Result.fail("请输入用户名"); |
| | | } |
| | | QueryWrapper<UserEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | | objectQueryWrapper.eq("username",username); |
| | | // objectQueryWrapper.eq("belong_id",userlogin.getBelongId()); |
| | | List<UserEntity> userEntities = this.baseMapper.selectList(objectQueryWrapper); |
| | | if(CollUtil.isNotEmpty(userEntities)){ |
| | | return Result.fail("用户名重复"); |
| | | } |
| | | String roleIds = adminAddUserDto.getRoleIds(); |
| | | if(StrUtil.isEmpty(roleIds)){ |
| | | return Result.fail("请选择用户角色"); |
| | | } |
| | | String phone = adminAddUserDto.getPhone(); |
| | | if(StrUtil.isEmpty(phone)){ |
| | | return Result.fail("请输入联系电话"); |
| | | } |
| | | Long belongId = adminAddUserDto.getBelongId() == null ? UserEntity.USER_BELONG_TOP:adminAddUserDto.getBelongId(); |
| | | if(belongId == UserEntity.USER_BELONG_TOP){ |
| | | return Result.fail("请选择所属公司"); |
| | |
| | | } |
| | | userEntity.setPassword(SecureUtil.md5(UserEntity.PASSWORD_DEFAULT)); |
| | | userEntity.setStatus(UserEntity.STATUS_ENABLE); |
| | | userEntity.setBelongId(belongId); |
| | | userEntity.setCompanyId(belongId); |
| | | int insert = this.baseMapper.insert(userEntity); |
| | | if(insert > 0){ |
| | | saveUserRole(roleIds,userEntity.getId()); |
| | |
| | | adminSeeUserInfoVo.setNickname(userEntity.getNickname()); |
| | | adminSeeUserInfoVo.setPhone(userEntity.getPhone()); |
| | | adminSeeUserInfoVo.setEmail(userEntity.getEmail()); |
| | | adminSeeUserInfoVo.setBelongId(userEntity.getBelongId()); |
| | | adminSeeUserInfoVo.setBelongId(userEntity.getCompanyId()); |
| | | |
| | | List<AdminRoleVo> adminRoleVos = new ArrayList<>(); |
| | | QueryWrapper<UserRoleEntity> objectQueryWrapper = new QueryWrapper<>(); |
| | |
| | | if(ObjectUtil.isEmpty(userEntity)){ |
| | | return Result.fail("用户不存在"); |
| | | } |
| | | userEntity.setBelongId(belongId); |
| | | userEntity.setCompanyId(belongId); |
| | | userEntity.setUsername(username); |
| | | userEntity.setPhone(phone); |
| | | if(StrUtil.isNotEmpty(adminUpdateUserDto.getNickname())){ |
| | |
| | | List<UserRoleEntity> userRoleEntities = userRoleMapper.selectList(userRoleQueryWrapper); |
| | | if(CollUtil.isNotEmpty(userRoleEntities)){ |
| | | List menuIds = new ArrayList<Long>(); |
| | | for(UserRoleEntity userRoleEntity : userRoleEntities){ |
| | | List<RoleMenuEntity> roleMenuEntities = roleMenuMapper.selectListByRoleId(userRoleEntity.getRoleId()); |
| | | if(CollUtil.isNotEmpty(roleMenuEntities)){ |
| | | for(RoleMenuEntity roleMenuEntity : roleMenuEntities){ |
| | | menuIds.add(roleMenuEntity.getMenuId()); |
| | | if(UserEntity.USERNAME_DEFAULT.equals(loginUser.getUsername())){ |
| | | List<MenuEntity> menuEntities = menuMapper.selectList(new QueryWrapper<>()); |
| | | if(CollUtil.isNotEmpty(menuEntities)){ |
| | | for(MenuEntity menuEntity : menuEntities){ |
| | | menuIds.add(menuEntity.getId()); |
| | | } |
| | | } |
| | | }else{ |
| | | for(UserRoleEntity userRoleEntity : userRoleEntities){ |
| | | List<RoleMenuEntity> roleMenuEntities = roleMenuMapper.selectListByRoleId(userRoleEntity.getRoleId()); |
| | | if(CollUtil.isNotEmpty(roleMenuEntities)){ |
| | | for(RoleMenuEntity roleMenuEntity : roleMenuEntities){ |
| | | menuIds.add(roleMenuEntity.getMenuId()); |
| | | } |
| | | } |
| | | } |
| | | } |