修改前端的验证码和登录相关的接口

This commit is contained in:
2025-07-13 00:39:31 +08:00
parent 0a2091adbb
commit b772a96196
6 changed files with 46 additions and 69 deletions

View File

@ -40,8 +40,7 @@ import com.ruoyi.system.service.ISysUserService;
*/ */
@RestController @RestController
@RequestMapping("/system/role") @RequestMapping("/system/role")
public class SysRoleController extends BaseController public class SysRoleController extends BaseController {
{
@Autowired @Autowired
private ISysRoleService roleService; private ISysRoleService roleService;
@ -59,8 +58,7 @@ public class SysRoleController extends BaseController
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(SysRole role) public TableDataInfo list(SysRole role) {
{
startPage(); startPage();
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list); return getDataTable(list);
@ -69,8 +67,7 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.EXPORT) @Log(title = "角色管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:role:export')") @PreAuthorize("@ss.hasPermi('system:role:export')")
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, SysRole role) public void export(HttpServletResponse response, SysRole role) {
{
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
util.exportExcel(response, list, "角色数据"); util.exportExcel(response, list, "角色数据");
@ -81,8 +78,7 @@ 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 AjaxResult getInfo(@PathVariable Long roleId) {
{
roleService.checkRoleDataScope(roleId); roleService.checkRoleDataScope(roleId);
return success(roleService.selectRoleById(roleId)); return success(roleService.selectRoleById(roleId));
} }
@ -93,14 +89,10 @@ 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 AjaxResult add(@Validated @RequestBody SysRole role) {
{ if (!roleService.checkRoleNameUnique(role)) {
if (!roleService.checkRoleNameUnique(role))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在"); return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
} } else if (!roleService.checkRoleKeyUnique(role)) {
else if (!roleService.checkRoleKeyUnique(role))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
role.setCreateBy(getUsername()); role.setCreateBy(getUsername());
@ -114,26 +106,20 @@ 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 AjaxResult edit(@Validated @RequestBody SysRole role) {
{
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
if (!roleService.checkRoleNameUnique(role)) if (!roleService.checkRoleNameUnique(role)) {
{
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
} } else if (!roleService.checkRoleKeyUnique(role)) {
else if (!roleService.checkRoleKeyUnique(role))
{
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
role.setUpdateBy(getUsername()); role.setUpdateBy(getUsername());
if (roleService.updateRole(role) > 0) if (roleService.updateRole(role) > 0) {
{
// 更新缓存用户权限 // 更新缓存用户权限
LoginUser loginUser = getLoginUser(); LoginUser loginUser = getLoginUser();
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) {
{
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName())); loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
tokenService.setLoginUser(loginUser); tokenService.setLoginUser(loginUser);
@ -149,8 +135,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 AjaxResult dataScope(@RequestBody SysRole role) {
{
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.authDataScope(role)); return toAjax(roleService.authDataScope(role));
@ -162,8 +147,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 AjaxResult changeStatus(@RequestBody SysRole role) {
{
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId()); roleService.checkRoleDataScope(role.getRoleId());
role.setUpdateBy(getUsername()); role.setUpdateBy(getUsername());
@ -176,8 +160,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 AjaxResult remove(@PathVariable Long[] roleIds) {
{
return toAjax(roleService.deleteRoleByIds(roleIds)); return toAjax(roleService.deleteRoleByIds(roleIds));
} }
@ -186,8 +169,7 @@ 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 AjaxResult optionselect() {
{
return success(roleService.selectRoleAll()); return success(roleService.selectRoleAll());
} }
@ -196,8 +178,7 @@ public class SysRoleController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList") @GetMapping("/authUser/allocatedList")
public TableDataInfo allocatedList(SysUser user) public TableDataInfo allocatedList(SysUser user) {
{
startPage(); startPage();
List<SysUser> list = userService.selectAllocatedList(user); List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list); return getDataTable(list);
@ -208,8 +189,7 @@ public class SysRoleController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:role:list')") @PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList") @GetMapping("/authUser/unallocatedList")
public TableDataInfo unallocatedList(SysUser user) public TableDataInfo unallocatedList(SysUser user) {
{
startPage(); startPage();
List<SysUser> list = userService.selectUnallocatedList(user); List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list); return getDataTable(list);
@ -221,8 +201,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 AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole) {
{
return toAjax(roleService.deleteAuthUser(userRole)); return toAjax(roleService.deleteAuthUser(userRole));
} }
@ -232,8 +211,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 AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds) {
{
return toAjax(roleService.deleteAuthUsers(roleId, userIds)); return toAjax(roleService.deleteAuthUsers(roleId, userIds));
} }
@ -243,8 +221,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<Integer> selectAuthUserAll(Long roleId, Long[] userIds) public AjaxResult<Integer> selectAuthUserAll(Long roleId, Long[] userIds) {
{
roleService.checkRoleDataScope(roleId); roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds)); return toAjax(roleService.insertAuthUsers(roleId, userIds));
} }
@ -254,8 +231,7 @@ public class SysRoleController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:role:query')") @PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/deptTree/{roleId}") @GetMapping(value = "/deptTree/{roleId}")
public AjaxResult<DeptTree> deptTree(@PathVariable("roleId") Long roleId) public AjaxResult<DeptTree> deptTree(@PathVariable("roleId") Long roleId) {
{
DeptTree deptTree = new DeptTree(); DeptTree deptTree = new DeptTree();
deptTree.setCheckedKeys(deptService.selectDeptListByRoleId(roleId)); deptTree.setCheckedKeys(deptService.selectDeptListByRoleId(roleId));

View File

@ -102,7 +102,7 @@ public class SysUserController extends BaseController
* 根据用户编号获取详细信息 * 根据用户编号获取详细信息
*/ */
@PreAuthorize("@ss.hasPermi('system:user:query')") @PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = {"/{userId}" }) @GetMapping(value = { "/", "/{userId}" })
public AjaxResult<Infos> getInfo(@PathVariable(value = "userId", required = false) Long userId) public AjaxResult<Infos> getInfo(@PathVariable(value = "userId", required = false) Long userId)
{ {

View File

@ -26,7 +26,7 @@ import com.ruoyi.common.utils.sql.SqlUtil;
* *
* @author ruoyi * @author ruoyi
*/ */
public class BaseController public class BaseController<T>
{ {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@ -80,7 +80,7 @@ public class BaseController
* 响应请求分页数据 * 响应请求分页数据
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
protected TableDataInfo getDataTable(List<?> list) protected TableDataInfo getDataTable(List<T> list)
{ {
TableDataInfo rspData = new TableDataInfo(); TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS); rspData.setCode(HttpStatus.SUCCESS);
@ -109,15 +109,15 @@ public class BaseController
/** /**
* 返回成功消息 * 返回成功消息
*/ */
public AjaxResult success(String message) // public AjaxResult success(String message)
{ // {
return AjaxResult.success(message); // return AjaxResult.success(message);
} // }
/** /**
* 返回成功消息 * 返回成功消息
*/ */
public AjaxResult success(Object data) public AjaxResult<T> success(T data)
{ {
return AjaxResult.success(data); return AjaxResult.success(data);
} }
@ -125,7 +125,7 @@ public class BaseController
/** /**
* 返回失败消息 * 返回失败消息
*/ */
public AjaxResult error(String message) public AjaxResult<T> error(String message)
{ {
return AjaxResult.error(message); return AjaxResult.error(message);
} }
@ -133,7 +133,7 @@ public class BaseController
/** /**
* 返回警告消息 * 返回警告消息
*/ */
public AjaxResult warn(String message) public AjaxResult<T> warn(String message)
{ {
return AjaxResult.warn(message); return AjaxResult.warn(message);
} }
@ -144,7 +144,7 @@ public class BaseController
* @param rows 影响行数 * @param rows 影响行数
* @return 操作结果 * @return 操作结果
*/ */
protected AjaxResult toAjax(int rows) protected AjaxResult<T> toAjax(int rows)
{ {
return rows > 0 ? AjaxResult.success() : AjaxResult.error(); return rows > 0 ? AjaxResult.success() : AjaxResult.error();
} }

View File

@ -1,9 +1,6 @@
package com.ruoyi.common.core.domain; package com.ruoyi.common.core.domain;
import java.util.HashMap;
import java.util.Objects;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.utils.StringUtils;
/** /**
* 操作消息提醒 * 操作消息提醒

View File

@ -382,14 +382,14 @@ export default {
/** 根据角色ID查询菜单树结构 */ /** 根据角色ID查询菜单树结构 */
getRoleMenuTreeselect(roleId) { getRoleMenuTreeselect(roleId) {
return roleMenuTreeselect(roleId).then(response => { return roleMenuTreeselect(roleId).then(response => {
this.menuOptions = response.menus this.menuOptions = response.data.menus
return response return response
}) })
}, },
/** 根据角色ID查询部门树结构 */ /** 根据角色ID查询部门树结构 */
getDeptTree(roleId) { getDeptTree(roleId) {
return deptTreeSelect(roleId).then(response => { return deptTreeSelect(roleId).then(response => {
this.deptOptions = response.depts this.deptOptions = response.data.depts
return response return response
}) })
}, },

View File

@ -439,9 +439,12 @@ export default {
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
this.reset() this.reset()
console.log("userId:"+1111111)
getUser().then(response => { getUser().then(response => {
this.postOptions = response.posts console.log(response)
this.roleOptions = response.roles this.postOptions = response.data.posts
console.log(this.postOptions)
this.roleOptions = response.data.roles
this.open = true this.open = true
this.title = "添加用户" this.title = "添加用户"
this.form.password = this.initPassword this.form.password = this.initPassword
@ -451,10 +454,11 @@ export default {
handleUpdate(row) { handleUpdate(row) {
this.reset() this.reset()
const userId = row.userId || this.ids const userId = row.userId || this.ids
console.log("userId:"+userId)
getUser(userId).then(response => { getUser(userId).then(response => {
this.form = response.data this.form = response.data.user
this.postOptions = response.posts this.postOptions = response.data.posts
this.roleOptions = response.roles this.roleOptions = response.data.roles
this.$set(this.form, "postIds", response.postIds) this.$set(this.form, "postIds", response.postIds)
this.$set(this.form, "roleIds", response.roleIds) this.$set(this.form, "roleIds", response.roleIds)
this.open = true this.open = true