using Exam.Infrastructure.Data.Entity;
using Exam.Infrastructure.Validation.Validation;
using FluentValidation;
using SqlSugar;
using XF.Domain.Entities;
using XF.Domain.Repository;

namespace Hotline.Repository.SqlSugar.Exam.Interface
{
    public interface IExamRepository<TEntity, TDBContext> : IRepository<TEntity> where TEntity : class, IEntity<string>, IHasCreationTime, IDataPermission, new()
    where TDBContext : SugarUnitOfWork, new()
    {
        public ISugarUnitOfWork<TDBContext> UOW { get; }

        public AbstractValidator<TEntity> Validator { get; set; }

        /// <summary>
        /// 单表新增
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task<string> AddWithValidateAsync(TEntity entity, CancellationToken cancellationToken);

        /// <summary>
        /// 单表批量新增
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task AddWithValidateAsync(List<TEntity> entities, CancellationToken cancellationToken);

        /// <summary>
        /// 单表删除
        /// </summary>
        /// <param name="entityQueryRequest"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task DeleteWithValidateAsync(EntityQueryRequest entityQueryRequest, CancellationToken cancellationToken);

        /// <summary>
        /// 单表修改
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task UpdateWithValidateAsync(TEntity entity, CancellationToken cancellationToken);

        /// <summary>
        /// 单表修改
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task UpdateWithValidateAsync(List<TEntity> entities, CancellationToken cancellationToken);

        /// <summary>
        /// 用于事务（验证新增实体）
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task ValidateAddAsync(List<TEntity> entities, CancellationToken cancellationToken);

        /// <summary>
        /// 用于事务（验证修改实体）
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task ValidateUpdateAsync(List<TEntity> entities, CancellationToken cancellationToken);

        /// <summary>
        /// 用于事务（验证删除实体）
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task ValidateDeleteAsync(EntityQueryRequest entityQueryRequest, CancellationToken cancellationToken);

        /// <summary>
        /// 用于事务（验证新增实体）
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task ValidateAddAsync(TEntity entity, CancellationToken cancellationToken);

        /// <summary>
        /// 用于事务（验证修改实体）
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public Task ValidateUpdateAsync(TEntity entity, CancellationToken cancellationToken);


    }
}
