using Hotline.Users;

namespace Hotline.Caching.Interfaces
{
    public interface IUserCacheManager
    {
        /// <summary>
        ///  查询分机最近的工作记录
        /// </summary>
        /// <param name="telNo"></param>
        /// <returns></returns>
        Task<Work> GetWorkByTelNoLast(string telNo);

        /// <summary>
        /// 查询用户当前工作记录
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Work GetWorkByUser(string userId);

        /// <summary>
        /// 查询用户当前工作记录（不抛异常）
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        Work? GetWorkByUserNoExp(string userId);

        /// <summary>
        /// 查询分机当前工作记录
        /// </summary>
        /// <param name="telNo"></param>
        /// <returns></returns>
        Work GetWorkByTel(string telNo);

        /// <summary>
        /// 查询分机当前工作记录
        /// </summary>
        /// <param name="telNo"></param>
        /// <returns></returns>
        Work? GetWorkByTelNoExp(string telNo);

        /// <summary>
        /// 查询分机是否处于工作
        /// </summary>
        /// <param name="telNo"></param>
        /// <returns></returns>
        Task<bool> IsWorkingByTelAsync(string telNo, CancellationToken cancellationToken);

        /// <summary>
        /// 查询分机是否处于工作
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        Task<bool> IsWorkingByUserAsync(string userId, CancellationToken cancellationToken);

        /// <summary>
        /// 根据用户更新工作记录
        /// </summary>
        /// <param name="work"></param>
        /// <returns></returns>
        void UpdateWorkByUser(Work work);

        /// <summary>
        /// 查询所有在工作的记录
        /// </summary>
        /// <returns></returns>
        List<Work>? GetWorks();
    }
}
