完成角色模块的改造
This commit is contained in:
parent
4c4708cc8f
commit
eee0444e81
@ -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;
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.iocoder.mall.managementweb.convert.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.managementweb.controller.permission.vo.RoleVO;
|
||||
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 org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface RoleConvert {
|
||||
|
||||
RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);
|
||||
|
||||
RoleCreateDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.RoleCreateDTO bean);
|
||||
|
||||
RoleUpdateDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.RoleUpdateDTO bean);
|
||||
|
||||
RoleVO convert(cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO bean);
|
||||
|
||||
List<RoleVO> convertList(List<cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO> list);
|
||||
|
||||
RolePageDTO convert(cn.iocoder.mall.managementweb.controller.permission.dto.RolePageDTO bean);
|
||||
|
||||
PageResult<RoleVO> convertPage(PageResult<cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO> page);
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package cn.iocoder.mall.managementweb.manager.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.convert.permission.RoleConvert;
|
||||
import cn.iocoder.mall.systemservice.rpc.permission.RoleRpc;
|
||||
import org.apache.dubbo.config.annotation.Reference;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色 Manager
|
||||
*/
|
||||
@Service
|
||||
public class RoleManager {
|
||||
|
||||
@Reference(version = "$ {dubbo.consumer.RoleRpc.version}", validation = "false")
|
||||
private RoleRpc roleRpc;
|
||||
|
||||
/**
|
||||
* 创建角色
|
||||
*
|
||||
* @param createDTO 创建角色 DTO
|
||||
* @return 角色
|
||||
*/
|
||||
public Integer createRole(RoleCreateDTO createDTO) {
|
||||
CommonResult<Integer> createRoleResult = roleRpc.createRole(RoleConvert.INSTANCE.convert(createDTO));
|
||||
createRoleResult.checkError();
|
||||
return createRoleResult.getData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新角色
|
||||
*
|
||||
* @param updateDTO 更新角色 DTO
|
||||
*/
|
||||
public void updateRole(RoleUpdateDTO updateDTO) {
|
||||
CommonResult<Boolean> updateRoleResult = roleRpc.updateRole(RoleConvert.INSTANCE.convert(updateDTO));
|
||||
updateRoleResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param roleId 角色编号
|
||||
*/
|
||||
public void deleteRole(Integer roleId) {
|
||||
CommonResult<Boolean> deleteRoleResult = roleRpc.deleteRole(roleId);
|
||||
deleteRoleResult.checkError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得角色
|
||||
*
|
||||
* @param roleId 角色编号
|
||||
* @return 角色
|
||||
*/
|
||||
public RoleVO getRole(Integer roleId) {
|
||||
CommonResult<cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO> getRoleResult = roleRpc.getRole(roleId);
|
||||
getRoleResult.checkError();
|
||||
return RoleConvert.INSTANCE.convert(getRoleResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得角色列表
|
||||
*
|
||||
* @param roleIds 角色编号列表
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<RoleVO> listRole(List<Integer> roleIds) {
|
||||
CommonResult<List<cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO>> listRoleResult = roleRpc.listRole(roleIds);
|
||||
listRoleResult.checkError();
|
||||
return RoleConvert.INSTANCE.convertList(listRoleResult.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得角色分页
|
||||
*
|
||||
* @param pageDTO 角色编号列表
|
||||
* @return 角色列表
|
||||
*/
|
||||
public PageResult<RoleVO> pageRole(RolePageDTO pageDTO) {
|
||||
CommonResult<PageResult<cn.iocoder.mall.systemservice.rpc.permission.vo.RoleVO>> pageRoleResult =
|
||||
roleRpc.pageRole(RoleConvert.INSTANCE.convert(pageDTO));
|
||||
pageRoleResult.checkError();
|
||||
return RoleConvert.INSTANCE.convertPage(pageRoleResult.getData());
|
||||
}
|
||||
|
||||
}
|
@ -32,6 +32,8 @@ dubbo:
|
||||
version: 1.0.0
|
||||
ResourceRpc:
|
||||
version: 1.0.0
|
||||
RoleRpc:
|
||||
version: 1.0.0
|
||||
|
||||
# Swagger 配置项
|
||||
swagger:
|
||||
|
@ -0,0 +1,63 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.permission;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
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.RoleVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色 Rpc 接口
|
||||
*/
|
||||
public interface RoleRpc {
|
||||
|
||||
/**
|
||||
* 创建角色
|
||||
*
|
||||
* @param createDTO 创建角色 DTO
|
||||
* @return 角色编号
|
||||
*/
|
||||
CommonResult<Integer> createRole(RoleCreateDTO createDTO);
|
||||
|
||||
/**
|
||||
* 更新角色
|
||||
*
|
||||
* @param updateDTO 更新角色 DTO
|
||||
*/
|
||||
CommonResult<Boolean> updateRole(RoleUpdateDTO updateDTO);
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param roleId 角色编号
|
||||
*/
|
||||
CommonResult<Boolean> deleteRole(Integer roleId);
|
||||
|
||||
/**
|
||||
* 获得角色
|
||||
*
|
||||
* @param roleId 角色编号
|
||||
* @return 角色
|
||||
*/
|
||||
CommonResult<RoleVO> getRole(Integer roleId);
|
||||
|
||||
/**
|
||||
* 获得角色列表
|
||||
*
|
||||
* @param roleIds 角色编号列表
|
||||
* @return 角色列表
|
||||
*/
|
||||
CommonResult<List<RoleVO>> listRole(List<Integer> roleIds);
|
||||
|
||||
|
||||
/**
|
||||
* 获得角色分页
|
||||
*
|
||||
* @param pageDTO 角色分页查询
|
||||
* @return 角色分页结果
|
||||
*/
|
||||
CommonResult<PageResult<RoleVO>> pageRole(RolePageDTO pageDTO);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.permission.dto;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* 角色分页 DTO
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class RolePageDTO extends PageParam {
|
||||
|
||||
/**
|
||||
* 角色名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.permission.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 角色更新 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RoleUpdateDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 角色编号
|
||||
*/
|
||||
@NotNull(message = "角色编号不能为空")
|
||||
private Integer id;
|
||||
/**
|
||||
* 角色名
|
||||
*/
|
||||
@NotEmpty(message = "角色名不能为空")
|
||||
private String name;
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.permission.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 角色创建 DTO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RoleCreateDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 角色名
|
||||
*/
|
||||
@NotEmpty(message = "角色名不能为空")
|
||||
private String name;
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 创建管理员编号
|
||||
*/
|
||||
@NotNull(message = "创建管理员编号不能为空")
|
||||
private Integer createAdminId;
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.permission.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 角色 VO
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class RoleVO implements Serializable {
|
||||
|
||||
/**
|
||||
* 角色编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 角色名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 角色类型
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
* 创建管理员编号
|
||||
*/
|
||||
private Integer createAdminId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 最后更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
@ -2,8 +2,13 @@ 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.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;
|
||||
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;
|
||||
@ -22,8 +27,20 @@ public interface RoleConvert {
|
||||
|
||||
RoleDO convert(RoleUpdateBO bean);
|
||||
|
||||
RoleCreateBO convert(RoleCreateDTO bean);
|
||||
|
||||
RoleUpdateBO convert(RoleUpdateDTO bean);
|
||||
|
||||
RolePageBO convert(RolePageDTO bean);
|
||||
|
||||
RoleVO convert(RoleBO bean);
|
||||
|
||||
List<RoleBO> convertList(List<RoleDO> list);
|
||||
|
||||
List<RoleVO> convertList02(List<RoleBO> list);
|
||||
|
||||
PageResult<RoleBO> convertPage(IPage<RoleDO> page);
|
||||
|
||||
PageResult<RoleVO> convertPage(PageResult<RoleBO> page);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,87 @@
|
||||
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.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;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色 Manager
|
||||
*/
|
||||
@Service
|
||||
public class RoleManager {
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
/**
|
||||
* 创建角色
|
||||
*
|
||||
* @param createDTO 创建角色 DTO
|
||||
* @return 角色
|
||||
*/
|
||||
public Integer createRole(RoleCreateDTO createDTO) {
|
||||
RoleBO roleBO = roleService.createRole(RoleConvert.INSTANCE.convert(createDTO));
|
||||
return roleBO.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新角色
|
||||
*
|
||||
* @param updateDTO 更新角色 DTO
|
||||
*/
|
||||
public void updateRole(RoleUpdateDTO updateDTO) {
|
||||
roleService.updateRole(RoleConvert.INSTANCE.convert(updateDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param roleId 角色编号
|
||||
*/
|
||||
public void deleteRole(Integer roleId) {
|
||||
roleService.deleteRole(roleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得角色
|
||||
*
|
||||
* @param roleId 角色编号
|
||||
* @return 角色
|
||||
*/
|
||||
public RoleVO getRole(Integer roleId) {
|
||||
RoleBO roleBO = roleService.getRole(roleId);
|
||||
return RoleConvert.INSTANCE.convert(roleBO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得角色列表
|
||||
*
|
||||
* @param roleIds 角色编号列表
|
||||
* @return 角色列表
|
||||
*/
|
||||
public List<RoleVO> listRole(List<Integer> roleIds) {
|
||||
List<RoleBO> roleBOs = roleService.listRole(roleIds);
|
||||
return RoleConvert.INSTANCE.convertList02(roleBOs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得角色分页
|
||||
*
|
||||
* @param pageDTO 角色分页查询
|
||||
* @return 角色分页结果
|
||||
*/
|
||||
public PageResult<RoleVO> pageRole(RolePageDTO pageDTO) {
|
||||
PageResult<RoleBO> pageResultBO = roleService.pageRole(RoleConvert.INSTANCE.convert(pageDTO));
|
||||
return RoleConvert.INSTANCE.convertPage(pageResultBO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
package cn.iocoder.mall.systemservice.rpc.permission;
|
||||
|
||||
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.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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.common.framework.vo.CommonResult.success;
|
||||
|
||||
/**
|
||||
* 角色 Rpc 实现类
|
||||
*/
|
||||
@Service(version = "${dubbo.provider.RoleRpc.version}", validation = "false")
|
||||
public class RoleRpcImpl implements RoleRpc {
|
||||
|
||||
@Autowired
|
||||
private RoleManager roleManager;
|
||||
|
||||
@Override
|
||||
public CommonResult<Integer> createRole(RoleCreateDTO createDTO) {
|
||||
return success(roleManager.createRole(createDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> updateRole(RoleUpdateDTO updateDTO) {
|
||||
roleManager.updateRole(updateDTO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> deleteRole(Integer roleId) {
|
||||
roleManager.deleteRole(roleId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<RoleVO> getRole(Integer roleId) {
|
||||
return success(roleManager.getRole(roleId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<List<RoleVO>> listRole(List<Integer> roleIds) {
|
||||
return success(roleManager.listRole(roleIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<PageResult<RoleVO>> pageRole(RolePageDTO pageDTO) {
|
||||
return success(roleManager.pageRole(pageDTO));
|
||||
}
|
||||
|
||||
}
|
@ -42,6 +42,7 @@ public class RoleService {
|
||||
checkDuplicateRole(createBO.getName(), createBO.getCode(), null);
|
||||
// 插入到数据库
|
||||
RoleDO roleDO = RoleConvert.INSTANCE.convert(createBO);
|
||||
roleDO.setType(RoleTypeEnum.CUSTOM.getType());
|
||||
roleMapper.insert(roleDO);
|
||||
// 返回
|
||||
return RoleConvert.INSTANCE.convert(roleDO);
|
||||
|
@ -1,31 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.convert.authorization;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.system.biz.bo.authorization.RoleBO;
|
||||
import cn.iocoder.mall.system.biz.dataobject.authorization.RoleDO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleAddDTO;
|
||||
import cn.iocoder.mall.system.biz.dto.authorization.RoleUpdateDTO;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface RoleConvert {
|
||||
|
||||
RoleConvert INSTANCE = Mappers.getMapper(RoleConvert.class);
|
||||
|
||||
RoleBO convert(RoleDO bean);
|
||||
|
||||
List<RoleBO> convertList(List<RoleDO> beans);
|
||||
|
||||
@Mapping(source = "records", target = "list")
|
||||
PageResult<RoleBO> convertPage(IPage<RoleDO> page);
|
||||
|
||||
RoleDO convert(RoleAddDTO bean);
|
||||
|
||||
RoleDO convert(RoleUpdateDTO bean);
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user