You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
1 year ago
|
|
||
|
//----------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
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 角色信息表Repository
|
||
|
/// </summary>
|
||
|
public class SysRoleRepository : BaseRepository<SysRole>, ISysRoleRepository
|
||
|
{
|
||
|
|
||
|
private readonly ISysUserRoleRepository _sysUserRoleRepository;
|
||
|
public SysRoleRepository(IUnitOfWork unitOfWork, ISysUserRoleRepository sysUserRoleRepository) : base(unitOfWork)
|
||
|
{
|
||
|
_sysUserRoleRepository = sysUserRoleRepository;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取所有角色信息
|
||
|
/// </summary>
|
||
|
/// <param name="userId"></param>
|
||
|
/// <returns></returns>
|
||
|
public async Task<List<SysRole>> 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结束----------
|