From 0414ddb0b2b3a7199ae6181a770f97ac140dbd73 Mon Sep 17 00:00:00 2001
From: zhangf <1603559716@qq.com>
Date: 星期三, 08 五月 2024 16:46:22 +0800
Subject: [PATCH] spi统计

---
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java |   74 ++++++++++++++++++++++++++++++++++++-
 1 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java
index a7d00ff..af1e7c5 100644
--- a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java
@@ -1,15 +1,29 @@
 package com.gkhy.safePlatform.accountController;
 
+import com.alibaba.fastjson.JSONObject;
+import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
 import com.gkhy.safePlatform.account.rpc.apimodel.AccountMenuService;
 import com.gkhy.safePlatform.account.rpc.apimodel.AccountUserService;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.req.AccountAddRPCReqDTO;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.req.AccountModRPCReqDTO;
 import com.gkhy.safePlatform.account.rpc.apimodel.model.req.query.AccountRPCQuery;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepUserRPCRespDTO;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.PersonalDetailRPCRespDTO;
+import com.gkhy.safePlatform.commons.co.ContextCacheUser;
+import com.gkhy.safePlatform.commons.enums.ResultCodes;
 import com.gkhy.safePlatform.commons.query.PageQuery;
+import com.gkhy.safePlatform.commons.vo.ResultVO;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.dubbo.config.annotation.DubboService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.security.core.Authentication;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.security.Principal;
+import java.util.List;
 
 @RestController
 @RequestMapping("/account")
@@ -19,8 +33,64 @@
     private AccountUserService accountUserService;
 
 
+
     @RequestMapping("/page/list")
-    public Object getUserPage(Principal principal, PageQuery<AccountRPCQuery> rpcQueryPageQuery) {
-        return accountUserService.getAccountPage(Long.valueOf(principal.getName()), rpcQueryPageQuery);
+    public Object getUserPage(Authentication authentication, PageQuery<AccountRPCQuery> rpcQueryPageQuery) {
+        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+        return accountUserService.getAccountPage(currentUser.getUid(), rpcQueryPageQuery);
+    }
+
+
+    /**
+     * @Description: 获取部门下的用户列表
+     */
+    @RequestMapping(value = "/dep/list", method = RequestMethod.GET)
+    public ResultVO<List<DepUserRPCRespDTO>> depUserList(Authentication authentication, Long depId) {
+        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+        return accountUserService.getDepList(currentUser.getUid(), depId);
+    }
+
+    /**
+     * @Description: 个人信息
+     */
+    @RequestMapping(value = "/personal", method = RequestMethod.GET)
+    public ResultVO<PersonalDetailRPCRespDTO> getPersonal(Authentication authentication) {
+        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+        return accountUserService.getPersonalAccountDetail(currentUser.getUid());
+    }
+
+
+    /**
+     * @Description: 新增用户信息
+     */
+    @RequestMapping(value = "/add", method = RequestMethod.POST)
+    @PreAuthorize("hasRole('ROLE_admin')")
+    public ResultVO<String> addUser(Authentication authentication, @RequestBody AccountAddRPCReqDTO accountAddRPCReqDTO) {
+        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+        return  accountUserService.addAccount(currentUser, accountAddRPCReqDTO);
+    }
+
+
+    /**
+     * @Description: 修改用户信息
+     */
+
+    @RequestMapping(value = "/mod", method = RequestMethod.POST)
+    @PreAuthorize("hasRole('ROLE_admin')")
+    public ResultVO<String> modUser(Authentication authentication, @RequestBody AccountModRPCReqDTO accountModRPCReqDTO) {
+        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+        return accountUserService.modAccount(currentUser, accountModRPCReqDTO);
+    }
+
+
+    /**
+     * @Description: 删除用户信息
+     */
+    @RequestMapping(value = "/del", method = RequestMethod.POST)
+    @PreAuthorize("hasRole('ROLE_admin')")
+    public ResultVO<String> delUser(Authentication authentication, @RequestBody JSONObject json) {
+        Long uid = json.getLong("uid");
+        ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal();
+        return accountUserService.delAccount(currentUser, uid);
     }
 }

--
Gitblit v1.9.2