using AutoMapper;
using IRaCIS.Application.Services.BusinessFilter;
using IRaCIS.Core.Infra.EFCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Localization;
using Panda.DynamicWebApi;
using Panda.DynamicWebApi.Attributes;
using System.Diagnostics.CodeAnalysis;
using IRaCIS.Core.Domain.Share;

namespace IRaCIS.Core.Application
{

#pragma warning disable CS8618


    #region 非泛型版本

    [Authorize, DynamicWebApi, UnifiedApiResultFilter]
    public class BaseService : IBaseService, IDynamicWebApi
    {
        public IMapper _mapper { get; set; }

        public IUserInfo _userInfo { get; set; }

        public IRepository _repository { get; set; }

        public IStringLocalizer _localizer { get; set; }

        public IWebHostEnvironment _hostEnvironment { get; set; }




        public static IResponseOutput Null404NotFound<TEntity>(TEntity? businessObject) where TEntity : class
        {
            return new ResponseOutput<string>()
            .NotOk($"The query object {typeof(TEntity).Name} does not exist , or was deleted by someone else, or an incorrect parameter query caused", code: ApiResponseCodeEnum.DataNotExist);
        }
    }


    public interface IBaseService
    {
        [MemberNotNull(nameof(_mapper))]
        public IMapper _mapper { get; set; }

        [MemberNotNull(nameof(_userInfo))]
        public IUserInfo _userInfo { get; set; }

        [MemberNotNull(nameof(_repository))]
        public IRepository _repository { get; set; }

        [MemberNotNull(nameof(_localizer))]
        public IStringLocalizer _localizer { get; set; }

        [MemberNotNull(nameof(_hostEnvironment))]
        public IWebHostEnvironment _hostEnvironment { get; set; }

    }
    #endregion


    #region 泛型版本测试


    public interface IBaseServiceTest<T> where T : Entity
    {
        [MemberNotNull(nameof(_mapper))]
        public IMapper _mapper { get; set; }

        [MemberNotNull(nameof(_userInfo))]
        public IUserInfo _userInfo { get; set; }

        [MemberNotNull(nameof(_repository))]
        public IRepository _repository { get; set; }

        [MemberNotNull(nameof(_localizer))]
        public IStringLocalizer _localizer { get; set; }


      
    }


    [Authorize, DynamicWebApi, UnifiedApiResultFilter]
    public class BaseServiceTest<T> : IBaseServiceTest<T>, IDynamicWebApi where T : Entity
    {
        public IMapper _mapper { get; set; }

        public IUserInfo _userInfo { get; set; }

        public IRepository _repository { get; set; }

        public IStringLocalizer _localizer { get; set; }

        public static IResponseOutput Null404NotFound<TEntity>(TEntity? businessObject) where TEntity : class
        {
            return new ResponseOutput<string>()
            .NotOk($"The query object {typeof(TEntity).Name} does not exist , or was deleted by someone else, or an incorrect parameter query caused", code: ApiResponseCodeEnum.DataNotExist);
        }


    }


    #endregion







}
