From 3e3d04c82f35561e18fed8b63bff8cb3351fb892 Mon Sep 17 00:00:00 2001
From: 13693261870 <252740454@qq.com>
Date: 星期三, 12 十月 2022 09:44:34 +0800
Subject: [PATCH] 1

---
 src/main/java/com/lf/server/controller/sys/RoleController.java |   63 ++++++++++++++++++++++---------
 1 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/src/main/java/com/lf/server/controller/sys/RoleController.java b/src/main/java/com/lf/server/controller/sys/RoleController.java
index 9e92de2..edc7f2c 100644
--- a/src/main/java/com/lf/server/controller/sys/RoleController.java
+++ b/src/main/java/com/lf/server/controller/sys/RoleController.java
@@ -4,7 +4,9 @@
 import com.lf.server.controller.all.BaseController;
 import com.lf.server.entity.all.ResponseMsg;
 import com.lf.server.entity.sys.RoleEntity;
+import com.lf.server.entity.sys.UserEntity;
 import com.lf.server.service.sys.RoleService;
+import com.lf.server.service.sys.TokenService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -12,6 +14,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 
 /**
@@ -25,6 +28,9 @@
 public class RoleController extends BaseController {
     @Autowired
     RoleService roleService;
+
+    @Autowired
+    TokenService tokenService;
 
     @SysLog()
     @ApiOperation(value = "鏌ヨ璁板綍鏁�")
@@ -93,14 +99,19 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鎻掑叆瀛楀吀")
+    @ApiOperation(value = "鎻掑叆涓�鏉�")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "roleEntity", value = "瀛楀吀瀹炰綋绫�", dataType = "com.lf.server.entity.sys.RoleEntity", paramType = "body", example = "")
+            @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "com.lf.server.entity.sys.RoleEntity", paramType = "body", example = "")
     })
     @PostMapping(value = "/insertRole", produces = "application/json; charset=UTF-8")
-    public ResponseMsg<Integer> insertRole(@RequestBody RoleEntity roleEntity) {
+    public ResponseMsg<Integer> insertRole(@RequestBody RoleEntity entity, HttpServletRequest req) {
         try {
-            int count = roleService.insertRole(roleEntity);
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (ue != null) {
+                entity.setCreateUser(ue.getId());
+            }
+
+            int count = roleService.insertRole(entity);
 
             return success(count);
         } catch (Exception ex) {
@@ -109,14 +120,21 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鎻掑叆澶氭潯瀛楀吀")
+    @ApiOperation(value = "鎻掑叆澶氭潯")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "roleEntity", value = "瀛楀吀瀹炰綋绫婚泦鍚�", dataType = "List<RoleEntity>", paramType = "body", example = "")
+            @ApiImplicitParam(name = "list", value = "瀹炰綋绫婚泦鍚�", dataType = "List<RoleEntity>", paramType = "body", example = "")
     })
     @PostMapping(value = "/insertRoles", produces = "application/json; charset=UTF-8")
-    public ResponseMsg<Integer> insertRoles(@RequestBody List<RoleEntity> roleEntity) {
+    public ResponseMsg<Integer> insertRoles(@RequestBody List<RoleEntity> list, HttpServletRequest req) {
         try {
-            int count = roleService.insertRoles(roleEntity);
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (ue != null) {
+                for (RoleEntity entity : list) {
+                    entity.setCreateUser(ue.getId());
+                }
+            }
+
+            int count = roleService.insertRoles(list);
 
             return success(count);
         } catch (Exception ex) {
@@ -125,9 +143,9 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鍒犻櫎涓�鏉″瓧鍏�")
+    @ApiOperation(value = "鍒犻櫎涓�鏉�")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "瀛楀吀ID", dataType = "Integer", paramType = "query", example = "1")
+            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
     })
     @GetMapping(value = "/deleteRole")
     public ResponseMsg<Integer> deleteRole(int id) {
@@ -141,9 +159,9 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鍒犻櫎澶氭潯瀛楀吀")
+    @ApiOperation(value = "鍒犻櫎澶氭潯")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", value = "瀛楀吀ID闆嗗悎", dataType = "List<Integer>", paramType = "query", example = "1,2")
+            @ApiImplicitParam(name = "ids", value = "ID鏁扮粍", dataType = "List<Integer>", paramType = "query", example = "1,2")
     })
     @GetMapping(value = "/deleteAuths")
     public ResponseMsg<Integer> deleteRoles(@RequestParam List<Integer> ids) {
@@ -151,7 +169,9 @@
             if (ids == null || ids.isEmpty()) {
                 return fail("id鏁扮粍涓嶈兘涓虹┖", -1);
             }
+
             int count = roleService.deleteRoles(ids);
+
             return success(count);
         } catch (Exception ex) {
             return fail(ex.getMessage(), -1);
@@ -159,15 +179,20 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鏇存柊涓�鏉″瓧鍏�")
+    @ApiOperation(value = "鏇存柊涓�鏉�")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "roleEntity", value = "瀛楀吀ID闆嗗悎", dataType = "RoleEntity", paramType = "body", example = "")
+            @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "RoleEntity", paramType = "body", example = "")
     })
     @ResponseBody
     @PostMapping(value = "/updateRole", produces = "application/json; charset=UTF-8")
-    public ResponseMsg<Integer> updateRole(@RequestBody RoleEntity roleEntity) {
+    public ResponseMsg<Integer> updateRole(@RequestBody RoleEntity entity, HttpServletRequest req) {
         try {
-            int count = roleService.updateRole(roleEntity);
+            UserEntity ue = tokenService.getCurrentUser(req);
+            if (ue != null) {
+                entity.setUpdateUser(ue.getId());
+            }
+
+            int count = roleService.updateRole(entity);
 
             return success(count);
         } catch (Exception ex) {
@@ -176,9 +201,9 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鏍规嵁ID鏌ヨ瀛楀吀")
+    @ApiOperation(value = "鏍规嵁ID鏌ヨ")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "瀛楀吀ID", dataType = "Integer", paramType = "query", example = "1")
+            @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1")
     })
     @GetMapping(value = "/selectRole")
     public ResponseMsg<RoleEntity> selectRole(int id) {
@@ -192,7 +217,7 @@
     }
 
     @SysLog()
-    @ApiOperation(value = "鏌ヨ鎵�鏈夊瓧鍏�")
+    @ApiOperation(value = "鏌ヨ鎵�鏈�")
     @GetMapping(value = "/selectRoleAll")
     public ResponseMsg<List<RoleEntity>> selectRoleAll() {
         try {

--
Gitblit v1.9.3