完成角色模块的改造
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
package cn.iocoder.mall.managementweb.controller.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.RoleCreateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.RolePageDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.dto.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.RoleVO;
|
||||
import cn.iocoder.mall.managementweb.manager.permission.RoleManager;
|
||||
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.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 角色 Controller
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
@Api(tags = "角色")
|
||||
@Validated
|
||||
public class RoleController {
|
||||
|
||||
@Autowired
|
||||
private RoleManager roleManager;
|
||||
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建角色")
|
||||
public CommonResult<Integer> createRole(@Valid RoleCreateDTO createDTO) {
|
||||
return success(roleManager.createRole(createDTO));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新角色")
|
||||
public CommonResult<Boolean> updateRole(@Valid RoleUpdateDTO updateDTO) {
|
||||
roleManager.updateRole(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除角色")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色编号", required = true)
|
||||
public CommonResult<Boolean> deleteRole(@RequestParam("roleId") Integer roleId) {
|
||||
roleManager.deleteRole(roleId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@ApiOperation("获得角色")
|
||||
public CommonResult<RoleVO> getRole(@RequestParam("roleId") Integer roleId) {
|
||||
return success(roleManager.getRole(roleId));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得角色列表")
|
||||
@ApiImplicitParam(name = "roleId", value = "角色编号列表", required = true)
|
||||
public CommonResult<List<RoleVO>> getRoles(@RequestParam("roleIds") List<Integer> roleIds) {
|
||||
return success(roleManager.listRole(roleIds));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("获得角色分页")
|
||||
public CommonResult<PageResult<RoleVO>> pageRole(RolePageDTO pageDTO) {
|
||||
return success(roleManager.pageRole(pageDTO));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
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.NotEmpty;
|
||||
|
||||
@ApiModel("角色创建 DTO")
|
||||
@Data
|
||||
public class RoleCreateDTO {
|
||||
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "管理员")
|
||||
@NotEmpty(message = "角色名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "角色编码", example = "ADMIN")
|
||||
private String code;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("角色分页 DTO")
|
||||
@Data
|
||||
public class RolePageDTO {
|
||||
|
||||
@ApiModelProperty(value = "角色名", example = "管理", notes = "模糊匹配")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("角色更新 DTO")
|
||||
@Data
|
||||
public class RoleUpdateDTO {
|
||||
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1")
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "管理员")
|
||||
@NotEmpty(message = "角色名不能为空")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "角色编码", example = "ADMIN")
|
||||
private String code;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.iocoder.mall.managementweb.controller.permission.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel("角色 VO")
|
||||
@Data
|
||||
public class RoleVO {
|
||||
|
||||
@ApiModelProperty(value = "角色编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "角色名", required = true, example = "管理员")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "角色编码", example = "ADMIN")
|
||||
private String code;
|
||||
@ApiModelProperty(value = "角色类型", required = true, example = "1", notes = "见 RoleTypeEnum 枚举")
|
||||
private Integer type;
|
||||
@ApiModelProperty(value = "创建管理员编号", required = true, example = "1")
|
||||
private Integer createAdminId;
|
||||
@ApiModelProperty(value = "创建时间", required = true)
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user