个人中心信息更新、重置cc密码
This commit is contained in:
@@ -9,6 +9,12 @@
|
||||
账户管理
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.RestCC">
|
||||
<summary>
|
||||
重置管理员CC的密码
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.AccountController.Login(Yi.Framework.DTOModel.LoginDto)">
|
||||
<summary>
|
||||
没啥说,登录
|
||||
@@ -432,6 +438,13 @@
|
||||
<param name="userDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.UpdateProfile(Yi.Framework.DTOModel.UserInfoDto)">
|
||||
<summary>
|
||||
更新个人中心信息
|
||||
</summary>
|
||||
<param name="userDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.UserController.Add(Yi.Framework.DTOModel.UserInfoDto)">
|
||||
<summary>
|
||||
添加用户
|
||||
|
||||
@@ -36,6 +36,20 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置管理员CC的密码
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> RestCC()
|
||||
{
|
||||
var user= await _iUserService._repository.GetFirstAsync(u => u.UserName == "cc");
|
||||
user.Password = "123456";
|
||||
user.BuildPassword();
|
||||
await _iUserService._repository.UpdateIgnoreNullAsync(user);
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 没啥说,登录
|
||||
/// </summary>
|
||||
|
||||
@@ -90,6 +90,18 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
return Result.Success().SetStatus(await _iUserService.UpdateInfo(userDto));
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新个人中心信息
|
||||
/// </summary>
|
||||
/// <param name="userDto"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<Result> UpdateProfile(UserInfoDto userDto)
|
||||
{
|
||||
return Result.Success().SetStatus(await _iUserService.UpdateProfile(userDto));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加用户
|
||||
/// </summary>
|
||||
|
||||
Binary file not shown.
@@ -116,5 +116,12 @@ namespace Yi.Framework.Interface
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdatePassword(UpdatePasswordDto dto, long userId);
|
||||
|
||||
/// <summary>
|
||||
/// 个人中心信息更新
|
||||
/// </summary>
|
||||
/// <param name="userDto"></param>
|
||||
/// <returns></returns>
|
||||
Task<bool> UpdateProfile(UserInfoDto userDto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,19 +84,25 @@ namespace Yi.Framework.Service
|
||||
//删除用户之前所有的用户角色关系(物理删除,没有恢复的必要)
|
||||
await _repositoryUserRole.DeleteAsync(u => userIds.Contains((long)u.UserId));
|
||||
|
||||
//遍历用户
|
||||
foreach (var userId in userIds)
|
||||
if (roleIds is not null)
|
||||
{
|
||||
//添加新的关系
|
||||
List<UserRoleEntity> userRoleEntities = new();
|
||||
foreach (var roleId in roleIds)
|
||||
//遍历用户
|
||||
foreach (var userId in userIds)
|
||||
{
|
||||
userRoleEntities.Add(new UserRoleEntity() { UserId = userId, RoleId = roleId });
|
||||
}
|
||||
//添加新的关系
|
||||
List<UserRoleEntity> userRoleEntities = new();
|
||||
|
||||
//一次性批量添加
|
||||
await _repositoryUserRole.InsertReturnSnowflakeIdAsync(userRoleEntities);
|
||||
foreach (var roleId in roleIds)
|
||||
{
|
||||
userRoleEntities.Add(new UserRoleEntity() { UserId = userId, RoleId = roleId });
|
||||
}
|
||||
|
||||
//一次性批量添加
|
||||
await _repositoryUserRole.InsertReturnSnowflakeIdAsync(userRoleEntities);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,19 +116,22 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
//删除用户之前所有的用户角色关系(物理删除,没有恢复的必要)
|
||||
await _repositoryUserPost.DeleteAsync(u => userIds.Contains((long)u.UserId));
|
||||
|
||||
//遍历用户
|
||||
foreach (var userId in userIds)
|
||||
if (postIds is not null)
|
||||
{
|
||||
//添加新的关系
|
||||
List<UserPostEntity> userPostEntities = new();
|
||||
foreach (var post in postIds)
|
||||
//遍历用户
|
||||
foreach (var userId in userIds)
|
||||
{
|
||||
userPostEntities.Add(new UserPostEntity() { UserId = userId, PostId = post });
|
||||
//添加新的关系
|
||||
List<UserPostEntity> userPostEntities = new();
|
||||
foreach (var post in postIds)
|
||||
{
|
||||
userPostEntities.Add(new UserPostEntity() { UserId = userId, PostId = post });
|
||||
}
|
||||
|
||||
//一次性批量添加
|
||||
await _repositoryUserPost.InsertReturnSnowflakeIdAsync(userPostEntities);
|
||||
}
|
||||
|
||||
//一次性批量添加
|
||||
await _repositoryUserPost.InsertReturnSnowflakeIdAsync(userPostEntities);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -131,7 +140,10 @@ namespace Yi.Framework.Service
|
||||
|
||||
public async Task<UserEntity> GetInfoById(long userId)
|
||||
{
|
||||
return await _repository._DbQueryable.Includes(u => u.Roles).Includes(u => u.Posts).Includes(u => u.Dept).InSingleAsync(userId);
|
||||
var data = await _repository._DbQueryable.Includes(u => u.Roles).Includes(u => u.Posts).Includes(u => u.Dept).InSingleAsync(userId);
|
||||
data.Password = null;
|
||||
data.Salt = null;
|
||||
return data;
|
||||
}
|
||||
|
||||
public async Task<UserRoleMenuDto> GetUserAllInfo(long userId)
|
||||
@@ -142,7 +154,8 @@ namespace Yi.Framework.Service
|
||||
|
||||
//得到用户
|
||||
var user = await _repository._DbQueryable.Includes(u => u.Roles.Where(r => r.IsDeleted == false).ToList(), r => r.Menus.Where(m => m.IsDeleted == false).ToList()).InSingleAsync(userId);
|
||||
|
||||
user.Password = null;
|
||||
user.Salt = null;
|
||||
//得到角色集合
|
||||
var roleList = user.Roles;
|
||||
|
||||
@@ -207,6 +220,9 @@ namespace Yi.Framework.Service
|
||||
|
||||
data = await query.OrderBy(u => u.OrderNum, OrderByType.Desc)
|
||||
.ToPageListAsync(page.PageNum, page.PageSize, total);
|
||||
|
||||
|
||||
data.ForEach(u => { u.Password = null; u.Salt = null; });
|
||||
return new PageModel<List<UserEntity>>(data, total);
|
||||
}
|
||||
|
||||
@@ -268,5 +284,15 @@ namespace Yi.Framework.Service
|
||||
newUser.BuildPassword();
|
||||
return await _repository.UpdateIgnoreNullAsync(newUser);
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> UpdateProfile(UserInfoDto userDto)
|
||||
{
|
||||
userDto.User.Salt = null;
|
||||
userDto.User.Password = null;
|
||||
userDto.User.DeptId = null;
|
||||
return await _repository.UpdateIgnoreNullAsync(userDto.User);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,9 +83,9 @@ export function getUserProfile() {
|
||||
// 修改用户个人信息
|
||||
export function updateUserProfile(data) {
|
||||
return request({
|
||||
url: '/system/user/profile',
|
||||
url: '/user/UpdateProfile',
|
||||
method: 'put',
|
||||
data: data
|
||||
data: {user:data}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ export default {
|
||||
const { value } = binding
|
||||
const all_permission = "*:*:*";
|
||||
const permissions = useUserStore().permissions
|
||||
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
const permissionFlag = value
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register'];
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
NProgress.start()
|
||||
|
||||
if (getToken()) {
|
||||
to.meta.title && useSettingsStore().setTitle(to.meta.title)
|
||||
/* has token*/
|
||||
@@ -22,7 +23,9 @@ router.beforeEach((to, from, next) => {
|
||||
next({ path: '/' })
|
||||
NProgress.done()
|
||||
} else {
|
||||
if (useUserStore().roles.length === 0) {
|
||||
|
||||
if (useUserStore().roles.length === 0)
|
||||
{
|
||||
isRelogin.show = true
|
||||
// 判断当前用户是否已拉取完user_info信息
|
||||
useUserStore().getInfo().then(() => {
|
||||
|
||||
@@ -37,15 +37,18 @@ const useUserStore = defineStore(
|
||||
const res=response.data;
|
||||
const user = res.user
|
||||
const avatar = (user.avatar == "" || user.avatar == null) ? defAva : import.meta.env.VITE_APP_BASE_API + user.avatar;
|
||||
|
||||
|
||||
if (res.roleCodes && res.roleCodes.length > 0) { // 验证返回的roles是否是一个非空数组
|
||||
// this.roles = res.roleCodes
|
||||
// this.permissions = res.permissionCodes
|
||||
this.roles = ["admin"];
|
||||
this.permissions=["*:*:*"]
|
||||
|
||||
} else {
|
||||
this.roles = ['ROLE_DEFAULT']
|
||||
}
|
||||
this.roles = ["admin"];
|
||||
this.permissions=["*:*:*"]
|
||||
this.name = user.userName
|
||||
this.avatar = avatar;
|
||||
resolve(res)
|
||||
|
||||
@@ -88,19 +88,19 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top" v-if="scope.row.userName != 'c'">
|
||||
<el-tooltip content="修改" placement="top" v-if="scope.row.userName != 'test'">
|
||||
<el-button type="text" icon="Edit" @click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['system:user:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top" v-if="scope.row.userName != 'c'">
|
||||
<el-tooltip content="删除" placement="top" v-if="scope.row.userName != 'test'">
|
||||
<el-button type="text" icon="Delete" @click="handleDelete(scope.row)"
|
||||
v-hasPermi="['system:user:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="重置密码" placement="top" v-if="scope.row.userName != 'c'">
|
||||
<el-tooltip content="重置密码" placement="top" v-if="scope.row.userName != 'test'">
|
||||
<el-button type="text" icon="Key" @click="handleResetPwd(scope.row)"
|
||||
v-hasPermi="['system:user:resetPwd']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="分配角色" placement="top" v-if="scope.row.userName != 'c'">
|
||||
<el-tooltip content="分配角色" placement="top" v-if="scope.row.userName != 'test'">
|
||||
<el-button type="text" icon="CircleCheck" @click="handleAuthRole(scope.row)"
|
||||
v-hasPermi="['system:user:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
Reference in New Issue
Block a user