//----------SysRole开始----------
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Linq;
using Admin.Core.IRepository.ISys;
using Admin.Core.Model.Sys;
namespace Admin.Core.Repository.Sys
{
///
/// 角色信息表Repository
///
public class SysRoleRepository : BaseRepository, ISysRoleRepository
{
private readonly ISysUserRoleRepository _sysUserRoleRepository;
public SysRoleRepository(IUnitOfWork unitOfWork, ISysUserRoleRepository sysUserRoleRepository) : base(unitOfWork)
{
_sysUserRoleRepository = sysUserRoleRepository;
}
///
/// 获取所有角色信息
///
///
///
public async Task> GetUserRolesByUserId(int userId)
{
var userRoles = await _sysUserRoleRepository.QueryAsync(x => x.UserID == userId);
var roleIds = userRoles.Select(x => (int)x.RoleID).ToList();
return await QueryAsync(x => roleIds.Contains(x.RoleID));
}
}
}
//----------SysRole结束----------