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 b2c233d8..ddc03b47 100644 Binary files a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db and b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db differ diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm new file mode 100644 index 00000000..bb45466f Binary files /dev/null and b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm differ 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 00000000..095eada3 Binary files /dev/null and b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal differ 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; }