using System.Collections.Generic;
using System.Threading.Tasks;
using MDL.Models;

namespace DAL.Interfaces
{
    /// <summary>
    /// 客户API信息的数据访问接口
    /// </summary>
    public interface ICustomerApiRepository
    {
        /// <summary>
        /// 创建客户API记录
        /// </summary>
        /// <param name="entity">客户API实体</param>
        /// <returns>创建的记录ID</returns>
        Task<int> CreateAsync(CustomerApiEntity entity);
        
        /// <summary>
        /// 根据ID获取客户API记录
        /// </summary>
        /// <param name="id">记录ID</param>
        /// <returns>客户API实体</returns>
        Task<CustomerApiEntity?> GetByIdAsync(int id);
        
        /// <summary>
        /// 根据客户ID获取客户API记录
        /// </summary>
        /// <param name="customerId">客户ID</param>
        /// <returns>客户API实体列表</returns>
        Task<List<CustomerApiEntity>> GetByCustomerIdAsync(int customerId);
        
        /// <summary>
        /// 根据客户代码获取客户API记录
        /// </summary>
        /// <param name="customerCode">客户代码</param>
        /// <returns>客户API实体列表</returns>
        Task<List<CustomerApiEntity>> GetByCustomerCodeAsync(string customerCode);
        
        /// <summary>
        /// 根据API密钥获取客户API记录
        /// </summary>
        /// <param name="apiKey">API密钥</param>
        /// <returns>客户API实体</returns>
        Task<CustomerApiEntity?> GetByApiKeyAsync(string apiKey);
        
        /// <summary>
        /// 验证客户API凭证并返回客户API信息
        /// </summary>
        /// <param name="customerCode">客户代码</param>
        /// <param name="apiKey">API密钥</param>
        /// <returns>客户API实体，如果验证失败则返回null</returns>
        Task<CustomerApiEntity?> ValidateAndGetApiCredentialsAsync(string customerCode, string apiKey);
        
        /// <summary>
        /// 验证客户API凭证
        /// </summary>
        /// <param name="customerCode">客户代码</param>
        /// <param name="apiKey">API密钥</param>
        /// <returns>是否验证通过</returns>
        Task<bool> ValidateApiCredentialsAsync(string customerCode, string apiKey);
        
        /// <summary>
        /// 更新客户API记录
        /// </summary>
        /// <param name="entity">客户API实体</param>
        /// <returns>更新是否成功</returns>
        Task<bool> UpdateAsync(CustomerApiEntity entity);
        
        /// <summary>
        /// 删除客户API记录
        /// </summary>
        /// <param name="id">记录ID</param>
        /// <returns>删除是否成功</returns>
        Task<bool> DeleteAsync(int id);
        
        /// <summary>
        /// 获取所有客户API记录
        /// </summary>
        /// <returns>客户API实体列表</returns>
        Task<List<CustomerApiEntity>> GetAllAsync();
    }
}