diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
index c081745b..5c7257c5 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml
@@ -9,6 +9,12 @@
账户管理
+
+
+ 重置管理员CC的密码
+
+
+
没啥说,登录
@@ -432,6 +438,13 @@
+
+
+ 更新个人中心信息
+
+
+
+
添加用户
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs
index fad47913..e9527636 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs
@@ -36,6 +36,20 @@ namespace Yi.Framework.ApiMicroservice.Controllers
_logger = logger;
}
+ ///
+ /// 重置管理员CC的密码
+ ///
+ ///
+ [HttpGet]
+ public async Task RestCC()
+ {
+ var user= await _iUserService._repository.GetFirstAsync(u => u.UserName == "cc");
+ user.Password = "123456";
+ user.BuildPassword();
+ await _iUserService._repository.UpdateIgnoreNullAsync(user);
+ return Result.Success();
+ }
+
///
/// 没啥说,登录
///
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs
index d82df68e..f8406471 100644
--- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs
+++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/UserController.cs
@@ -90,6 +90,18 @@ namespace Yi.Framework.ApiMicroservice.Controllers
return Result.Success().SetStatus(await _iUserService.UpdateInfo(userDto));
}
+
+ ///
+ /// 更新个人中心信息
+ ///
+ ///
+ ///
+ [HttpPut]
+ public async Task UpdateProfile(UserInfoDto userDto)
+ {
+ return Result.Success().SetStatus(await _iUserService.UpdateProfile(userDto));
+ }
+
///
/// 添加用户
///
diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db
index 73355b6d..6b62182e 100644
Binary files a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db and b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/yi-sqlsugar-dev.db differ
diff --git a/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs
index 2c79d12e..94bf093a 100644
--- a/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs
@@ -116,5 +116,12 @@ namespace Yi.Framework.Interface
///
///
Task UpdatePassword(UpdatePasswordDto dto, long userId);
+
+ ///
+ /// 个人中心信息更新
+ ///
+ ///
+ ///
+ Task UpdateProfile(UserInfoDto userDto);
}
}
diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs
index 1887c3e2..3c5eb373 100644
--- a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs
+++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs
@@ -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 userRoleEntities = new();
- foreach (var roleId in roleIds)
+ //遍历用户
+ foreach (var userId in userIds)
{
- userRoleEntities.Add(new UserRoleEntity() { UserId = userId, RoleId = roleId });
- }
+ //添加新的关系
+ List 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 userPostEntities = new();
- foreach (var post in postIds)
+ //遍历用户
+ foreach (var userId in userIds)
{
- userPostEntities.Add(new UserPostEntity() { UserId = userId, PostId = post });
+ //添加新的关系
+ List 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 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 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>(data, total);
}
@@ -268,5 +284,15 @@ namespace Yi.Framework.Service
newUser.BuildPassword();
return await _repository.UpdateIgnoreNullAsync(newUser);
}
+
+
+ public async Task UpdateProfile(UserInfoDto userDto)
+ {
+ userDto.User.Salt = null;
+ userDto.User.Password = null;
+ userDto.User.DeptId = null;
+ return await _repository.UpdateIgnoreNullAsync(userDto.User);
+ }
+
}
}
diff --git a/Yi.Vue3.X.RuoYi/src/api/system/user.js b/Yi.Vue3.X.RuoYi/src/api/system/user.js
index 308a6256..aa88ec0f 100644
--- a/Yi.Vue3.X.RuoYi/src/api/system/user.js
+++ b/Yi.Vue3.X.RuoYi/src/api/system/user.js
@@ -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}
})
}
diff --git a/Yi.Vue3.X.RuoYi/src/directive/permission/hasPermi.js b/Yi.Vue3.X.RuoYi/src/directive/permission/hasPermi.js
index 44ef3f82..95fb3f4f 100644
--- a/Yi.Vue3.X.RuoYi/src/directive/permission/hasPermi.js
+++ b/Yi.Vue3.X.RuoYi/src/directive/permission/hasPermi.js
@@ -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
diff --git a/Yi.Vue3.X.RuoYi/src/permission.js b/Yi.Vue3.X.RuoYi/src/permission.js
index a7447aa4..5492dda1 100644
--- a/Yi.Vue3.X.RuoYi/src/permission.js
+++ b/Yi.Vue3.X.RuoYi/src/permission.js
@@ -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(() => {
diff --git a/Yi.Vue3.X.RuoYi/src/store/modules/user.js b/Yi.Vue3.X.RuoYi/src/store/modules/user.js
index f709f2d4..e856e983 100644
--- a/Yi.Vue3.X.RuoYi/src/store/modules/user.js
+++ b/Yi.Vue3.X.RuoYi/src/store/modules/user.js
@@ -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)
diff --git a/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue
index 2e5354d9..89ad5b23 100644
--- a/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue
+++ b/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue
@@ -88,19 +88,19 @@
-
+
-
+
-
+
-
+