diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs index 0b746043..39cf7e08 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/MenuController.cs @@ -27,7 +27,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers public async Task GetMenu() { - return Result.Success().SetData(await _menuService.GetMenuMould()); + return Result.Success().SetData(await _menuService.GetAllEntitiesTrueAsync()); } /// @@ -105,7 +105,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers public async Task AddChildrenMenu(ChildrenDto childrenDto) { - var _children= await _menuService.AddChildrenMenu(new menu() { id=childrenDto.parentId}, childrenDto.data); + var _children= await _menuService.AddChildrenMenu(childrenDto.parentId, childrenDto.data); return Result.Success(); } /// diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs index 0b1f374b..5f2225d9 100644 --- a/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs +++ b/Yi.Framework/Yi.Framework.ApiMicroservice/Controllers/UserController.cs @@ -108,6 +108,29 @@ namespace Yi.Framework.ApiMicroservice.Controllers var roleList = await _userService.GetRolesByUser(_user); return Result.Success().SetData(roleList); } + /// + /// 根据用户id得到该用户有哪些角色 + /// + /// + [HttpGet] + public async Task GetRolesByUserId(int user_id) + { + var _user =await _userService.GetEntityById(user_id); + var roleList = await _userService.GetRolesByUser(_user); + return Result.Success().SetData(roleList); + } + /// + /// 根据http上下文的用户得到该用户信息,关联角色 + /// + /// + [HttpGet] + public async Task GetUserInfoById() + { + var _user = HttpContext.GetCurrentUserInfo(); + return Result.Success().SetData(await _userService.GetUserInfoById(_user.id)); + } + + } } diff --git a/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db b/Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db index f084e71b..ce65e2c6 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..41e182bc 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..bf0bc32d 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 e0d24536..4e7e7357 100644 --- a/Yi.Framework/Yi.Framework.Interface/IMenuService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IMenuService.cs @@ -49,7 +49,7 @@ namespace Yi.Framework.Interface /// /// /// - Task AddChildrenMenu(menu _menu, menu _children); + Task AddChildrenMenu(int menu_id, menu _children); /// /// 获取根目录菜单 /// diff --git a/Yi.Framework/Yi.Framework.Interface/IUserService.cs b/Yi.Framework/Yi.Framework.Interface/IUserService.cs index 8a60b2c9..b0160e82 100644 --- a/Yi.Framework/Yi.Framework.Interface/IUserService.cs +++ b/Yi.Framework/Yi.Framework.Interface/IUserService.cs @@ -63,5 +63,11 @@ namespace Yi.Framework.Interface /// /// Task> GetMenuByUser(user _user); + /// + /// 通过用户id,得到该用户的所有信息,关联角色 + /// + /// + /// + Task GetUserInfoById(int user_id); } } diff --git a/Yi.Framework/Yi.Framework.Service/MenuService.cs b/Yi.Framework/Yi.Framework.Service/MenuService.cs index 0da06e45..0a73b762 100644 --- a/Yi.Framework/Yi.Framework.Service/MenuService.cs +++ b/Yi.Framework/Yi.Framework.Service/MenuService.cs @@ -11,9 +11,9 @@ namespace Yi.Framework.Service { public partial class MenuService:BaseService, IMenuService { - public async Task AddChildrenMenu(menu _menu, menu _children) + public async Task AddChildrenMenu(int menu_id, menu _children) { - var menu_data = await _Db.Set().Include(u => u.children).Where(u => u.id == _menu.id).FirstOrDefaultAsync(); + var menu_data = await _Db.Set().Include(u => u.children).Where(u => u.id == menu_id).FirstOrDefaultAsync(); _children.is_top = (short)Common.Enum.TopFlagEnum.Children; menu_data.children.Add(_children); await UpdateAsync(menu_data); @@ -58,7 +58,8 @@ namespace Yi.Framework.Service public async Task GetMenuMouldByMenu(menu _menu) { - var menu_data = await _Db.Set().Include(u => u.children).Include(u=>u.mould).Where(u=>u.id==_menu.id).FirstOrDefaultAsync(); + var menu_data = await _Db.Set().Include(u => u.children).Include(u=>u.mould) + .Where(u=>u.id==_menu.id&& u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); return menu_data; } diff --git a/Yi.Framework/Yi.Framework.Service/UserService.cs b/Yi.Framework/Yi.Framework.Service/UserService.cs index b41af503..31835bb8 100644 --- a/Yi.Framework/Yi.Framework.Service/UserService.cs +++ b/Yi.Framework/Yi.Framework.Service/UserService.cs @@ -113,6 +113,11 @@ namespace Yi.Framework.Service } return menu_data; } - - } + public async Task GetUserInfoById(int user_id) + { + var user_data=await _Db.Set().Include(u=>u.roles) + .Where(u => u.id == user_id && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync(); + return user_data; + } + } }