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

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

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

View File

@ -102,7 +102,7 @@ public class SysUserController extends BaseController
* 根据用户编号获取详细信息
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = {"/{userId}" })
@GetMapping(value = { "/", "/{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
*/
public class BaseController
public class BaseController<T>
{
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
@ -80,7 +80,7 @@ public class BaseController
* 响应请求分页数据
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TableDataInfo getDataTable(List<?> list)
protected TableDataInfo getDataTable(List<T> list)
{
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
@ -109,15 +109,15 @@ public class BaseController
/**
* 返回成功消息
*/
public AjaxResult success(String message)
{
return AjaxResult.success(message);
}
// public AjaxResult success(String message)
// {
// return AjaxResult.success(message);
// }
/**
* 返回成功消息
*/
public AjaxResult success(Object data)
public AjaxResult<T> success(T 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);
}
@ -133,7 +133,7 @@ public class BaseController
/**
* 返回警告消息
*/
public AjaxResult warn(String message)
public AjaxResult<T> warn(String message)
{
return AjaxResult.warn(message);
}
@ -144,7 +144,7 @@ public class BaseController
* @param rows 影响行数
* @return 操作结果
*/
protected AjaxResult toAjax(int rows)
protected AjaxResult<T> toAjax(int rows)
{
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
}

View File

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

View File

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

View File

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