using HoneyBox.Admin.Business.Models.Config;

namespace HoneyBox.Admin.Business.Services.Interfaces;

/// <summary>
/// 后台配置服务接口
/// </summary>
public interface IAdminConfigService
{
    /// <summary>
    /// 获取配置
    /// </summary>
    /// <typeparam name="T">配置类型</typeparam>
    /// <param name="key">配置键</param>
    /// <returns>配置对象</returns>
    Task<T?> GetConfigAsync<T>(string key) where T : class;

    /// <summary>
    /// 获取配置（原始JSON字符串）
    /// </summary>
    /// <param name="key">配置键</param>
    /// <returns>配置JSON字符串</returns>
    Task<string?> GetConfigRawAsync(string key);

    /// <summary>
    /// 更新配置
    /// </summary>
    /// <typeparam name="T">配置类型</typeparam>
    /// <param name="key">配置键</param>
    /// <param name="config">配置对象</param>
    /// <returns>是否成功</returns>
    Task<bool> UpdateConfigAsync<T>(string key, T config) where T : class;

    /// <summary>
    /// 更新配置（原始JSON字符串）
    /// </summary>
    /// <param name="key">配置键</param>
    /// <param name="jsonValue">配置JSON字符串</param>
    /// <returns>是否成功</returns>
    Task<bool> UpdateConfigRawAsync(string key, string jsonValue);

    /// <summary>
    /// 验证配置
    /// </summary>
    /// <param name="key">配置键</param>
    /// <param name="jsonValue">配置JSON字符串</param>
    /// <returns>验证结果，null表示验证通过，否则返回错误消息</returns>
    Task<string?> ValidateConfigAsync(string key, string jsonValue);

    /// <summary>
    /// 清理配置缓存
    /// </summary>
    /// <param name="key">配置键</param>
    Task ClearConfigCacheAsync(string key);

    /// <summary>
    /// 清除所有用户海报缓存
    /// </summary>
    /// <returns>清除的记录数</returns>
    Task<int> ClearAllPosterCacheAsync();
}
