| | |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.basic.PageInfo; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.framework.web.service.TokenService; |
| | | import com.ruoyi.system.dto.AuditUserDto; |
| | | import com.ruoyi.system.dto.TAppUserDTO; |
| | | import com.ruoyi.system.dto.UpAndDownDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.dto.UserIdDto; |
| | | import com.ruoyi.system.model.TAppUser; |
| | | import com.ruoyi.system.model.TUserMajor; |
| | | import com.ruoyi.system.query.TAppUserQuery; |
| | | import com.ruoyi.system.service.TAppUserService; |
| | | import com.ruoyi.system.service.TUserMajorService; |
| | | import com.ruoyi.system.vo.TAppUserPageVo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.util.CollectionUtils; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.stream.Collectors; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | private final TokenService tokenService; |
| | | private final TAppUserService appUserService; |
| | | private final TUserMajorService userMajorService; |
| | | |
| | | @Autowired |
| | | public TAppUserController(TokenService tokenService, TAppUserService appUserService) { |
| | | public TAppUserController(TokenService tokenService, TAppUserService appUserService, TUserMajorService userMajorService) { |
| | | this.tokenService = tokenService; |
| | | this.appUserService = appUserService; |
| | | this.userMajorService = userMajorService; |
| | | } |
| | | |
| | | /** |
| | |
| | | * 添加人员 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:addUser')") |
| | | @ApiOperation(value = "添加人员") |
| | | @ApiOperation(value = "添加人员",notes = "请求参数:TAppUserDTO对象",response = TAppUserDTO.class) |
| | | @PostMapping(value = "/api/t-app-user/addUser") |
| | | public R<?> addUser(@RequestBody String param) { |
| | | TAppUser tAppUser = JSON.parseObject(param, TAppUser.class); |
| | | String pwd = SecurityUtils.encryptPassword(tAppUser.getPassword()); |
| | | tAppUser.setPassword(pwd); |
| | | tAppUser.setState(1); |
| | | appUserService.save(tAppUser); |
| | | TAppUserDTO dto = JSON.parseObject(param, TAppUserDTO.class); |
| | | if(!StringUtils.hasLength(dto.getAccount())){ |
| | | return R.fail("请输入账号"); |
| | | } |
| | | if (appUserService.isExit(dto)) { |
| | | return R.fail("该账号已存在"); |
| | | } |
| | | List<TUserMajor> userMajors = dto.getUserMajors(); |
| | | if(CollectionUtils.isEmpty(userMajors)){ |
| | | return R.fail("请选择专业"); |
| | | } |
| | | String pwd = SecurityUtils.encryptPassword(dto.getPassword()); |
| | | dto.setPassword(pwd); |
| | | dto.setState(1); |
| | | appUserService.save(dto); |
| | | |
| | | for (TUserMajor userMajor : userMajors) { |
| | | userMajor.setAppUserId(dto.getId()); |
| | | } |
| | | userMajorService.saveBatch(userMajors); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | * 编辑人员 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:updateUser')") |
| | | @ApiOperation(value = "编辑人员") |
| | | @ApiOperation(value = "编辑人员", response = TAppUser.class) |
| | | @PostMapping(value = "/api/t-app-user/updateUser") |
| | | public R<?> updateUser(@RequestBody String param) { |
| | | TAppUser tAppUser = JSON.parseObject(param, TAppUser.class); |
| | | if(tAppUser.getPassword()!=null && !tAppUser.getPassword().isEmpty()){ |
| | | String pwd = SecurityUtils.encryptPassword(tAppUser.getPassword()); |
| | | tAppUser.setPassword(pwd); |
| | | TAppUserDTO dto = JSON.parseObject(param, TAppUserDTO.class); |
| | | if (appUserService.isExit(dto)) { |
| | | return R.fail("该账号已存在"); |
| | | } |
| | | tAppUser.setState(1); |
| | | appUserService.updateById(tAppUser); |
| | | List<TUserMajor> userMajors = dto.getUserMajors(); |
| | | if(dto.getPassword()!=null && !dto.getPassword().isEmpty()){ |
| | | String pwd = SecurityUtils.encryptPassword(dto.getPassword()); |
| | | dto.setPassword(pwd); |
| | | } |
| | | dto.setState(1); |
| | | appUserService.updateById(dto); |
| | | userMajorService.remove(Wrappers.lambdaQuery(TUserMajor.class).eq(TUserMajor::getAppUserId,dto.getId())); |
| | | for (TUserMajor userMajor : userMajors) { |
| | | userMajor.setAppUserId(dto.getId()); |
| | | } |
| | | userMajorService.saveBatch(userMajors); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除人员 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:delUser')") |
| | | @ApiOperation(value = "删除人员") |
| | | @PostMapping(value = "/api/t-app-user/delUser") |
| | | public R<?> delUser(@RequestBody String param) { |
| | | String id = JSON.parseObject(param, String.class); |
| | | TAppUser appUser = appUserService.getById(id); |
| | | UserIdDto dto = JSON.parseObject(param, UserIdDto.class); |
| | | TAppUser appUser = appUserService.getById(dto.getId()); |
| | | appUser.setDisabled(true); |
| | | appUserService.updateById(appUser); |
| | | return R.ok(); |
| | |
| | | /** |
| | | * 禁用/启用 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:updateStatus')") |
| | | @ApiOperation(value = "禁用/启用") |
| | | @PostMapping(value = "/api/t-app-user/updateStatus") |
| | | public R<?> updateStatus(@RequestBody String param) { |
| | |
| | | /** |
| | | * 禁用/启用 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:resetPwd')") |
| | | @ApiOperation(value = "重置密码") |
| | | @PostMapping(value = "/api/t-app-user/resetPwd") |
| | | public R<?> resetPwd(@RequestBody String param) { |
| | | String id = JSON.parseObject(param, String.class); |
| | | TAppUser appUser = appUserService.getById(id); |
| | | UserIdDto dto = JSON.parseObject(param, UserIdDto.class); |
| | | TAppUser appUser = appUserService.getById(dto.getId()); |
| | | String pwd = SecurityUtils.encryptPassword("123456"); |
| | | appUser.setPassword(pwd); |
| | | appUserService.updateById(appUser); |
| | |
| | | /** |
| | | * 获取人员审核管理分页列表 |
| | | */ |
| | | @ApiOperation(value = "获取人员审核管理分页列表", response = TAppUserPageVo.class) |
| | | // @PreAuthorize("@ss.hasPermi('system:user:pageAuditList')") |
| | | @ApiOperation(value = "获取人员审核管理分页列表", response = TAppUserQuery.class) |
| | | @PostMapping(value = "/api/t-app-user/pageAuditList") |
| | | public R<PageInfo<TAppUserPageVo>> pageAuditList(@RequestBody String param) { |
| | | TAppUserQuery query = JSON.parseObject(param, TAppUserQuery.class); |
| | |
| | | /** |
| | | * 获取人员审核管理详情 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:auditDetail')") |
| | | @ApiOperation(value = "获取人员审核管理详情", response = TAppUserPageVo.class) |
| | | @PostMapping(value = "/api/t-app-user/pageAuditDetail") |
| | | public R<TAppUserPageVo> pageAuditDetail(@RequestBody String param) { |
| | | TAppUserQuery query = JSON.parseObject(param, TAppUserQuery.class); |
| | | return R.ok(appUserService.pageAuditDetail(query)); |
| | | @PostMapping(value = "/api/t-app-user/auditDetail") |
| | | public R<TAppUserPageVo> auditDetail(@RequestBody String param) { |
| | | UserIdDto dto = JSON.parseObject(param, UserIdDto.class); |
| | | return R.ok(appUserService.pageAuditDetail(dto.getId())); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 编辑人员 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:auditUser')") |
| | | @ApiOperation(value = "人员审核", response = AuditUserDto.class) |
| | | @PostMapping(value = "/api/t-app-user/auditUser") |
| | | public R<?> auditUser(@RequestBody String param) { |
| | | AuditUserDto dto = JSON.parseObject(param, AuditUserDto.class); |
| | | TAppUser tAppUser = appUserService.getById(dto.getId()); |
| | | tAppUser.setStatus(dto.getStatus()); |
| | | tAppUser.setTeamId(dto.getTeamId()); |
| | | appUserService.updateById(tAppUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 详情 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:auditUser')") |
| | | @ApiOperation(value = "人员详情", response = AuditUserDto.class) |
| | | @GetMapping(value = "/api/t-app-user/detailUser") |
| | | public R<TAppUser> detailUser(@RequestBody String param) { |
| | | UserIdDto dto = JSON.parseObject(param, UserIdDto.class); |
| | | TAppUser tAppUser = appUserService.getById(dto.getId()); |
| | | List<TUserMajor> list = userMajorService.list(new LambdaQueryWrapper<TUserMajor>().eq(TUserMajor::getAppUserId, dto.getId())); |
| | | tAppUser.setUserMajors(list); |
| | | return R.ok(tAppUser); |
| | | } |
| | | |
| | | |