From e5c227d7992ca6171b998ed2b73b1f0cbaf1ccfe Mon Sep 17 00:00:00 2001
From: whycxzp <perryhsu@163.com>
Date: 星期五, 18 十二月 2020 17:30:09 +0800
Subject: [PATCH] update basic function

---
 src/main/java/com/whyc/controller/RoleController.java |   93 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 86 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/whyc/controller/RoleController.java b/src/main/java/com/whyc/controller/RoleController.java
index 293d1c1..c0d20f1 100644
--- a/src/main/java/com/whyc/controller/RoleController.java
+++ b/src/main/java/com/whyc/controller/RoleController.java
@@ -1,21 +1,100 @@
 package com.whyc.controller;
 
+import com.whyc.pojo.*;
+import com.whyc.service.RolePrivilegeService;
+import com.whyc.service.RoleService;
+import com.whyc.service.UserRoleService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
 
 @RequestMapping("role")
 @RestController
 @Slf4j
-@Api(value ="role value",tags = "瑙掕壊")
+@Api(value ="role value",tags = "瑙掕壊鐩稿叧-鐢ㄦ埛,鏉冮檺,鑿滃崟")
 public class RoleController {
 
-    @GetMapping
-    @ApiOperation(value = "鏌ヨ")
-    public void get(){
+    @Autowired
+    private RoleService roleService;
 
+    @Autowired
+    private UserRoleService userRoleService;
+
+    @Autowired
+    private RolePrivilegeService rolePrivilegeService;
+
+    @GetMapping("userWithNoRole")
+    @ApiOperation(value = "鏌ヨ鏈垎閰嶈鑹茬殑鐢ㄦ埛")
+    public List<User> getUserWithNoRole(){
+        return userRoleService.getUserWithNoRole();
     }
+
+    @GetMapping("userWithRole")
+    @ApiOperation(value = "鏌ヨ鍒嗛厤瑙掕壊鐨勭敤鎴�")
+    public List<UserRole> getUserWithRole(){
+        return userRoleService.getUserWithRole();
+    }
+
+    @GetMapping("userWithRoleMap")
+    @ApiOperation(value = "鏌ヨ鍒嗛厤瑙掕壊鐨勭敤鎴稭ap")
+    public Map<String,List<UserRole>> getUserWithRoleMap(){
+        return userRoleService.getUserWithRoleMap();
+    }
+
+    @GetMapping("roleAll")
+    @ApiOperation(value = "鏌ヨ鎵�鏈夎鑹�")
+    public List<Role> getRoleAll(){
+        return roleService.getAll();
+    }
+
+    @PostMapping
+    @ApiOperation(value = "鏂板瑙掕壊")
+    public boolean add(@RequestBody Role role){
+        return roleService.add(role);
+    }
+
+    @PostMapping("batch")
+    @ApiOperation(value = "鎵归噺鏂板瑙掕壊")
+    public boolean addBatch(@RequestBody List<Role> roles){
+        return roleService.addBatch(roles);
+    }
+
+    @PostMapping("bindingUserWithRole")
+    @ApiOperation(value = "缁戝畾鐢ㄦ埛鍜岃鑹�")
+    public boolean bindingUserWithRole(@RequestParam int userId,int roleId){
+        return userRoleService.bindingUserWithRole(userId,roleId);
+    }
+
+    @PostMapping("bindingUserWithRoleBatch")
+    @ApiOperation(value = "鎵归噺缁戝畾鐢ㄦ埛鍜岃鑹�",notes = "浼犲叆userId鍜宺oleId鐨勬暟缁�")
+    public boolean bindingUserWithRoleBatch(@RequestBody List<UserRole> userRoles){
+        return userRoleService.bindingUserWithRoleBatch(userRoles);
+    }
+
+    @PostMapping("bindingRoleWithPrivilege")
+    @ApiOperation(value = "缁戝畾瑙掕壊-鏉冮檺")
+    public boolean bindingRoleWithPrivilege(@RequestParam int roleId,int privilegeId){
+        return rolePrivilegeService.bindingUserWithRole(roleId,privilegeId);
+    }
+
+    @PostMapping("bindingRoleWithPrivilegeBatch")
+    @ApiOperation(value = "鎵归噺缁戝畾瑙掕壊-鏉冮檺",notes = "浼犲叆roleId鍜宲rivilegeId鐨勬暟缁�")
+    public boolean bindingRoleWithPrivilegeBatch(@RequestBody List<RolePrivilege> rolePrivileges){
+        return rolePrivilegeService.bindingUserWithRoleBatch(rolePrivileges);
+    }
+
+    @GetMapping("privilege")
+    @ApiOperation(value = "鑾峰彇褰撳墠鐢ㄦ埛鐨勬潈闄�")
+    public List<Privilege> getPrivileges(HttpServletRequest request){
+        User user = (User) request.getSession().getAttribute("user");
+        return rolePrivilegeService.getPrivileges(user.getId());
+    }
+
+
 }

--
Gitblit v1.9.1