From 482c178f89c516440628acb70b2f050747f00449 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期五, 01 十二月 2023 08:09:48 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/CanadaMes
---
springboot-vue3/src/main/java/com/example/springboot/controller/RoleController.java | 75 +++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/springboot-vue3/src/main/java/com/example/springboot/controller/RoleController.java b/springboot-vue3/src/main/java/com/example/springboot/controller/RoleController.java
new file mode 100644
index 0000000..f108103
--- /dev/null
+++ b/springboot-vue3/src/main/java/com/example/springboot/controller/RoleController.java
@@ -0,0 +1,75 @@
+package com.example.springboot.controller;
+
+import com.example.springboot.entity.Role;
+import com.example.springboot.entity.vo.Result;
+import com.example.springboot.entity.vo.RoleVo;
+import com.example.springboot.service.RoleService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.apache.shiro.authz.annotation.RequiresRoles;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@Slf4j
+@Api(tags = "瑙掕壊")
+@RequestMapping("/api/role")
+public class RoleController {
+ @Autowired
+ private RoleService roleService;
+
+ @ApiOperation(value = "娣诲姞鎴栬�呮洿鏂拌鑹�")
+ @PostMapping("/saveOrUpdate")
+ @RequiresRoles({"admin"})
+ @RequiresPermissions({"role:add", "role:update"})
+ public Result saveOrUpdate(@RequestBody Role role) {
+ Integer count = roleService.lambdaQuery().eq(Role::getName, role.getName())
+ .ne(role.getId() != null, Role::getId, role.getId())
+ .count();
+ if (count > 0) return Result.fail("宸插瓨鍦ㄨ瑙掕壊鍚嶇О");
+ roleService.saveOrUpdate(role);
+ return Result.success();
+ }
+
+
+ @ApiOperation(value = "鏍规嵁id鍒犻櫎瑙掕壊")
+ @PostMapping("/removeById")
+ @RequiresRoles({"admin"})
+ @RequiresPermissions({"role:delete"})
+ public Result removeById(@RequestBody RoleVo roleVO) {
+ roleService.removeById(roleVO.getId());
+ return Result.success();
+ }
+
+ @ApiOperation(value = "鏍规嵁id鏌ヨ瑙掕壊")
+ @GetMapping("/getById")
+ @RequiresRoles({"admin"})
+ @RequiresPermissions({"role:select"})
+ public Result getById(Role role) {
+ return Result.success(roleService.getById(role.getId()));
+ }
+
+
+
+ @ApiOperation(value = "鍒嗛〉鏌ヨ瑙掕壊")
+ @GetMapping("/selectPage")
+ @RequiresRoles({"admin"})
+ @RequiresPermissions({"role:select"})
+ public Result selectPage(RoleVo roleVO) {
+ return Result.success(roleService.selectPage(roleVO));
+ }
+
+ @ApiOperation(value = "鏌ヨ瑙掕壊鍒楄〃")
+ @GetMapping("/select")
+ @RequiresRoles({"admin"})
+ @RequiresPermissions({"role:select"})
+ public Result select(RoleVo roleVO) {
+ return Result.success(roleService.lambdaQuery().list());
+ }
+}
\ No newline at end of file
--
Gitblit v1.8.0