From 0860e05d17f7d5242c80a11f1ff04a0e779804cd Mon Sep 17 00:00:00 2001 From: lzw <605106923@qq.com> Date: Sat, 16 Oct 2021 17:50:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/AccountController.cs | 7 ++++--- .../Controllers/MenuController.cs | 6 +++--- .../Yi.Framework.ApiMicroservice/YIDB.db | Bin 65536 -> 65536 bytes .../Yi.Framework.ApiMicroservice/YIDB.db-shm | Bin 0 -> 32768 bytes .../Yi.Framework.ApiMicroservice/YIDB.db-wal | Bin 0 -> 12392 bytes .../Yi.Framework.Interface/IMenuService.cs | 2 +- .../Yi.Framework.Interface/IUserService.cs | 4 ++-- .../Yi.Framework.Service/MenuService.cs | 7 +++---- .../Yi.Framework.Service/UserService.cs | 13 +++++-------- 9 files changed, 18 insertions(+), 21 deletions(-) create mode 100644 Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm create mode 100644 Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs index 06c7d7cf..375ad1f8 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/AccountController.cs @@ -35,10 +35,11 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPost] public async Task Login(user _user) { - if (await _userService.Login(_user)) + var user_data = await _userService.Login(_user); + if( user_data!=null) { - _user.roles = await _userService.GetRolesByUser(_user); - var toke = MakeJwt.app(_user); + + var toke = MakeJwt.app(user_data); return Result.Success().SetData(new { user = new { _user.id, _user.username, _user.introduction, _user.icon, _user.nick }, toke }); } return Result.Error(); diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs index fe417cd3..3a4aebfc 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs @@ -26,7 +26,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpGet] public async Task GetMenu() { - return Result.Success().SetData(await _menuService.GetAllEntitiesTrueAsync()); + return Result.Success().SetData(await _menuService.GetMenuMouldByMenu( new menu())); } /// @@ -101,8 +101,8 @@ namespace Yi.Framework.ApiMicroservice.Controllers [HttpPost] public async Task AddChildrenMenu(ChildrenDto childrenDto) { - //var _menu = await _menuService.GetEntityById(childrenDto.parentId); - var _children= await _menuService.AddChildrenMenu(childrenDto.parentId,childrenDto.data); + + var _children= await _menuService.AddChildrenMenu(new menu() { id=childrenDto.parentId}, childrenDto.data); return Result.Success(); } diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db index b2c233d87e56f739f19854503b45862550172f91..ddc03b475d05a37c5a9f26d3dd455d193f1111f6 100644 GIT binary patch delta 224 zcmY+;J!%3$9ES1#FyqHKu+MHQ7J`)rP}tf7>|t^M=Liyu^fopY!j{%HS}cMf7HT9- z8W9AsP|(3DX(nXA%*uw6!%6`7>8UjIq{^eDiZ)>W;ba;Kqd$zx=Rc!-^&I@G_=c o(n?u3To!4di~n@bmNf;7Kqr)pme5`tI&sK&1p3Yhf1*Ri3s)RKvH$=8 delta 133 zcmZo@U})hk!$lqe`N&;E`ELn{`>s9`KR+2^ZWBV^PBN&^2_k^Zx$5z%r}|8 z{_AFz1%Ko>EnopDJ2&8LXQ9vS{wJ!*;sa-Hz9Dy*O20?vJC|JU-Gcz9*v? z$5H8SAwYlt0RjXF5FkK+009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+ z009C72oNAZfB*pk1PBlyK!5-N0t5&UAV7cs0RjXF5FkK+009C72oNAZfB*pk1PBoL z6@m21wGhZtpqFRcx+Xw?009C72oNAZfB*pk1PJ`KK>E*52oNAZfB*pk1PBlyK!5;& Gyak>n$RdmY literal 0 HcmV?d00001 diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal new file mode 100644 index 0000000000000000000000000000000000000000..095eada39750cd75b40bc9bf82b3a3413ee70ab9 GIT binary patch literal 12392 zcmeI&I|{-;6ouh=B!LlRQi^pxL1Q0*~0R#|0009ILKmY**5U7rTr?inuOKn^yP;-lweZjnSjc(6D;zDIp*9)ZX zpFsct1Q0*~0R#|0009ILKmdVi2n3#yQYp_fzh1x{5`<+h;5UL%ZxauTULX_pW3y^( h%@znCfB*srAb99+13JGK_yS<>D6s$l literal 0 HcmV?d00001 diff --git a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs index 8bd350c5..f360d358 100644 --- a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs @@ -45,6 +45,6 @@ namespace Yi.Framework.Interface /// /// /// - Task AddChildrenMenu(int _menuId, menu _children); + Task AddChildrenMenu(menu _menu, menu _children); } } diff --git a/Yi.Framework/Yi.Framework.Interface/IUserService.cs b/Yi.Framework/Yi.Framework.Interface/IUserService.cs index 73de2f0e..32df6a1a 100644 --- a/Yi.Framework/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IUserService.cs @@ -13,10 +13,10 @@ namespace Yi.Framework.Interface Task> GetAllEntitiesTrueAsync(); /// - /// 登录,传入_user需包含用户名与密码 + /// 登录,传入_user需包含用户名与密码/角色 /// /// - Task Login(user _user); + Task Login(user _user); /// /// 注册,需要检测是否用户名重复 diff --git a/Yi.Framework/Yi.Framework.Service/MenuService.cs b/Yi.Framework/Yi.Framework.Service/MenuService.cs index 31f357d2..ccea412f 100644 --- a/Yi.Framework/Yi.Framework.Service/MenuService.cs +++ b/Yi.Framework/Yi.Framework.Service/MenuService.cs @@ -13,10 +13,9 @@ namespace Yi.Framework.Service { public MenuService(DbContext Db) : base(Db) { } - public async Task AddChildrenMenu(int _menuId, menu _children) + public async Task AddChildrenMenu(menu _menu, menu _children) { - var menu_data = await _Db.Set().Include(u=>u.children) - .Where(u=>u.id==_menuId&& u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); + var menu_data = await _Db.Set().Include(u => u.children).Where(u => u.id == _menu.id).FirstOrDefaultAsync(); menu_data.children.Add(_children); await UpdateAsync(menu_data); return menu_data; @@ -43,7 +42,7 @@ namespace Yi.Framework.Service public async Task GetMenuMouldByMenu(menu _menu) { - var menu_data = await _Db.Set().Where(u=>u.id==_menu.id).Include(u=>u.mould).FirstOrDefaultAsync(); + var menu_data = await _Db.Set().Include(u => u.children).Include(u=>u.mould).Where(u=>u.id==_menu.id).FirstOrDefaultAsync(); return menu_data; } diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework/Yi.Framework.Service/UserService.cs index 004001dd..39fd1557 100644 --- a/Yi.Framework/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework/Yi.Framework.Service/UserService.cs @@ -63,15 +63,12 @@ namespace Yi.Framework.Service return roleList; } - public async Task Login(user _user) + public async Task Login(user _user) { - var user_data =await GetEntity(u => u.username == _user.username&&u.password==_user.password&& - u.is_delete == (short)Common.Enum.DelFlagEnum.Normal); - if (user_data == null) - { - return false; - } - return true; + var user_data =await _Db.Set().Include(u=>u.roles).Where(u => u.username == _user.username&&u.password==_user.password&& + u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); + + return user_data; }