diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml index 2a275347..c081745b 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Config/SwaggerDoc.xml @@ -41,13 +41,6 @@ - - - 更新登录的用户密码 - - - - 更新已登录用户的用户信息 @@ -55,6 +48,13 @@ + + + 自己更新密码 + + + + Json To Sql 类比模式,通用模型 diff --git a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index 154ccb99..fad47913 100644 --- a/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework.Net6/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -111,34 +111,12 @@ namespace Yi.Framework.ApiMicroservice.Controllers { var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id; var data = await _iUserService.GetUserAllInfo(userId); - + //将后端菜单转换成前端路由,组件级别需要过滤 List routers = MenuEntity.RouterBuild(data.Menus.ToList()); return Result.Success().SetData(routers); } - - /// - /// 更新登录的用户密码 - /// - /// - /// - [HttpPut] - public async Task UpdatePassword(UpdatePasswordDto updatePasswordDto) - { - var userId = HttpContext.GetCurrentUserEntityInfo(out _).Id; - var userEntiy = await _iUserService._repository.GetByIdAsync(userId); - - //判断输入的老密码是否和原密码相同 - if (userEntiy.JudgePassword(updatePasswordDto.OldPassword)) - { - userEntiy.Password = updatePasswordDto.NewPassword; - userEntiy.BuildPassword(); - return Result.Success().SetStatus(await _iUserService._repository.UpdateAsync(userEntiy)); - } - return Result.SuccessError("原密码错误!"); - } - /// /// 更新已登录用户的用户信息 /// @@ -155,5 +133,22 @@ namespace Yi.Framework.ApiMicroservice.Controllers user.Id = HttpContext.GetCurrentUserEntityInfo(out _).Id; return Result.Success().SetStatus(await _iUserService._repository.UpdateIgnoreNullAsync(user)); } + + /// + /// 自己更新密码 + /// + /// + /// + [HttpPut] + public async Task UpdatePassword(UpdatePasswordDto dto) + { + long userId = HttpContext.GetCurrentUserEntityInfo(out _).Id; + + if (await _iUserService.UpdatePassword(dto, userId)) + { + return Result.Success(); + } + return Result.Error("更新失败!"); + } } } 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 6b7267aa..73355b6d 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 7791f6b2..2c79d12e 100644 --- a/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Interface/IUserService.cs @@ -68,8 +68,6 @@ namespace Yi.Framework.Interface /// Task GetUserAllInfo(long userId); - - /// /// 动态条件分页查询 /// @@ -100,6 +98,23 @@ namespace Yi.Framework.Interface /// /// Task RestPassword(long userId,string password ); + + + /// + /// 给用户设置岗位 + /// + /// + /// + /// Task GiveUserSetPost(List userIds, List postIds); + + + /// + /// 更新密码 + /// + /// + /// + /// + Task UpdatePassword(UpdatePasswordDto dto, long userId); } } diff --git a/Yi.Framework.Net6/Yi.Framework.Model/UserEntity.cs b/Yi.Framework.Net6/Yi.Framework.Model/UserEntity.cs index 470fdd20..dd3d2275 100644 --- a/Yi.Framework.Net6/Yi.Framework.Model/UserEntity.cs +++ b/Yi.Framework.Net6/Yi.Framework.Model/UserEntity.cs @@ -41,6 +41,7 @@ namespace Yi.Framework.Model.Models /// public bool JudgePassword(string password) { + var p = MD5Helper.SHA2Encode(password, this.Salt); if (this.Password == MD5Helper.SHA2Encode(password, this.Salt)) { return true; diff --git a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs index 5f48733d..1887c3e2 100644 --- a/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework.Net6/Yi.Framework.Service/UserService.cs @@ -202,7 +202,7 @@ namespace Yi.Framework.Service { //如果deptId不为空,部门id以下及自己都可以 List deptIds = (await _repository._Db.Queryable().ToChildListAsync(it => it.ParentId, deptId)).Select(d => d.Id).ToList(); - query = query.Where(u => u.DeptId!=null&& deptIds.Contains((long)u.DeptId)); + query = query.Where(u => u.DeptId != null && deptIds.Contains((long)u.DeptId)); } data = await query.OrderBy(u => u.OrderNum, OrderByType.Desc) @@ -248,5 +248,25 @@ namespace Yi.Framework.Service } + + + public async Task UpdatePassword(UpdatePasswordDto dto, long userId) + { + var user = await _repository.GetByIdAsync(userId); + + if (dto.OldPassword.Equals(dto.NewPassword)) + { + return false; + } + if (!user.JudgePassword(dto.OldPassword)) + { + return false; + } + var newUser = new UserEntity(); + newUser.Password = dto.NewPassword; + newUser.Id = userId; + newUser.BuildPassword(); + return await _repository.UpdateIgnoreNullAsync(newUser); + } } } diff --git a/Yi.Vue3.X.RuoYi/src/api/system/user.js b/Yi.Vue3.X.RuoYi/src/api/system/user.js index 39b14803..308a6256 100644 --- a/Yi.Vue3.X.RuoYi/src/api/system/user.js +++ b/Yi.Vue3.X.RuoYi/src/api/system/user.js @@ -75,7 +75,7 @@ export function changeUserStatus(userId, isDel) { // 查询用户个人信息 export function getUserProfile() { return request({ - url: '/system/user/profile', + url: '/account/getUserAllInfo', method: 'get' }) } @@ -96,9 +96,9 @@ export function updateUserPwd(oldPassword, newPassword) { newPassword } return request({ - url: '/system/user/profile/updatePwd', + url: '/account/UpdatePassword', method: 'put', - params: data + data: data }) } diff --git a/Yi.Vue3.X.RuoYi/src/views/login.vue b/Yi.Vue3.X.RuoYi/src/views/login.vue index dd2fc4b1..bb37ba44 100644 --- a/Yi.Vue3.X.RuoYi/src/views/login.vue +++ b/Yi.Vue3.X.RuoYi/src/views/login.vue @@ -76,7 +76,7 @@ const { proxy } = getCurrentInstance(); const loginForm = ref({ username: "cc", - password: "123", + password: "123456", rememberMe: false, code: "", uuid: "" diff --git a/Yi.Vue3.X.RuoYi/src/views/system/dept/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/dept/index.vue index 1479acae..8c02caca 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/dept/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/dept/index.vue @@ -135,11 +135,7 @@ - {{ dict.label }} + {{dict.label}} diff --git a/Yi.Vue3.X.RuoYi/src/views/system/dict/data.vue b/Yi.Vue3.X.RuoYi/src/views/system/dict/data.vue index 26fefe3a..e40296af 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/dict/data.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/dict/data.vue @@ -161,13 +161,9 @@ > - - - {{ dict.label }} + + + {{dict.label}} diff --git a/Yi.Vue3.X.RuoYi/src/views/system/dict/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/dict/index.vue index 43f53c85..62d56424 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/dict/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/dict/index.vue @@ -160,11 +160,7 @@ - {{ dict.label }} + {{dict.label}} diff --git a/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue index 539572be..1990ffef 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/menu/index.vue @@ -274,11 +274,7 @@ - {{ dict.label }} + {{dict.label}} diff --git a/Yi.Vue3.X.RuoYi/src/views/system/post/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/post/index.vue index 752670f4..d1b66a4c 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/post/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/post/index.vue @@ -131,11 +131,7 @@ - {{ dict.label }} + {{dict.label}} diff --git a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue index 2e24a464..99d9cc4d 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/role/index.vue @@ -109,8 +109,7 @@ - {{ dict.label }} - + {{dict.label}} 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 af419287..2e5354d9 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/user/index.vue @@ -165,11 +165,8 @@ - {{form.user.isDeleted}} - - {{dict.value+ dict.label - }} + {{dict.label}} diff --git a/Yi.Vue3.X.RuoYi/src/views/system/user/profile/index.vue b/Yi.Vue3.X.RuoYi/src/views/system/user/profile/index.vue index 9ef98407..ecea87d1 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/user/profile/index.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/user/profile/index.vue @@ -19,7 +19,7 @@
  • 手机号码 -
    {{ state.user.phonenumber }}
    +
    {{ state.user.phone }}
  • 用户邮箱 @@ -27,11 +27,11 @@
  • 所属部门 -
    {{ state.user.dept.deptName }} / {{ state.postGroup }}
    +
    {{ state.dept.deptName }}
  • 所属角色 -
    {{ state.roleGroup }}
    +
    {{ role.roleName }} /
  • 创建日期 @@ -71,13 +71,17 @@ import { getUserProfile } from "@/api/system/user"; const activeTab = ref("userinfo"); const state = reactive({ user: {}, + dept: {}, + roles: [], roleGroup: {}, postGroup: {} }); function getUser() { getUserProfile().then(response => { - state.user = response.data; + state.user = response.data.user; + state.dept=response.data.dept; + state.roles=response.data.roles; state.roleGroup = response.roleGroup; state.postGroup = response.postGroup; }); diff --git a/Yi.Vue3.X.RuoYi/src/views/system/user/profile/userInfo.vue b/Yi.Vue3.X.RuoYi/src/views/system/user/profile/userInfo.vue index 2d62c842..52bac135 100644 --- a/Yi.Vue3.X.RuoYi/src/views/system/user/profile/userInfo.vue +++ b/Yi.Vue3.X.RuoYi/src/views/system/user/profile/userInfo.vue @@ -1,10 +1,10 @@