diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.http b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.http new file mode 100644 index 000000000..6797f14c5 --- /dev/null +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.http @@ -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}} + +### + diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.java index 92a0bafea..5a4ca8945 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/RoleController.java @@ -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 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> pageRole(RolePageDTO pageDTO) { return success(roleManager.pageRole(pageDTO)); diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/dto/RolePageDTO.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/dto/RolePageDTO.java index 63901bd4f..db1b5d8f9 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/dto/RolePageDTO.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/permission/dto/RolePageDTO.java @@ -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; diff --git a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/RoleManager.java b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/RoleManager.java index e5c0512e0..480e578b6 100644 --- a/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/RoleManager.java +++ b/management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/permission/RoleManager.java @@ -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 createRoleResult = roleRpc.createRole(RoleConvert.INSTANCE.convert(createDTO)); + public Integer createRole(RoleCreateDTO createDTO, Integer createAdminId) { + CommonResult createRoleResult = roleRpc.createRole(RoleConvert.INSTANCE.convert(createDTO).setCreateAdminId(createAdminId)); createRoleResult.checkError(); return createRoleResult.getData(); } diff --git a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java index 63e1d1cb2..bcf233cd9 100644 --- a/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java +++ b/system-service-project/system-service-api/src/main/java/cn/iocoder/mall/systemservice/enums/SystemErrorCodeEnum.java @@ -70,7 +70,7 @@ public enum SystemErrorCodeEnum implements ServiceExceptionUtil.Enumerable convertList02(List list); + @Mapping(source = "records", target = "list") PageResult convertPage(IPage page); PageResult convertPage(PageResult page); diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/permission/RoleDO.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/permission/RoleDO.java index 610633628..7e5404a8b 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/permission/RoleDO.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/dal/mysql/dataobject/permission/RoleDO.java @@ -37,5 +37,9 @@ public class RoleDO extends DeletableDO { * 关联 {@link RoleTypeEnum} */ private Integer type; + /** + * 创建管理员编号 + */ + private Integer createAdminId; } diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/permission/RoleManager.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/permission/RoleManager.java index b176fa4aa..5804224c7 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/permission/RoleManager.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/manager/permission/RoleManager.java @@ -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; diff --git a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/permission/RoleRpcImpl.java b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/permission/RoleRpcImpl.java index 032023ed2..b7cead32b 100644 --- a/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/permission/RoleRpcImpl.java +++ b/system-service-project/system-service-app/src/main/java/cn/iocoder/mall/systemservice/rpc/permission/RoleRpcImpl.java @@ -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; diff --git a/system-service-project/system-service-app/src/main/resources/application.yaml b/system-service-project/system-service-app/src/main/resources/application.yaml index 42a6e2368..3ad04327a 100644 --- a/system-service-project/system-service-app/src/main/resources/application.yaml +++ b/system-service-project/system-service-app/src/main/resources/application.yaml @@ -41,3 +41,5 @@ dubbo: version: 1.0.0 ResourceRpc: version: 1.0.0 + RoleRpc: + version: 1.0.0 diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/AccessLogAddDTO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/AccessLogAddDTO.java deleted file mode 100644 index a56628ea5..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/AccessLogAddDTO.java +++ /dev/null @@ -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; - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/ExceptionLogAddDTO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/ExceptionLogAddDTO.java deleted file mode 100644 index d9952a0d8..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/system/ExceptionLogAddDTO.java +++ /dev/null @@ -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; - -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserUpdateDTO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserUpdateDTO.java deleted file mode 100644 index c2216e8a8..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserUpdateDTO.java +++ /dev/null @@ -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; -} diff --git a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserUpdateStatusDTO.java b/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserUpdateStatusDTO.java deleted file mode 100644 index 8ee05e0b0..000000000 --- a/system/system-biz/src/main/java/cn/iocoder/mall/system/biz/dto/user/UserUpdateStatusDTO.java +++ /dev/null @@ -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; -}