From ea2be7609cd1884f8f27eec782c71053d8f8e8e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=B7=B3?= Date: Wed, 14 Sep 2022 19:53:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=8A=B6=E6=80=81=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=81=E7=94=A8=E6=88=B7=E4=B8=AD=E5=BF=83=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=9F=A5=E8=AF=A2=E5=8F=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/SwaggerDoc.xml | 14 +++--- .../Controllers/AccountController.cs | 41 ++++++++---------- .../yi-sqlsugar-dev.db | Bin 151552 -> 151552 bytes .../Yi.Framework.Interface/IUserService.cs | 19 +++++++- .../Yi.Framework.Model/UserEntity.cs | 1 + .../Yi.Framework.Service/UserService.cs | 22 +++++++++- Yi.Vue3.X.RuoYi/src/api/system/user.js | 6 +-- Yi.Vue3.X.RuoYi/src/views/login.vue | 2 +- .../src/views/system/dept/index.vue | 6 +-- .../src/views/system/dict/data.vue | 10 ++--- .../src/views/system/dict/index.vue | 6 +-- .../src/views/system/menu/index.vue | 6 +-- .../src/views/system/post/index.vue | 6 +-- .../src/views/system/role/index.vue | 3 +- .../src/views/system/user/index.vue | 5 +-- .../src/views/system/user/profile/index.vue | 12 +++-- .../views/system/user/profile/userInfo.vue | 10 ++--- 17 files changed, 90 insertions(+), 79 deletions(-) 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 6b7267aa7a37bffb97b0eec27bef5b3d26b46d09..73355b6df9dc1713cbe8f713e813f0b0c634575d 100644 GIT binary patch delta 1459 zcmZ{jT})eL7{}jJ*x>-}c@K_GK1S%=8ZS)idC&JL%4my7%SS&Z6i`D88>LMLjPg-t zA|El!^vZEa&}_+O7BVxlL~UZ1Oc%0g+`JHPX0lzlWM+`yE=-7*8sE0ZrZ8+yFP^;b z^M8KN|9zf?E9DDU%0I3r9$z@@CLVtkz6K8f)9)40w2`4JO1z+3YpCBp`qr zxXXcgQGFfM0#JJtP(WL3IA{|rNO5qggJ33^w03AhCEvc>49h=7jszYQQh_iF5jARuJ507?vdMA=7 zq>l9W509J~A4lGS;b5PQZ3~T$&9Je#(Gy+my`8a>fx*uHcx+g7cLuyuTV!%s>v?R#3HVRnAWNnl$*)|S2O)&Gchr*T5D5x5Tye|DBfl8E?yj|4$wCEQ}y zWH2%mlsiM??cO(hQJHHCaf4^4d)opD$vf#vjk#K#ZN6?bs<@KkU|*}>AD9^EOY{tM z_MstPBo^ddGbf#=ZAp2iy*n11nvFPPDc@{l;%sj)?&+I!b_~U$9yhP}-qfV}*+PTq zmmB|L82FL#SK~!v*l4ZXrXRu|(nl<}E7RLee;TS9D@c+AO}J}dzJJU6flK?Nxt`8F zGh!XAWEWUbt3Lj!VFsl;Rk7zXeL4CAyQ^ablXN*U6cMRo%`v-oE< z-_QK=oq++#x#Zw<^3>#D@>Ht$L1c$0I7HFTNiruQX=~;4&GVVfg=yqDgBl)FCO1c(e2YmMBKtymWo*@*1~?RCEZ6UE&cZvr?Whf6rTn z6%Q5^8*$S+6PU1A@#$I`<>cb}y5i2o>?SKnRzzOT>)~4-QWtY(J*2W?+eX7~v8|O1 z`y3mG>`0Y(K}W-PGLhTFRicD~pQg(!%Q^23yrg$a>5k<<%k&^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i.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 @@