| | |
| | | import com.sinata.system.service.ISysRoleService; |
| | | import com.sinata.system.service.ISysUserService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotEmpty; |
| | | import javax.validation.constraints.NotBlank; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 角色信息 |
| | |
| | | @PostMapping("/save") |
| | | public R<?> save(@Valid @RequestBody SysRoleDTO dto) { |
| | | roleService.saveRole(dto); |
| | | if (Objects.nonNull(dto.getRoleId())) { |
| | | // 更新缓存用户权限 |
| | | LoginUser loginUser = getLoginUser(); |
| | | if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) { |
| | | loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); |
| | | loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); |
| | | tokenService.setLoginUser(loginUser); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | return R.ok(roleService.getDetailInfo(roleId)); |
| | | } |
| | | |
| | | @ApiOperation("删除详情") |
| | | @ApiOperation("批量删除") |
| | | @PostMapping("/deleteBatch") |
| | | public R<?> deleteBatch(@ApiParam(name = "roleIds", value = "角色id列表", required = true) @NotEmpty(message = "角色id列表不能为空") @RequestBody List<Long> roleIds) { |
| | | roleService.removeBatchByIds(roleIds); |
| | | @ApiImplicitParam(name = "roleIdStr", value = "角色id字符串,多个用逗号分隔", required = true) |
| | | public R<?> deleteBatch(@RequestParam @NotBlank(message = "角色id字符串不能为空") String roleIdStr) { |
| | | List<Long> idList = Arrays.stream(roleIdStr.split(",")).map(Long::valueOf).collect(Collectors.toList()); |
| | | roleService.removeBatchByIds(idList); |
| | | return R.ok(); |
| | | } |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | |
| | | /** |
| | | * 获取当前登录用户可管理角色列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @ApiOperation("获取当前登录用户可管理角色列表") |
| | | @GetMapping("/manageRoleList") |
| | | public R<List<SysRoleVO>> getManageRoleList() { |
| | | return R.ok(roleService.getManageRoleList(getLoginUser())); |
| | | } |
| | | |
| | | /** |
| | | * 角色列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @ApiOperation("角色列表") |
| | | @GetMapping("/list") |
| | | public R<List<SysRoleVO>> queryList() { |
| | | return R.ok(roleService.queryList()); |
| | | } |
| | | @PreAuthorize("@ss.hasPermi('system:role:list')") |
| | | //@GetMapping("/list") |
| | | public TableDataInfo list(SysRole role) |
| | | { |
| | | startPage(); |
| | |
| | | /** |
| | | * 根据角色编号获取详细信息 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | /* @PreAuthorize("@ss.hasPermi('system:role:query')") |
| | | @GetMapping(value = "/{roleId}") |
| | | public AjaxResult getInfo(@PathVariable Long roleId) |
| | | { |
| | | roleService.checkRoleDataScope(roleId); |
| | | return success(roleService.selectRoleById(roleId)); |
| | | } |
| | | }*/ |
| | | |
| | | /** |
| | | * 新增角色 |