1.角色接口
This commit is contained in:
@@ -3,13 +3,13 @@ package com.czg.controller;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.service.account.dto.PageDTO;
|
||||
import com.czg.service.account.dto.role.RoleAddDTO;
|
||||
import com.czg.service.account.dto.role.RoleEditDTO;
|
||||
import com.czg.service.account.entity.SysRole;
|
||||
import com.czg.service.account.service.SysRoleService;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -23,14 +23,39 @@ public class RoleController {
|
||||
@Resource
|
||||
private SysRoleService roleService;
|
||||
|
||||
@SaAdminCheckPermission(value = "role.list")
|
||||
/**
|
||||
* 获取角色列表
|
||||
* 权限标识: role:list
|
||||
* @param pageDTO 分页信息
|
||||
* @return 分页数据
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "role:list")
|
||||
@GetMapping("/list")
|
||||
public CzgResult<Page<SysRole>> getList(PageDTO pageDTO) {
|
||||
return CzgResult.success(roleService.getList(pageDTO));
|
||||
}
|
||||
|
||||
@SaAdminCheckPermission(value = "role.add")
|
||||
public CzgResult add(PageDTO pageDTO) {
|
||||
return null;
|
||||
/**
|
||||
* 新增角色
|
||||
* 权限标识: role:add
|
||||
* @param roleAddDTO 角色信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "role:add")
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> add(@RequestBody RoleAddDTO roleAddDTO) {
|
||||
return CzgResult.success(roleService.add(roleAddDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑角色
|
||||
* 权限标识: role:edit
|
||||
* @param roleEditDTO 角色信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission(value = "role:edit")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody RoleEditDTO roleEditDTO) {
|
||||
return CzgResult.success(roleService.edit(roleEditDTO));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,12 @@
|
||||
<artifactId>cash-common-redis</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.czg</groupId>
|
||||
<artifactId>cash-common-sa-token</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.czg.exception;
|
||||
|
||||
import cn.dev33.satoken.exception.NotPermissionException;
|
||||
import com.czg.resp.CzgRespCode;
|
||||
import com.czg.resp.CzgResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -29,6 +30,14 @@ public class CzgControllerAdvice {
|
||||
return CzgResult.failure(CzgRespCode.SYSTEM_ERROR);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(value = NotPermissionException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public CzgResult<Object> notPermissionErrorHandler(NotPermissionException ex) {
|
||||
setErrorLog(ex);
|
||||
return CzgResult.failure(CzgRespCode.UN_PERMISSION);
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
|
||||
Reference in New Issue
Block a user