using System.Threading.Tasks;
using Wicture.DbRESTFul.Infrastructure.Repository;
using MySql.Data.MySqlClient;
using Wicture.DbRESTFul.Configuration;

namespace JiaZhiQuan.Common
{
    public static partial class RepositoryExtension
    {

        /// <summary>
        /// 获取视频的上传状态
        /// </summary>
        public async static Task<VideoUploadState> GetVodVideoUploadState(this DbRESTFulRepository repository, string videoId)
        {
            //获取配置文件中的ProdCommonConnection数据库连接字符串
            var prodConnStr = ConfigurationManager.Settings.GetConfig<string>("ProdCommonConnection");
            await using var prodConn = new MySqlConnection(prodConnStr);
            await prodConn.OpenAsync();
            return await repository.QuerySingleOrDefaultAsync<VideoUploadState>("select uploadState, width, height from jiazhiquan_vod.s_vod_records where videoId=@videoId", new { videoId }, prodConn);
        }

    }
}
