using APT.BaseData.Domain.Entities;
using APT.BaseData.Domain.IServices;
using APT.Infrastructure.Core;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using APT.Utility;
using APT.Utility;
using APT.BaseData.Domain.Entities.T4;
using System.Threading.Tasks;
using APT.Infrastructure.Api;
using APT.BaseData.Domain.Enums.PF;

namespace APT.PF.WebApiControllers.Api.PF
{
    [Route("api/PF/AppVersionInfo")]
    public class AppVersionInfoController : APTApiController<T_PF_APP_VERSION>
    {

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet, Route("LastVersionUrl")]
        public JsonActionResult<string> LastVersionUrl()
        {
            return SafeExecute<string>(() =>
            {
                BaseFilter filter = new BaseFilter();
                filter.IsSpecifyDb = true;
                filter.SpecifyTenant = HeadHelper.HeadtelnetCode;
                filter.IgnoreOrgRule = true;
                filter.Order = DbOrder.DESC;
                filter.Sort = "CREATE_TIME";
                var appVersion = this.GetEntity<T_PF_APP_VERSION>(i => i.UPGRADE == (int)UpgradeType.全量, filter, "Nav_Files.Nav_ImgFile");
                return appVersion?.Nav_Files?.FirstOrDefault()?.Nav_ImgFile.FILE_PATH;
            });
        }



    }
}
