using EntrustSettle.IRepository;
using EntrustSettle.Model.Models;
using EntrustSettle.Repository.Base;
using SqlSugar;
using System.Collections.Generic;
using System.Threading.Tasks;
using EntrustSettle.Repository.UnitOfWorks;
namespace EntrustSettle.Repository
{
///
/// RoleModulePermissionRepository
///
public class RoleModulePermissionRepository : BaseRepository, IRoleModulePermissionRepository
{
public RoleModulePermissionRepository(IUnitOfWorkManage unitOfWorkManage) : base(unitOfWorkManage)
{
}
///
/// 角色权限Map
/// RoleModulePermission, Module, Role 三表联合
/// 第四个类型 RoleModulePermission 是返回值
///
///
public async Task> RoleModuleMaps()
{
return await Db.Queryable(
(rmp, m, r) => new object[] {
JoinType.Left, rmp.ModuleId == m.Id,
JoinType.Left, rmp.RoleId == r.Id
})
.Where((rmp, m, r) => rmp.IsDeleted == false && m.IsDeleted == false && r.IsDeleted == false)
.Select((rmp, m, r) => new RoleModulePermission()
{
Role = r,
Module = m,
IsDeleted = rmp.IsDeleted
})
.ToListAsync();
}
}
}