From fea25a3ca8897f415f2a8cc14e5c9497a828d32e Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期五, 08 七月 2022 11:05:32 +0800
Subject: [PATCH] UP

---
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/RoleController.java       |   61 ++++++++++++++++++++
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/UserController.java       |   48 ++++++++++++++++
 safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/DepartmentController.java |   57 +++++++++++++++++++
 3 files changed, 166 insertions(+), 0 deletions(-)

diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/DepartmentController.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/DepartmentController.java
new file mode 100644
index 0000000..3bc2502
--- /dev/null
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/DepartmentController.java
@@ -0,0 +1,57 @@
+package com.gkhy.safePlatform.accountController;
+
+import com.alibaba.fastjson.JSONObject;
+import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService;
+import com.gkhy.safePlatform.account.rpc.apimodel.AccountDepartmentService;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.req.DepAddRPCReqDTO;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.req.DepModRPCReqDTO;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.DepRPCRespDTO;
+import com.gkhy.safePlatform.commons.enums.ResultCodes;
+import com.gkhy.safePlatform.commons.vo.ResultVO;
+import org.apache.dubbo.config.annotation.DubboReference;
+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("/department")
+public class DepartmentController {
+
+
+    @DubboReference(check = false)
+    private AccountDepartmentService accountDepartmentService;
+
+
+    @RequestMapping(value = "/list",method = RequestMethod.POST)
+    public ResultVO<List<DepRPCRespDTO>> getListTree(){
+        return accountDepartmentService.depList();
+    }
+
+
+    @RequestMapping(value = "/add", method = RequestMethod.POST)
+    public ResultVO<String> addDepartment(Principal principal, @RequestBody DepAddRPCReqDTO depAddRPCReqDTO) {
+        String userId = principal.getName();
+        return accountDepartmentService.addDep(Long.valueOf(userId) , depAddRPCReqDTO);
+    }
+
+
+    @RequestMapping(value = "/mod", method = RequestMethod.POST)
+    public ResultVO<String> addDepartment(Principal principal, @RequestBody DepModRPCReqDTO depModRPCReqDTO) {
+        String userId = principal.getName();
+        return accountDepartmentService.modDep(Long.valueOf(userId) , depModRPCReqDTO);
+    }
+
+
+    @RequestMapping(value = "/del", method = RequestMethod.POST)
+    public ResultVO<String> addDepartment(Principal principal, @RequestBody JSONObject json) {
+        String userId = principal.getName();
+        Long depId = json.getLong("depId");
+        return accountDepartmentService.delDep(Long.valueOf(userId) , depId);
+    }
+
+
+}
diff --git a/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/RoleController.java b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/RoleController.java
new file mode 100644
index 0000000..d8946cc
--- /dev/null
+++ b/safePlatfrom-out-web/src/main/java/com/gkhy/safePlatform/accountController/RoleController.java
@@ -0,0 +1,61 @@
+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.AccountRoleService;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.req.RoleAddRPCReqDTO;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.req.RoleModRPCReqDTO;
+import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.RoleRPCRespDTO;
+import com.gkhy.safePlatform.commons.enums.ResultCodes;
+import com.gkhy.safePlatform.commons.vo.ResultVO;
+import org.apache.dubbo.config.annotation.DubboReference;
+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("/role")
+public class RoleController {
+
+    @DubboReference(check = false)
+    private AccountRoleService accountRoleService;
+
+
+    /**
+     * @Description: 获取所有启用角色
+     */
+
+    @RequestMapping(value = "/list",method = RequestMethod.POST)
+    public ResultVO<List<RoleRPCRespDTO>> addRole(Principal principal){
+        return accountRoleService.getRoleList();
+    }
+
+
+
+
+    @RequestMapping(value = "/add",method = RequestMethod.POST)
+    public ResultVO<String> addRole(Principal principal, RoleAddRPCReqDTO roleAddRPCReqDTO){
+        String userId = principal.getName();
+        return accountRoleService.addRole(Long.valueOf(userId),roleAddRPCReqDTO);
+    }
+
+
+
+    @RequestMapping(value = "/mod",method = RequestMethod.POST)
+    public ResultVO<String> modRole(Principal principal, RoleModRPCReqDTO roleModRPCReqDTO){
+        String userId = principal.getName();
+        return accountRoleService.modRole(Long.valueOf(userId),roleModRPCReqDTO);
+    }
+
+
+    @RequestMapping(value = "/del",method = RequestMethod.POST)
+    public ResultVO<String> modRole(Principal principal, JSONObject json){
+        String userId = principal.getName();
+        Long depId = json.getLong("depId");
+        return accountRoleService.delRole(Long.valueOf(userId),depId);
+    }
+}
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 48258a7..2d677b9 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,21 @@
 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.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.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;
@@ -41,5 +47,47 @@
         return accountUserService.getDepList(Long.valueOf(userId), depId);
     }
 
+    /**
+     * @Description: 个人信息
+     */
+    @RequestMapping(value = "/personal", method = RequestMethod.GET)
+    public ResultVO<PersonalDetailRPCRespDTO> getPersonal(Principal principal) {
+        String userId = principal.getName();
+        return accountUserService.getPersonalAccountDetail(Long.valueOf(userId));
+    }
 
+
+    /**
+     * @Description: 新增用户信息
+     */
+    @RequestMapping(value = "/add", method = RequestMethod.POST)
+    @PreAuthorize("hasRole('ROLE_admin')")
+    public ResultVO<String> addUser(Principal principal, @RequestBody AccountAddRPCReqDTO accountAddRPCReqDTO) {
+        String userId = principal.getName();
+        return  accountUserService.addAccount(Long.valueOf(userId), accountAddRPCReqDTO);
+    }
+
+
+    /**
+     * @Description: 修改用户信息
+     */
+
+    @RequestMapping(value = "/mod", method = RequestMethod.POST)
+    @PreAuthorize("hasRole('ROLE_admin')")
+    public ResultVO<String> modUser(Principal principal, @RequestBody AccountModRPCReqDTO accountModRPCReqDTO) {
+        String userId = principal.getName();
+        return accountUserService.modAccount(Long.valueOf(userId), accountModRPCReqDTO);
+    }
+
+
+    /**
+     * @Description: 删除用户信息
+     */
+    @RequestMapping(value = "/del", method = RequestMethod.POST)
+    @PreAuthorize("hasRole('ROLE_admin')")
+    public ResultVO<String> delUser(Principal principal, @RequestBody JSONObject json) {
+        Long uid = json.getLong("uid");
+        String userId = principal.getName();
+        return accountUserService.delAccount(Long.valueOf(userId), uid);
+    }
 }

--
Gitblit v1.9.2