|
|
@@ -8,16 +8,21 @@ import com.jzg.core.base.BaseController;
|
|
|
import com.jzg.core.page.HttpResult;
|
|
|
import com.jzg.entity.vo.RolePermissionVo;
|
|
|
import com.jzg.entity.vo.SysRoleVo;
|
|
|
+import com.jzg.exception.SystemException;
|
|
|
+import com.jzg.exception.ValidateException;
|
|
|
import com.jzg.service.UserRoleService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.media.Schema;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
-
|
|
|
+/**
|
|
|
+ * 用户角色管理
|
|
|
+ */
|
|
|
@Tag(name="用户角色管理")
|
|
|
@RestController
|
|
|
@RequestMapping("/userRole")
|
|
|
@@ -26,18 +31,6 @@ public class UserRoleController extends BaseController {
|
|
|
@Autowired
|
|
|
UserRoleService userRoleService;
|
|
|
|
|
|
- @GetMapping("/getAllMenu")
|
|
|
- public String getAllMenu(){
|
|
|
- List<RolePermissionVo> allRoleMenu = userRoleService.getAllRoleMenu();
|
|
|
- return JSONObject.toJSONString(allRoleMenu);
|
|
|
- }
|
|
|
-
|
|
|
- @PremissionCheck(value = "power:test")
|
|
|
- @GetMapping("/powerTest")
|
|
|
- public String powerTest(){
|
|
|
- return "powerTest";
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取角色列表
|
|
|
* @param sysRoleVo
|
|
|
@@ -58,13 +51,26 @@ public class UserRoleController extends BaseController {
|
|
|
|
|
|
@Operation(summary = "角色添加")
|
|
|
@PostMapping("/roleAdd")
|
|
|
- public HttpResult roleAdd(@RequestBody SysRoleVo sysRoleVo){
|
|
|
- if(userRoleService.isExist(sysRoleVo.getName())){
|
|
|
- return HttpResult.error("角色名称已存在,请修改后重新提交");
|
|
|
+ public HttpResult roleAdd(@Validated @RequestBody SysRoleVo sysRoleVo){
|
|
|
+ if(userRoleService.isExist(sysRoleVo.getSystem(),sysRoleVo.getName())){
|
|
|
+ throw new ValidateException("角色名称已存在,请修改后重新提交");
|
|
|
}
|
|
|
return userRoleService.roleAdd(sysRoleVo) ? HttpResult.ok("添加角色成功") : HttpResult.error("添加角色失败");
|
|
|
}
|
|
|
|
|
|
+ @Operation(summary = "角色修改")
|
|
|
+ @PostMapping("/roleUpdate")
|
|
|
+ public HttpResult roleUpdate(@Validated @RequestBody SysRoleVo sysRoleVo){
|
|
|
+ if(userRoleService.isExist(sysRoleVo.getSystem(),sysRoleVo.getName(),sysRoleVo.getId())){
|
|
|
+ throw new ValidateException("角色名称已存在,请修改后重新提交");
|
|
|
+ }
|
|
|
+ return userRoleService.roleUpdate(sysRoleVo)? HttpResult.ok("修改角色成功") : HttpResult.error("修改角色失败");
|
|
|
+ }
|
|
|
|
|
|
+ @Operation(summary = "角色删除")
|
|
|
+ @PostMapping("/roleDelete")
|
|
|
+ public HttpResult roleDelete(@RequestBody SysRoleVo roleVo){
|
|
|
+ return userRoleService.roleDelete(roleVo) ? HttpResult.ok("删除角色成功") : HttpResult.error("删除角色失败");
|
|
|
+ }
|
|
|
|
|
|
}
|