From 1cebcbd79fd408e17aa59e434b396476e117fc1c Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 22 十月 2025 18:06:00 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java |  203 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 200 insertions(+), 3 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java
index 4591b29..86cedca 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TAppUserController.java
@@ -1,8 +1,22 @@
 package com.ruoyi.web.controller.api;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.alibaba.fastjson2.JSON;
+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.UpAndDownDTO;
+import com.ruoyi.system.dto.UserIdDto;
+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.web.bind.annotation.*;
 
 /**
  * <p>
@@ -13,8 +27,191 @@
  * @since 2025-09-28
  */
 @RestController
-@RequestMapping("/t-app-user")
+@RequestMapping("")
+@Api(tags = "人员管理")
 public class TAppUserController {
 
+    private final TokenService tokenService;
+    private final TAppUserService appUserService;
+    private final TUserMajorService userMajorService;
+
+    @Autowired
+    public TAppUserController(TokenService tokenService, TAppUserService appUserService, TUserMajorService userMajorService) {
+        this.tokenService = tokenService;
+        this.appUserService = appUserService;
+        this.userMajorService = userMajorService;
+    }
+
+    /**
+     * 获取人员列表
+     */
+//    @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 = "添加人员",notes = "请求参数:TAppUserDTO对象",response = TAppUserDTO.class)
+    @PostMapping(value = "/api/t-app-user/addUser")
+    public R<?> addUser(@RequestBody String param) {
+        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 = "编辑人员", response = TAppUser.class)
+    @PostMapping(value = "/api/t-app-user/updateUser")
+    public R<?> updateUser(@RequestBody String param) {
+        TAppUserDTO dto = JSON.parseObject(param, TAppUserDTO.class);
+        if (appUserService.isExit(dto)) {
+            return R.fail("该账号已存在");
+        }
+        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) {
+        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) {
+        UpAndDownDTO dto = JSON.parseObject(param, UpAndDownDTO.class);
+        TAppUser appUser = appUserService.getById(dto.getId());
+        appUser.setStatus(dto.getStatus());
+        appUserService.updateById(appUser);
+        return R.ok();
+    }
+
+
+    /**
+     * 禁用/启用
+     */
+    //    @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
+    @ApiOperation(value = "重置密码")
+    @PostMapping(value = "/api/t-app-user/resetPwd")
+    public R<?> resetPwd(@RequestBody String param) {
+        UserIdDto dto = JSON.parseObject(param, UserIdDto.class);
+        TAppUser appUser = appUserService.getById(dto.getId());
+        String pwd = SecurityUtils.encryptPassword("123456");
+        appUser.setPassword(pwd);
+        appUserService.updateById(appUser);
+        return R.ok();
+    }
+
+
+
+
+    /**
+     * 获取人员审核管理分页列表
+     */
+    //    @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);
+        return R.ok(appUserService.pageAuditList(query));
+    }
+
+
+    /**
+     * 获取人员审核管理详情
+     */
+    //    @PreAuthorize("@ss.hasPermi('system:user:auditDetail')")
+    @ApiOperation(value = "获取人员审核管理详情", response = TAppUserPageVo.class)
+    @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());
+        return R.ok(tAppUser);
+    }
+
+
 }
 

--
Gitblit v1.7.1