完善控制器接口
This commit is contained in:
@@ -27,7 +27,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public async Task<Result> GetMenu()
|
||||
{
|
||||
|
||||
return Result.Success().SetData(await _menuService.GetMenuMould());
|
||||
return Result.Success().SetData(await _menuService.GetAllEntitiesTrueAsync());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -105,7 +105,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
public async Task<Result> AddChildrenMenu(ChildrenDto<menu> 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();
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
@@ -108,6 +108,29 @@ namespace Yi.Framework.ApiMicroservice.Controllers
|
||||
var roleList = await _userService.GetRolesByUser(_user);
|
||||
return Result.Success().SetData(roleList);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据用户id得到该用户有哪些角色
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetRolesByUserId(int user_id)
|
||||
{
|
||||
var _user =await _userService.GetEntityById(user_id);
|
||||
var roleList = await _userService.GetRolesByUser(_user);
|
||||
return Result.Success().SetData(roleList);
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据http上下文的用户得到该用户信息,关联角色
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> GetUserInfoById()
|
||||
{
|
||||
var _user = HttpContext.GetCurrentUserInfo();
|
||||
return Result.Success().SetData(await _userService.GetUserInfoById(_user.id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm
Normal file
BIN
Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-shm
Normal file
Binary file not shown.
BIN
Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal
Normal file
BIN
Yi.Framework/Yi.Framework.ApiMicroservice/YIDB.db-wal
Normal file
Binary file not shown.
@@ -49,7 +49,7 @@ namespace Yi.Framework.Interface
|
||||
/// </summary>
|
||||
/// <param name="_menu"></param>
|
||||
/// <returns></returns>
|
||||
Task<menu> AddChildrenMenu(menu _menu, menu _children);
|
||||
Task<menu> AddChildrenMenu(int menu_id, menu _children);
|
||||
/// <summary>
|
||||
/// 获取根目录菜单
|
||||
/// </summary>
|
||||
|
||||
@@ -63,5 +63,11 @@ namespace Yi.Framework.Interface
|
||||
/// <param name="_user"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<menu>> GetMenuByUser(user _user);
|
||||
/// <summary>
|
||||
/// 通过用户id,得到该用户的所有信息,关联角色
|
||||
/// </summary>
|
||||
/// <param name="user_id"></param>
|
||||
/// <returns></returns>
|
||||
Task<user> GetUserInfoById(int user_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace Yi.Framework.Service
|
||||
{
|
||||
public partial class MenuService:BaseService<menu>, IMenuService
|
||||
{
|
||||
public async Task<menu> AddChildrenMenu(menu _menu, menu _children)
|
||||
public async Task<menu> AddChildrenMenu(int menu_id, menu _children)
|
||||
{
|
||||
var menu_data = await _Db.Set<menu>().Include(u => u.children).Where(u => u.id == _menu.id).FirstOrDefaultAsync();
|
||||
var menu_data = await _Db.Set<menu>().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<menu> GetMenuMouldByMenu(menu _menu)
|
||||
{
|
||||
var menu_data = await _Db.Set<menu>().Include(u => u.children).Include(u=>u.mould).Where(u=>u.id==_menu.id).FirstOrDefaultAsync();
|
||||
var menu_data = await _Db.Set<menu>().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;
|
||||
}
|
||||
|
||||
|
||||
@@ -113,6 +113,11 @@ namespace Yi.Framework.Service
|
||||
}
|
||||
return menu_data;
|
||||
}
|
||||
|
||||
}
|
||||
public async Task<user> GetUserInfoById(int user_id)
|
||||
{
|
||||
var user_data=await _Db.Set<user>().Include(u=>u.roles)
|
||||
.Where(u => u.id == user_id && u.is_delete == (short)Common.Enum.DelFlagEnum.Normal).FirstOrDefaultAsync();
|
||||
return user_data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user