|
@@ -1,14 +1,12 @@
|
|
package com.usky.dxtop.controller.web;
|
|
package com.usky.dxtop.controller.web;
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
-
|
|
|
|
import com.usky.dxtop.common.annotation.Log;
|
|
import com.usky.dxtop.common.annotation.Log;
|
|
import com.usky.dxtop.common.constant.UserConstants;
|
|
import com.usky.dxtop.common.constant.UserConstants;
|
|
-
|
|
|
|
-import com.usky.dxtop.common.core.domain.AjaxResult;
|
|
|
|
|
|
+import com.usky.dxtop.common.core.domain.ApiResult;
|
|
import com.usky.dxtop.common.core.domain.model.LoginUser;
|
|
import com.usky.dxtop.common.core.domain.model.LoginUser;
|
|
import com.usky.dxtop.common.core.page.TableDataInfo;
|
|
import com.usky.dxtop.common.core.page.TableDataInfo;
|
|
import com.usky.dxtop.common.enums.BusinessType;
|
|
import com.usky.dxtop.common.enums.BusinessType;
|
|
|
|
+import com.usky.dxtop.common.exception.CustomException;
|
|
import com.usky.dxtop.common.utils.SecurityUtils;
|
|
import com.usky.dxtop.common.utils.SecurityUtils;
|
|
import com.usky.dxtop.common.utils.ServletUtils;
|
|
import com.usky.dxtop.common.utils.ServletUtils;
|
|
import com.usky.dxtop.common.utils.StringUtils;
|
|
import com.usky.dxtop.common.utils.StringUtils;
|
|
@@ -22,16 +20,10 @@ import com.usky.dxtop.service.ISysRoleService;
|
|
import com.usky.dxtop.service.ISysUserService;
|
|
import com.usky.dxtop.service.ISysUserService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
-
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-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.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
+
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -69,9 +61,9 @@ public class SysRoleController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
|
@GetMapping(value = "/{roleId}")
|
|
@GetMapping(value = "/{roleId}")
|
|
- public AjaxResult getInfo(@PathVariable Long roleId)
|
|
|
|
|
|
+ public ApiResult getInfo(@PathVariable Long roleId)
|
|
{
|
|
{
|
|
- return AjaxResult.success(roleService.selectRoleById(roleId));
|
|
|
|
|
|
+ return ApiResult.success(roleService.selectRoleById(roleId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -80,15 +72,15 @@ public class SysRoleController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:add')")
|
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
|
@Log(title = "角色管理", businessType = BusinessType.INSERT)
|
|
@PostMapping
|
|
@PostMapping
|
|
- public AjaxResult add(@Validated @RequestBody SysRole role)
|
|
|
|
|
|
+ public ApiResult 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() + "'失败,角色名称已存在");
|
|
|
|
|
|
+ throw new CustomException("新增角色'" + 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() + "'失败,角色权限已存在");
|
|
|
|
|
|
+ throw new CustomException("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
|
}
|
|
}
|
|
role.setCreateBy(SecurityUtils.getUsername());
|
|
role.setCreateBy(SecurityUtils.getUsername());
|
|
return toAjax(roleService.insertRole(role));
|
|
return toAjax(roleService.insertRole(role));
|
|
@@ -101,16 +93,16 @@ public class SysRoleController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
@PutMapping
|
|
@PutMapping
|
|
- public AjaxResult edit(@Validated @RequestBody SysRole role)
|
|
|
|
|
|
+ public ApiResult 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() + "'失败,角色名称已存在");
|
|
|
|
|
|
+ throw new CustomException("修改角色'" + 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() + "'失败,角色权限已存在");
|
|
|
|
|
|
+ throw new CustomException("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
|
|
}
|
|
}
|
|
role.setUpdateBy(SecurityUtils.getUsername());
|
|
role.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
|
|
@@ -124,9 +116,9 @@ public class SysRoleController extends BaseController
|
|
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
|
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
|
|
tokenService.setLoginUser(loginUser);
|
|
tokenService.setLoginUser(loginUser);
|
|
}
|
|
}
|
|
- return AjaxResult.success();
|
|
|
|
|
|
+ return ApiResult.success();
|
|
}
|
|
}
|
|
- return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
|
|
|
|
|
+ throw new CustomException("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -135,7 +127,7 @@ public class SysRoleController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/dataScope")
|
|
@PutMapping("/dataScope")
|
|
- public AjaxResult dataScope(@RequestBody SysRole role)
|
|
|
|
|
|
+ public ApiResult dataScope(@RequestBody SysRole role)
|
|
{
|
|
{
|
|
roleService.checkRoleAllowed(role);
|
|
roleService.checkRoleAllowed(role);
|
|
return toAjax(roleService.authDataScope(role));
|
|
return toAjax(roleService.authDataScope(role));
|
|
@@ -147,7 +139,7 @@ public class SysRoleController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
|
|
@PutMapping("/changeStatus")
|
|
@PutMapping("/changeStatus")
|
|
- public AjaxResult changeStatus(@RequestBody SysRole role)
|
|
|
|
|
|
+ public ApiResult changeStatus(@RequestBody SysRole role)
|
|
{
|
|
{
|
|
roleService.checkRoleAllowed(role);
|
|
roleService.checkRoleAllowed(role);
|
|
role.setUpdateBy(SecurityUtils.getUsername());
|
|
role.setUpdateBy(SecurityUtils.getUsername());
|
|
@@ -160,7 +152,7 @@ public class SysRoleController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:remove')")
|
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
|
@Log(title = "角色管理", businessType = BusinessType.DELETE)
|
|
@DeleteMapping("/{roleIds}")
|
|
@DeleteMapping("/{roleIds}")
|
|
- public AjaxResult remove(@PathVariable Long[] roleIds)
|
|
|
|
|
|
+ public ApiResult remove(@PathVariable Long[] roleIds)
|
|
{
|
|
{
|
|
return toAjax(roleService.deleteRoleByIds(roleIds));
|
|
return toAjax(roleService.deleteRoleByIds(roleIds));
|
|
}
|
|
}
|
|
@@ -170,9 +162,9 @@ public class SysRoleController extends BaseController
|
|
*/
|
|
*/
|
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:query')")
|
|
@GetMapping("/optionselect")
|
|
@GetMapping("/optionselect")
|
|
- public AjaxResult optionselect()
|
|
|
|
|
|
+ public ApiResult optionselect()
|
|
{
|
|
{
|
|
- return AjaxResult.success(roleService.selectRoleAll());
|
|
|
|
|
|
+ return ApiResult.success(roleService.selectRoleAll());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -205,7 +197,7 @@ public class SysRoleController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
@PutMapping("/authUser/cancel")
|
|
@PutMapping("/authUser/cancel")
|
|
- public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
|
|
|
|
|
|
+ public ApiResult cancelAuthUser(@RequestBody SysUserRole userRole)
|
|
{
|
|
{
|
|
return toAjax(roleService.deleteAuthUser(userRole));
|
|
return toAjax(roleService.deleteAuthUser(userRole));
|
|
}
|
|
}
|
|
@@ -216,7 +208,7 @@ public class SysRoleController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
@PutMapping("/authUser/cancelAll")
|
|
@PutMapping("/authUser/cancelAll")
|
|
- public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
|
|
|
|
|
|
+ public ApiResult cancelAuthUserAll(Long roleId, Long[] userIds)
|
|
{
|
|
{
|
|
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
|
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
|
|
}
|
|
}
|
|
@@ -227,7 +219,7 @@ public class SysRoleController extends BaseController
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@PreAuthorize("@ss.hasPermi('system:role:edit')")
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
|
@PutMapping("/authUser/selectAll")
|
|
@PutMapping("/authUser/selectAll")
|
|
- public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
|
|
|
|
|
|
+ public ApiResult selectAuthUserAll(Long roleId, Long[] userIds)
|
|
{
|
|
{
|
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
|
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
|
}
|
|
}
|