重构,增加 Permission 相关模块,更加清晰
This commit is contained in:
@@ -42,7 +42,7 @@ public class PassportController {
|
||||
|
||||
@GetMapping("/info")
|
||||
@ApiOperation(value = "获得当前管理员信息")
|
||||
public CommonResult<PassportAdminVO> info() {
|
||||
public CommonResult<PassportAdminVO> getInfo() {
|
||||
return success(passportManager.getAdmin(AdminSecurityContextHolder.getAdminId()));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.iocoder.mall.managementweb.controller.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.managementweb.manager.permission.PermissionManager;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 权限 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/permission")
|
||||
@Api(tags = "权限")
|
||||
@Validated
|
||||
public class PermissionController {
|
||||
|
||||
@Autowired
|
||||
private PermissionManager permissionManager;
|
||||
|
||||
@GetMapping("/list-role-resource")
|
||||
@ApiOperation("获得角色拥有的资源编号")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色编号", required = true)
|
||||
public CommonResult<Set<Integer>> listRoleResource(Integer roleId) {
|
||||
return success(permissionManager.listRoleResource(roleId));
|
||||
}
|
||||
|
||||
public CommonResult<Boolean> assignRoleResource() {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -55,13 +55,14 @@ public class RoleController {
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得角色")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色编号", required = true)
|
||||
public CommonResult<RoleVO> getRole(@RequestParam("roleId") Integer roleId) {
|
||||
return success(roleManager.getRole(roleId));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得角色列表")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色编号列表", required = true)
|
||||
@ApiImplicitParam(name = "roleIds", value = "角色编号列表", required = true)
|
||||
public CommonResult<List<RoleVO>> getRoles(@RequestParam("roleIds") List<Integer> roleIds) {
|
||||
return success(roleManager.listRole(roleIds));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Set;
|
||||
|
||||
@ApiModel("赋予角色资源 DTO")
|
||||
@Data
|
||||
public class PermissionAssignRoleResourceDTO {
|
||||
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "管理员")
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Integer roleId;
|
||||
@ApiModelProperty(value = "资源编号列表", required = true, example = "1,3,5")
|
||||
private Set<Integer> resourceIds;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user