|
@ -15,6 +15,7 @@ import com.shuili.common.core.domain.SearchParam; |
|
|
import com.shuili.common.core.domain.entity.SysRole; |
|
|
import com.shuili.common.core.domain.entity.SysRole; |
|
|
import com.shuili.common.enums.BusinessType; |
|
|
import com.shuili.common.enums.BusinessType; |
|
|
import com.shuili.common.utils.poi.ExcelUtil; |
|
|
import com.shuili.common.utils.poi.ExcelUtil; |
|
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.validation.annotation.Validated; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
@ -28,8 +29,7 @@ import java.util.List; |
|
|
*/ |
|
|
*/ |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("/system/role") |
|
|
@RequestMapping("/system/role") |
|
|
public class SysRoleController extends BaseController |
|
|
public class SysRoleController extends BaseController { |
|
|
{ |
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private SysRoleService roleService; |
|
|
private SysRoleService roleService; |
|
|
@Autowired |
|
|
@Autowired |
|
@ -44,19 +44,21 @@ public class SysRoleController extends BaseController |
|
|
|
|
|
|
|
|
//获取所有的角色
|
|
|
//获取所有的角色
|
|
|
@GetMapping("listAll") |
|
|
@GetMapping("listAll") |
|
|
|
|
|
@ApiOperation("获取所有的角色") |
|
|
public AjaxResult listAll() { |
|
|
public AjaxResult listAll() { |
|
|
return AjaxResult.success(roleService.list()); |
|
|
return AjaxResult.success(roleService.list()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/list") |
|
|
@PostMapping("/list") |
|
|
public IPage list(@RequestBody SearchParam<SysRole> sp) |
|
|
@ApiOperation("角色列表") |
|
|
{ |
|
|
public IPage list(@RequestBody SearchParam<SysRole> sp) { |
|
|
return roleService.selectPage(sp); |
|
|
return roleService.selectPage(sp); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 角色导出 |
|
|
* 角色导出 |
|
|
|
|
|
* |
|
|
* @param role |
|
|
* @param role |
|
|
* @return |
|
|
* @return |
|
|
*/ |
|
|
*/ |
|
@ -64,8 +66,7 @@ public class SysRoleController extends BaseController |
|
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT) |
|
|
@Log(title = "角色管理", businessType = BusinessType.EXPORT) |
|
|
@SaCheckPermission(value = "system:role:export") |
|
|
@SaCheckPermission(value = "system:role:export") |
|
|
@PostMapping("/export") |
|
|
@PostMapping("/export") |
|
|
public AjaxResult export(@RequestBody SysRole role) |
|
|
public AjaxResult export(@RequestBody SysRole role) { |
|
|
{ |
|
|
|
|
|
List<SysRole> list = roleService.listByIds(role.getIds()); |
|
|
List<SysRole> list = roleService.listByIds(role.getIds()); |
|
|
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
|
|
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); |
|
|
return util.exportExcel(list, "角色数据"); |
|
|
return util.exportExcel(list, "角色数据"); |
|
@ -77,8 +78,7 @@ public class SysRoleController extends BaseController |
|
|
@SaCheckLogin |
|
|
@SaCheckLogin |
|
|
@SaCheckPermission(value = "system:role:query") |
|
|
@SaCheckPermission(value = "system:role:query") |
|
|
@GetMapping(value = "/{roleId}") |
|
|
@GetMapping(value = "/{roleId}") |
|
|
public AjaxResult getInfo(@PathVariable String roleId) |
|
|
public AjaxResult getInfo(@PathVariable String roleId) { |
|
|
{ |
|
|
|
|
|
/** |
|
|
/** |
|
|
* 1.角色详情 |
|
|
* 1.角色详情 |
|
|
* 2.角色相关的菜单 |
|
|
* 2.角色相关的菜单 |
|
@ -104,14 +104,10 @@ public class SysRoleController extends BaseController |
|
|
@Log(title = "角色管理", businessType = BusinessType.INSERT) |
|
|
@Log(title = "角色管理", businessType = BusinessType.INSERT) |
|
|
@SaCheckPermission(value = "system:role:add") |
|
|
@SaCheckPermission(value = "system:role:add") |
|
|
@PostMapping |
|
|
@PostMapping |
|
|
public AjaxResult add(@Validated @RequestBody SysRole role) |
|
|
public AjaxResult add(@Validated @RequestBody SysRole role) { |
|
|
{ |
|
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { |
|
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) |
|
|
|
|
|
{ |
|
|
|
|
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
|
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
|
|
} |
|
|
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { |
|
|
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) |
|
|
|
|
|
{ |
|
|
|
|
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
|
|
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
|
|
} |
|
|
} |
|
|
return toAjax(roleService.insertRole(role) > 0); |
|
|
return toAjax(roleService.insertRole(role) > 0); |
|
@ -125,20 +121,15 @@ public class SysRoleController extends BaseController |
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
@SaCheckPermission(value = "system:role:edit") |
|
|
@SaCheckPermission(value = "system:role:edit") |
|
|
@PutMapping |
|
|
@PutMapping |
|
|
public AjaxResult edit(@Validated @RequestBody SysRole role) |
|
|
public AjaxResult edit(@Validated @RequestBody SysRole role) { |
|
|
{ |
|
|
|
|
|
roleService.checkRoleAllowed(role); |
|
|
roleService.checkRoleAllowed(role); |
|
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) |
|
|
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) { |
|
|
{ |
|
|
|
|
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
|
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); |
|
|
} |
|
|
} else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) { |
|
|
else if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleKeyUnique(role))) |
|
|
|
|
|
{ |
|
|
|
|
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
|
|
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (roleService.updateRole(role) > 0) |
|
|
if (roleService.updateRole(role) > 0) { |
|
|
{ |
|
|
|
|
|
// 更新缓存用户权限
|
|
|
// 更新缓存用户权限
|
|
|
|
|
|
|
|
|
// SysUser user = UserUtils.getUser();
|
|
|
// SysUser user = UserUtils.getUser();
|
|
@ -160,8 +151,7 @@ public class SysRoleController extends BaseController |
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
@SaCheckPermission(value = "system:role:edit") |
|
|
@SaCheckPermission(value = "system:role:edit") |
|
|
@PutMapping("/dataScope") |
|
|
@PutMapping("/dataScope") |
|
|
public AjaxResult dataScope(@RequestBody SysRole role) |
|
|
public AjaxResult dataScope(@RequestBody SysRole role) { |
|
|
{ |
|
|
|
|
|
roleService.checkRoleAllowed(role); |
|
|
roleService.checkRoleAllowed(role); |
|
|
return toAjax(roleService.authDataScope(role) > 0); |
|
|
return toAjax(roleService.authDataScope(role) > 0); |
|
|
} |
|
|
} |
|
@ -173,8 +163,7 @@ public class SysRoleController extends BaseController |
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE) |
|
|
@SaCheckPermission(value = "system:role:edit") |
|
|
@SaCheckPermission(value = "system:role:edit") |
|
|
@PutMapping("/changeStatus") |
|
|
@PutMapping("/changeStatus") |
|
|
public AjaxResult changeStatus(@RequestBody SysRole role) |
|
|
public AjaxResult changeStatus(@RequestBody SysRole role) { |
|
|
{ |
|
|
|
|
|
roleService.checkRoleAllowed(role); |
|
|
roleService.checkRoleAllowed(role); |
|
|
return toAjax(roleService.updateRoleStatus(role) > 0); |
|
|
return toAjax(roleService.updateRoleStatus(role) > 0); |
|
|
} |
|
|
} |
|
@ -186,8 +175,7 @@ public class SysRoleController extends BaseController |
|
|
@Log(title = "角色管理", businessType = BusinessType.DELETE) |
|
|
@Log(title = "角色管理", businessType = BusinessType.DELETE) |
|
|
@SaCheckPermission(value = "system:role:remove") |
|
|
@SaCheckPermission(value = "system:role:remove") |
|
|
@DeleteMapping("/{roleIds}") |
|
|
@DeleteMapping("/{roleIds}") |
|
|
public AjaxResult remove(@PathVariable String[] roleIds) |
|
|
public AjaxResult remove(@PathVariable String[] roleIds) { |
|
|
{ |
|
|
|
|
|
return toAjax(roleService.deleteRoleByIds(roleIds) > 0); |
|
|
return toAjax(roleService.deleteRoleByIds(roleIds) > 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -195,8 +183,7 @@ public class SysRoleController extends BaseController |
|
|
* 获取角色选择框列表 |
|
|
* 获取角色选择框列表 |
|
|
*/ |
|
|
*/ |
|
|
@GetMapping("/optionselect") |
|
|
@GetMapping("/optionselect") |
|
|
public AjaxResult optionselect() |
|
|
public AjaxResult optionselect() { |
|
|
{ |
|
|
|
|
|
return AjaxResult.success(roleService.selectRoleAll()); |
|
|
return AjaxResult.success(roleService.selectRoleAll()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|