| | |
| | | package com.ruoyi.web.controller.system; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.annotation.Log; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.controller.BaseController; |
| | |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.SysUserUpdateStatusDTO; |
| | | import com.ruoyi.system.model.TProjectTeamStaff; |
| | | import com.ruoyi.system.query.SysUserQuery; |
| | | import com.ruoyi.system.service.*; |
| | | import com.ruoyi.system.vo.SysUserVO; |
| | |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDateTime; |
| | |
| | | private ISysDeptService deptService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Autowired |
| | | private TProjectTeamService projectTeamService; |
| | | @Autowired |
| | | private TProjectTeamStaffService projectTeamStaffService; |
| | | |
| | | /** |
| | | * 获取用户列表 |
| | | */ |
| | | @ApiOperation(value = "获取用户列表") |
| | | @PostMapping("/system/user/list") |
| | | @PreAuthorize("@ss.hasPermi('system:user')") |
| | | // @PreAuthorize("@ss.hasPermi('system:user')") |
| | | public AjaxResult list(@RequestBody SysUserQuery query) |
| | | { |
| | | PageInfo<SysUserVO> list = userService.pageList(query); |
| | |
| | | |
| | | @ApiOperation(value = "获取用户列表-不分页") |
| | | @PostMapping("/system/user/listNotPage") |
| | | @PreAuthorize("@ss.hasPermi('system:user')") |
| | | |
| | | // @PreAuthorize("@ss.hasPermi('system:user')") |
| | | public AjaxResult listNotPage() |
| | | { |
| | | List<SysUser> list = userService.selectList(); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "获取用户列表-不分页-根据角色筛选") |
| | | @GetMapping("/system/user/listByRole") |
| | | public AjaxResult listByRole(@RequestParam(value = "roleId",required = false) Long roleId, |
| | | @RequestParam(value = "nickName",required = false) String nickName) |
| | | { |
| | | // 获取当前用户项目组 |
| | | Long userId = tokenService.getLoginUser().getUserId(); |
| | | List<TProjectTeamStaff> staffs = projectTeamStaffService.list(Wrappers.lambdaQuery(TProjectTeamStaff.class) |
| | | .eq(TProjectTeamStaff::getUserId, userId)); |
| | | if (CollectionUtils.isEmpty(staffs)){ |
| | | return AjaxResult.success(new ArrayList<>()); |
| | | } |
| | | List<String> teamIds = staffs.stream().map(TProjectTeamStaff::getTeamId).collect(Collectors.toList()); |
| | | LambdaQueryWrapper<TProjectTeamStaff> wrapper = new LambdaQueryWrapper<>(); |
| | | if(Objects.nonNull(roleId)){ |
| | | wrapper.eq(TProjectTeamStaff::getRoleType,Integer.parseInt(roleId.toString())); |
| | | } |
| | | wrapper.in(TProjectTeamStaff::getTeamId, teamIds); |
| | | List<TProjectTeamStaff> teamStaffs = projectTeamStaffService.list(wrapper); |
| | | List<Long> userIds = teamStaffs.stream().map(TProjectTeamStaff::getUserId).collect(Collectors.toList()); |
| | | |
| | | List<SysUser> list = userService.listByRole(userIds,nickName); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | |
| | | } |
| | | user.setCreateBy(getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword("123456")); |
| | | user.setRoleType(Integer.parseInt(user.getRoleId().toString())); |
| | | userService.insertUser(user); |
| | | return R.ok(); |
| | | } |
| | |
| | | if(StringUtils.isNotEmpty(user.getPassword())){ |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | } |
| | | user.setRoleType(Integer.parseInt(user.getRoleId().toString())); |
| | | return R.ok(userService.updateUser(user)); |
| | | } |
| | | |