using Hotline.Repository.SqlSugar.DataPermissions;
using Hotline.Snapshot;
using Hotline.Snapshot.Interfaces;
using SqlSugar;
using XF.Domain.Dependency;
using XF.Domain.Repository;

namespace Hotline.Repository.SqlSugar.Snapshot;
public class ThirdAccountRepository : BaseRepository<ThirdAccount>,  IThirdAccountRepository , IScopeDependency
{
    public ThirdAccountRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder, IServiceProvider serviceProvider) : base(uow, dataPermissionFilterBuilder, serviceProvider)
    {
    }

    public async Task<ThirdAccount> GetByOpenIdAsync(string openId)
        => await Queryable()
        .Where(p => p.OpenId == openId)
        .FirstAsync();

    public async Task<ThirdAccount?> GetByPhoneNumberAsync(string phoneNumber)
        => await Queryable()
        .Where(m => m.PhoneNumber == phoneNumber)
        .FirstAsync();
}
