用户管理
This commit is contained in:
parent
b38514ee6b
commit
57605906e2
|
|
@ -1,6 +1,7 @@
|
|||
package com.qihang.security.service;
|
||||
|
||||
|
||||
import com.qihang.common.common.ServiceException;
|
||||
import com.qihang.common.config.RedisCache;
|
||||
import com.qihang.common.constant.UserConstants;
|
||||
import com.qihang.common.exception.UserNotExistsException;
|
||||
|
|
@ -78,7 +79,7 @@ public class SysLoginService
|
|||
else
|
||||
{
|
||||
// AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
|
||||
// throw new ServiceException(e.getMessage());
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.qihang.security.common.SecurityUtils;
|
|||
import com.qihang.security.entity.SysUser;
|
||||
import com.qihang.security.service.ISysUserService;
|
||||
import com.qihang.common.common.TableDataInfo;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
|
@ -59,7 +60,9 @@ public class SysUserController extends BaseController
|
|||
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
|
||||
{
|
||||
userService.checkUserDataScope(userId);
|
||||
SysUser sysUser = userService.selectUserById(userId);
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
ajax.put(AjaxResult.DATA_TAG, sysUser);
|
||||
// List<SysRole> roles = roleService.selectRoleAll();
|
||||
// ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
|
||||
// ajax.put("posts", postService.selectPostAll());
|
||||
|
|
@ -96,77 +99,77 @@ public class SysUserController extends BaseController
|
|||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
return toAjax(userService.insertUser(user));
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * 修改用户
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping
|
||||
// public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||
// {
|
||||
// userService.checkUserAllowed(user);
|
||||
// userService.checkUserDataScope(user.getUserId());
|
||||
// if (!userService.checkUserNameUnique(user))
|
||||
// {
|
||||
// return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
// }
|
||||
// else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
||||
// {
|
||||
// return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
// }
|
||||
// else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
|
||||
// {
|
||||
// return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
// }
|
||||
// user.setUpdateBy(getUsername());
|
||||
// return toAjax(userService.updateUser(user));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除用户
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.DELETE)
|
||||
// @DeleteMapping("/{userIds}")
|
||||
// public AjaxResult remove(@PathVariable Long[] userIds)
|
||||
// {
|
||||
// if (ArrayUtils.contains(userIds, getUserId()))
|
||||
// {
|
||||
// return error("当前用户不能删除");
|
||||
// }
|
||||
// return toAjax(userService.deleteUserByIds(userIds));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 重置密码
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping("/resetPwd")
|
||||
// public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||
// {
|
||||
// userService.checkUserAllowed(user);
|
||||
// userService.checkUserDataScope(user.getUserId());
|
||||
// user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
// user.setUpdateBy(getUsername());
|
||||
// return toAjax(userService.resetPwd(user));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 状态修改
|
||||
// */
|
||||
// @PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
// @Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping("/changeStatus")
|
||||
// public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||
// {
|
||||
// userService.checkUserAllowed(user);
|
||||
// userService.checkUserDataScope(user.getUserId());
|
||||
// user.setUpdateBy(getUsername());
|
||||
// return toAjax(userService.updateUserStatus(user));
|
||||
// }
|
||||
//
|
||||
|
||||
/**
|
||||
* 修改用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
if (!userService.checkUserNameUnique(user))
|
||||
{
|
||||
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
|
||||
{
|
||||
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
}
|
||||
else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
|
||||
{
|
||||
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.updateUser(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:remove')")
|
||||
|
||||
@DeleteMapping("/{userIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] userIds)
|
||||
{
|
||||
if (ArrayUtils.contains(userIds, getUserId()))
|
||||
{
|
||||
return error("当前用户不能删除");
|
||||
}
|
||||
for (var userId:userIds){
|
||||
userService.deleteUserById(userId);
|
||||
}
|
||||
return toAjax(userIds.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
|
||||
@PutMapping("/resetPwd")
|
||||
public AjaxResult resetPwd(@RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.resetPwd(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态修改
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:user:edit')")
|
||||
@PutMapping("/changeStatus")
|
||||
public AjaxResult changeStatus(@RequestBody SysUser user)
|
||||
{
|
||||
userService.checkUserAllowed(user);
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(getUsername());
|
||||
return toAjax(userService.updateUserStatus(user));
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 根据用户编号获取授权角色
|
||||
// */
|
||||
|
|
|
|||
|
|
@ -41,7 +41,8 @@ public class SysPermissionService
|
|||
}
|
||||
else
|
||||
{
|
||||
roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
|
||||
// roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
|
||||
roles.add("admin");
|
||||
}
|
||||
return roles;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu>
|
|||
}
|
||||
else
|
||||
{
|
||||
menus = menuMapper.selectMenuTreeByUserId(userId);
|
||||
// menus = menuMapper.selectMenuTreeByUserId(userId);
|
||||
menus = menuMapper.selectMenuTreeAll();
|
||||
}
|
||||
return getChildPerms(menus, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
#错误消息
|
||||
not.null=* 必须填写
|
||||
user.jcaptcha.error=验证码错误
|
||||
user.jcaptcha.expire=验证码已失效
|
||||
user.not.exists=用户不存在/密码错误
|
||||
user.password.not.match=用户不存在/密码错误
|
||||
user.password.retry.limit.count=密码输入错误{0}次
|
||||
user.password.retry.limit.exceed=密码输入错误{0}次,帐户锁定{1}分钟
|
||||
user.password.delete=对不起,您的账号已被删除
|
||||
user.blocked=用户已封禁,请联系管理员
|
||||
role.blocked=角色已封禁,请联系管理员
|
||||
login.blocked=很遗憾,访问IP已被列入系统黑名单
|
||||
user.logout.success=退出成功
|
||||
|
||||
length.not.valid=长度必须在{min}到{max}个字符之间
|
||||
|
||||
user.username.not.valid=* 2到20个汉字、字母、数字或下划线组成,且必须以非数字开头
|
||||
user.password.not.valid=* 5-50个字符
|
||||
|
||||
user.email.not.valid=邮箱格式错误
|
||||
user.mobile.phone.number.not.valid=手机号格式错误
|
||||
user.login.success=登录成功
|
||||
user.register.success=注册成功
|
||||
user.notfound=请重新登录
|
||||
user.forcelogout=管理员强制退出,请重新登录
|
||||
user.unknown.error=未知错误,请重新登录
|
||||
|
||||
##文件上传消息
|
||||
upload.exceed.maxSize=上传的文件大小超出限制的文件大小!<br/>允许的文件最大大小是:{0}MB!
|
||||
upload.filename.exceed.length=上传的文件名最长{0}个字符
|
||||
|
||||
##权限
|
||||
no.permission=您没有数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.create.permission=您没有创建数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.update.permission=您没有修改数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.delete.permission=您没有删除数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.export.permission=您没有导出数据的权限,请联系管理员添加权限 [{0}]
|
||||
no.view.permission=您没有查看数据的权限,请联系管理员添加权限 [{0}]
|
||||
|
|
@ -39,7 +39,7 @@ export function updateUser(data) {
|
|||
// 删除用户
|
||||
export function delUser(userId) {
|
||||
return request({
|
||||
url: '/system/user/' + userId,
|
||||
url: '/api/sys-api/system/user/' + userId,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@ export function resetUserPwd(userId, password) {
|
|||
password
|
||||
}
|
||||
return request({
|
||||
url: '/system/user/resetPwd',
|
||||
url: '/api/sys-api/system/user/resetPwd',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
|
|
@ -64,7 +64,7 @@ export function changeUserStatus(userId, status) {
|
|||
status
|
||||
}
|
||||
return request({
|
||||
url: '/system/user/changeStatus',
|
||||
url: '/api/sys-api/system/user/changeStatus',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
|
|
@ -73,7 +73,7 @@ export function changeUserStatus(userId, status) {
|
|||
// 查询用户个人信息
|
||||
export function getUserProfile() {
|
||||
return request({
|
||||
url: '/system/user/profile',
|
||||
url: '/api/sys-api/system/user/profile',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ export function getUserProfile() {
|
|||
// 修改用户个人信息
|
||||
export function updateUserProfile(data) {
|
||||
return request({
|
||||
url: '/system/user/profile',
|
||||
url: '/api/sys-api/system/user/profile',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
|
|
@ -94,7 +94,7 @@ export function updateUserPwd(oldPassword, newPassword) {
|
|||
newPassword
|
||||
}
|
||||
return request({
|
||||
url: '/system/user/profile/updatePwd',
|
||||
url: '/api/sys-api/system/user/profile/updatePwd',
|
||||
method: 'put',
|
||||
params: data
|
||||
})
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@
|
|||
<el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
|
||||
<el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />
|
||||
<!-- <el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />-->
|
||||
<el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible" width="120" />
|
||||
<el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
|
||||
<template slot-scope="scope">
|
||||
|
|
@ -527,8 +527,8 @@ export default {
|
|||
const userId = row.userId || this.ids;
|
||||
getUser(userId).then(response => {
|
||||
this.form = response.data;
|
||||
this.postOptions = response.posts;
|
||||
this.roleOptions = response.roles;
|
||||
// this.postOptions = response.posts;
|
||||
// this.roleOptions = response.roles;
|
||||
// this.$set(this.form, "postIds", response.postIds);
|
||||
// this.$set(this.form, "roleIds", response.roleIds);
|
||||
this.open = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue