From dc31792dc1b8ad1658e49ba8fce9a1be924e6fbb Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期四, 30 十一月 2023 08:44:04 +0800
Subject: [PATCH] 理片笼测试修改

---
 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