完成角色模块的改造
This commit is contained in:
parent
eee0444e81
commit
e4d3254869
@ -0,0 +1,38 @@
|
||||
### /role/create 成功
|
||||
POST {{baseUrl}}/role/create
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
|
||||
name=测试角色
|
||||
|
||||
### /role/update 成功
|
||||
POST {{baseUrl}}/role/update
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
|
||||
id=14&name=test
|
||||
|
||||
### /resource/delete 成功
|
||||
POST {{baseUrl}}/role/delete
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
|
||||
roleId=14
|
||||
|
||||
### /role/get 成功
|
||||
GET {{baseUrl}}/role/get?roleId=13
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
|
||||
### /role/list 成功
|
||||
GET {{baseUrl}}/role/list?roleIds=1,13
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
|
||||
### /role/page 成功
|
||||
GET {{baseUrl}}/role/page?pageNo=1&pageSize=10
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Authorization: Bearer {{accessToken}}
|
||||
|
||||
###
|
||||
|
@ -7,6 +7,7 @@ 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 cn.iocoder.mall.security.admin.core.context.AdminSecurityContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@ -34,7 +35,7 @@ public class RoleController {
|
||||
@PostMapping("/create")
|
||||
@ApiOperation("创建角色")
|
||||
public CommonResult<Integer> createRole(@Valid RoleCreateDTO createDTO) {
|
||||
return success(roleManager.createRole(createDTO));
|
||||
return success(roleManager.createRole(createDTO, AdminSecurityContextHolder.getAdminId()));
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ -65,7 +66,7 @@ public class RoleController {
|
||||
return success(roleManager.listRole(roleIds));
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("获得角色分页")
|
||||
public CommonResult<PageResult<RoleVO>> pageRole(RolePageDTO pageDTO) {
|
||||
return success(roleManager.pageRole(pageDTO));
|
||||
|
@ -1,12 +1,13 @@
|
||||
package cn.iocoder.mall.managementweb.controller.permission.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel("角色分页 DTO")
|
||||
@Data
|
||||
public class RolePageDTO {
|
||||
public class RolePageDTO extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "角色名", example = "管理", notes = "模糊匹配")
|
||||
private String name;
|
||||
|
@ -19,7 +19,7 @@ import java.util.List;
|
||||
@Service
|
||||
public class RoleManager {
|
||||
|
||||
@Reference(version = "$ {dubbo.consumer.RoleRpc.version}", validation = "false")
|
||||
@Reference(version = "${dubbo.consumer.RoleRpc.version}", validation = "false")
|
||||
private RoleRpc roleRpc;
|
||||
|
||||
/**
|
||||
@ -28,8 +28,8 @@ public class RoleManager {
|
||||
* @param createDTO 创建角色 DTO
|
||||
* @return 角色
|
||||
*/
|
||||
public Integer createRole(RoleCreateDTO createDTO) {
|
||||
CommonResult<Integer> createRoleResult = roleRpc.createRole(RoleConvert.INSTANCE.convert(createDTO));
|
||||
public Integer createRole(RoleCreateDTO createDTO, Integer createAdminId) {
|
||||
CommonResult<Integer> createRoleResult = roleRpc.createRole(RoleConvert.INSTANCE.convert(createDTO).setCreateAdminId(createAdminId));
|
||||
createRoleResult.checkError();
|
||||
return createRoleResult.getData();
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public enum SystemErrorCodeEnum implements ServiceExceptionUtil.Enumerable<Syste
|
||||
// ========== 授权模块 1002008000 ==========
|
||||
AUTHORIZATION_PERMISSION_DENY(1002008001, "没有该操作权限"),
|
||||
AUTHORIZATION_DEMO_PERMISSION_DENY(1002008002, "演示账号,暂不允许写操作。欢迎加入我们的交流群:http://t.cn/EKEr5WE"),
|
||||
AUTHORIZATION_ROLE_ASSIGN_RESOURCE_NOT_EXISTS(1002004001, "分配角色资源时,有资源不存在"),
|
||||
AUTHORIZATION_ROLE_ASSIGN_RESOURCE_NOT_EXISTS(1002008004, "分配角色资源时,有资源不存在"),
|
||||
|
||||
// ========== 错误码模块 1002009000 ==========
|
||||
ERROR_CODE_NOT_EXISTS(1002009000, "错误码不存在"),
|
||||
|
@ -3,8 +3,8 @@ package cn.iocoder.mall.systemservice.convert.permission;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.systemservice.dal.mysql.dataobject.permission.RoleDO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.RolePageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO;
|
||||
import cn.iocoder.mall.systemservice.service.permission.bo.RoleBO;
|
||||
import cn.iocoder.mall.systemservice.service.permission.bo.RoleCreateBO;
|
||||
@ -12,6 +12,7 @@ import cn.iocoder.mall.systemservice.service.permission.bo.RolePageBO;
|
||||
import cn.iocoder.mall.systemservice.service.permission.bo.RoleUpdateBO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
@ -39,6 +40,7 @@ public interface RoleConvert {
|
||||
|
||||
List<RoleVO> convertList02(List<RoleBO> list);
|
||||
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<RoleBO> convertPage(IPage<RoleDO> page);
|
||||
|
||||
PageResult<RoleVO> convertPage(PageResult<RoleBO> page);
|
||||
|
@ -37,5 +37,9 @@ public class RoleDO extends DeletableDO {
|
||||
* 关联 {@link RoleTypeEnum}
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 创建管理员编号
|
||||
*/
|
||||
private Integer createAdminId;
|
||||
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package cn.iocoder.mall.systemservice.manager.permission;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.systemservice.convert.permission.RoleConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.RolePageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO;
|
||||
import cn.iocoder.mall.systemservice.service.permission.RoleService;
|
||||
import cn.iocoder.mall.systemservice.service.permission.bo.RoleBO;
|
||||
|
@ -4,8 +4,8 @@ import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.systemservice.manager.permission.RoleManager;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.RolePageDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.dto.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleCreateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleUpdateDTO;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO;
|
||||
import org.apache.dubbo.config.annotation.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -41,3 +41,5 @@ dubbo:
|
||||
version: 1.0.0
|
||||
ResourceRpc:
|
||||
version: 1.0.0
|
||||
RoleRpc:
|
||||
version: 1.0.0
|
||||
|
@ -1,52 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.dto.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 访问日志添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AccessLogAddDTO {
|
||||
|
||||
/**
|
||||
* 用户编号 - 空
|
||||
*/
|
||||
public static final Integer ACCOUNT_ID_NULL = 0;
|
||||
|
||||
/**
|
||||
* 账号编号
|
||||
*/
|
||||
private Integer accountId;
|
||||
/**
|
||||
* 链路编号
|
||||
*/
|
||||
private String traceId;
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
@NotNull(message = "访问地址不能为空")
|
||||
private String uri;
|
||||
@NotNull(message = "请求参数不能为空")
|
||||
private String queryString;
|
||||
@NotNull(message = "http 请求方法不能为空")
|
||||
private String method;
|
||||
@NotNull(message = "User-Agent 不能为空")
|
||||
private String userAgent;
|
||||
@NotNull(message = "ip 不能为空")
|
||||
private String ip;
|
||||
@NotNull(message = "请求时间不能为空")
|
||||
private Date startTime;
|
||||
@NotNull(message = "响应时长不能为空")
|
||||
private Integer responseTime;
|
||||
@NotNull(message = "错误码不能为空")
|
||||
private Integer errorCode;
|
||||
/**
|
||||
* 错误提示
|
||||
*/
|
||||
private String errorMessage;
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.dto.system;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 异常日志添加 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ExceptionLogAddDTO {
|
||||
|
||||
/**
|
||||
* 账号编号
|
||||
*/
|
||||
private Integer accountId;
|
||||
/**
|
||||
* 链路编号
|
||||
*/
|
||||
private String traceId;
|
||||
@NotNull(message = "应用名不能为空")
|
||||
private String applicationName;
|
||||
@NotNull(message = "访问地址不能为空")
|
||||
private String uri;
|
||||
@NotNull(message = "请求参数不能为空")
|
||||
private String queryString;
|
||||
@NotNull(message = "http 请求方法不能为空")
|
||||
private String method;
|
||||
@NotNull(message = "User-Agent 不能为空")
|
||||
private String userAgent;
|
||||
@NotNull(message = "ip 不能为空")
|
||||
private String ip;
|
||||
@NotNull(message = "异常时间不能为空")
|
||||
private Date exceptionTime;
|
||||
@NotNull(message = "异常名不能为空")
|
||||
private String exceptionName;
|
||||
@NotNull(message = "异常发生的类全名不能为空")
|
||||
private String exceptionClassName;
|
||||
@NotNull(message = "异常发生的类文件不能为空")
|
||||
private String exceptionFileName;
|
||||
@NotNull(message = "异常发生的方法名不能为空")
|
||||
private String exceptionMethodName;
|
||||
@NotNull(message = "异常发生的方法所在行不能为空")
|
||||
private Integer exceptionLineNumber;
|
||||
@NotNull(message = "异常的栈轨迹不能为空")
|
||||
private String exceptionStackTrace;
|
||||
@NotNull(message = "异常导致的根消息不能为空")
|
||||
private String exceptionRootCauseMessage;
|
||||
@NotNull(message = "异常导致的消息不能为空")
|
||||
private String exceptionMessage;
|
||||
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.dto.user;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @Author: jiangweifan
|
||||
* @Date: 2020/5/12
|
||||
* @Description: 用户信息 - 更新用户信息DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserUpdateDTO {
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickname;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 用户状态,1 - 启用;2 - 禁用
|
||||
*/
|
||||
private Integer status;
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.dto.user;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* @Author: jiangweifan
|
||||
* @Date: 2020/5/12
|
||||
* @Description: 用户信息 - 更新用户状态DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class UserUpdateStatusDTO {
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
@NotNull(message = "用户编号不能为空")
|
||||
private Integer id;
|
||||
|
||||
/**
|
||||
* 用户状态,1 - 启用;2 - 禁用
|
||||
*/
|
||||
@NotNull(message = "用户状态不能为空")
|
||||
private Integer status;
|
||||
}
|
Loading…
Reference in New Issue
Block a user