Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
dc7f004d0f
@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.module.system.controller.admin.permission.vo.role.*;
|
||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
||||
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
||||
import cn.iocoder.yudao.module.system.service.permission.RoleService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
@ -23,6 +24,7 @@ import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
@ -37,18 +39,28 @@ public class RoleController {
|
||||
@Resource
|
||||
private RoleService roleService;
|
||||
|
||||
@Resource
|
||||
private PermissionService permissionService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建角色")
|
||||
@PreAuthorize("@ss.hasPermission('system:role:create')")
|
||||
public CommonResult<Long> createRole(@Valid @RequestBody RoleSaveReqVO createReqVO) {
|
||||
return success(roleService.createRole(createReqVO, null));
|
||||
//创建角色
|
||||
Long roleId = roleService.createRole(createReqVO, null);
|
||||
//赋予角色菜单权限
|
||||
permissionService.assignRoleMenu(roleId, createReqVO.getMenuIds());
|
||||
return success(roleId);
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "修改角色")
|
||||
@PreAuthorize("@ss.hasPermission('system:role:update')")
|
||||
public CommonResult<Boolean> updateRole(@Valid @RequestBody RoleSaveReqVO updateReqVO) {
|
||||
//修改角色
|
||||
roleService.updateRole(updateReqVO);
|
||||
//修改角色菜单权限
|
||||
permissionService.assignRoleMenu(updateReqVO.getId(), updateReqVO.getMenuIds());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -65,8 +77,13 @@ public class RoleController {
|
||||
@Operation(summary = "获得角色信息")
|
||||
@PreAuthorize("@ss.hasPermission('system:role:query')")
|
||||
public CommonResult<RoleRespVO> getRole(@RequestParam("id") Long id) {
|
||||
//获取角色信息
|
||||
RoleDO role = roleService.getRole(id);
|
||||
return success(BeanUtils.toBean(role, RoleRespVO.class));
|
||||
//获取角色的菜单权限
|
||||
Set<Long> roleMenuListByRoleId = permissionService.getRoleMenuListByRoleId(id);
|
||||
RoleRespVO roleRespVO = BeanUtils.toBean(role, RoleRespVO.class);
|
||||
roleRespVO.setMenuIds(roleMenuListByRoleId);
|
||||
return success(roleRespVO);
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
|
@ -10,6 +10,7 @@ import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 角色信息 Response VO")
|
||||
@ -56,4 +57,7 @@ public class RoleRespVO {
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "时间戳格式")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "菜单编号列表", example = "1,3,5")
|
||||
private Set<Long> menuIds = Collections.emptySet();
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ import lombok.Data;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 角色创建/更新 Request VO")
|
||||
@Data
|
||||
@ -45,4 +47,7 @@ public class RoleSaveReqVO {
|
||||
@DiffLogField(name = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "菜单编号列表", example = "1,3,5")
|
||||
private Set<Long> menuIds = Collections.emptySet();
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user