| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | 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.UpAndDownDTO; |
| | | import com.ruoyi.system.mapper.SysUserMapper; |
| | | import com.ruoyi.system.model.TAppUser; |
| | | import com.ruoyi.system.query.TAppUserQuery; |
| | | import com.ruoyi.system.service.TAppUserService; |
| | | 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 java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2025-09-28 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/t-app-user") |
| | | @RequestMapping("") |
| | | @Api(tags = "人员管理") |
| | | public class TAppUserController { |
| | | |
| | | private final TokenService tokenService; |
| | | private final TAppUserService appUserService; |
| | | |
| | | @Autowired |
| | | public TAppUserController(TokenService tokenService, TAppUserService appUserService) { |
| | | this.tokenService = tokenService; |
| | | this.appUserService = appUserService; |
| | | } |
| | | |
| | | /** |
| | | * 获取人员列表 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:list')") |
| | | @ApiOperation(value = "获取人员管理分页列表", response = TAppUser.class) |
| | | @PostMapping(value = "/api/t-app-user/pageList") |
| | | public R<PageInfo<TAppUserPageVo>> pageList(@RequestBody String param) { |
| | | TAppUserQuery query = JSON.parseObject(param, TAppUserQuery.class); |
| | | return R.ok(appUserService.pageList(query)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 添加人员 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:addUser')") |
| | | @ApiOperation(value = "添加人员") |
| | | @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); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 编辑人员 |
| | | */ |
| | | // @PreAuthorize("@ss.hasPermi('system:user:updateUser')") |
| | | @ApiOperation(value = "编辑人员") |
| | | @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); |
| | | } |
| | | tAppUser.setState(1); |
| | | appUserService.updateById(tAppUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 删除人员 |
| | | */ |
| | | @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); |
| | | appUser.setDisabled(true); |
| | | appUserService.updateById(appUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 禁用/启用 |
| | | */ |
| | | @ApiOperation(value = "禁用/启用") |
| | | @PostMapping(value = "/api/t-app-user/updateStatus") |
| | | public R<?> updateStatus(@RequestBody String param) { |
| | | UpAndDownDTO dto = JSON.parseObject(param, UpAndDownDTO.class); |
| | | TAppUser appUser = appUserService.getById(dto.getId()); |
| | | appUser.setStatus(dto.getStatus()); |
| | | appUserService.updateById(appUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 禁用/启用 |
| | | */ |
| | | @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); |
| | | String pwd = SecurityUtils.encryptPassword("123456"); |
| | | appUser.setPassword(pwd); |
| | | appUserService.updateById(appUser); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取人员审核管理分页列表 |
| | | */ |
| | | @ApiOperation(value = "获取人员审核管理分页列表", response = TAppUserPageVo.class) |
| | | @PostMapping(value = "/api/t-app-user/pageAuditList") |
| | | public R<PageInfo<TAppUserPageVo>> pageAuditList(@RequestBody String param) { |
| | | TAppUserQuery query = JSON.parseObject(param, TAppUserQuery.class); |
| | | return R.ok(appUserService.pageAuditList(query)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取人员审核管理详情 |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | | |
| | | } |
| | | |