using Hncore.Infrastructure.Service;
using Hncore.Pass.Vpn.Domain;
using Hncore.Wx.Open;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Hncore.Pass.Vpn.Service
{
    public partial class WxAppUserService : ServiceBase<WxAppUserEntity>
    {
        WxAppService m_WxAppService;
        public WxAppUserService(WxAppService _WxAppService, CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
        {
            m_WxAppService = _WxAppService;
        }
        public async Task<List<WxAppUserEntity>> GetWxUsers(List<int> UserId)
        {
            return await this.Query(m => UserId.Contains(m.UserId)).ToListAsync();
        }

        public async Task<WxAppUserEntity> GetWxUser(string appId, int userId)
        {
            return await this.Query(m => m.Appid == appId && m.UserId == userId).FirstOrDefaultAsync();
        }

        public async Task<WxAppUserEntity> GetWxUser(string appId, string openId)
        {
            return await this.Query(m => m.Appid == appId && m.Openid == openId).FirstOrDefaultAsync();
        }
    }
}