live-forum/server/webapi/LiveForum/LiveForum.IService/Posts/IViewService.cs
2026-03-24 11:27:37 +08:00

43 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using System.Threading.Tasks;
namespace LiveForum.IService.Posts
{
/// <summary>
/// 浏览服务接口
/// </summary>
public interface IViewService
{
/// <summary>
/// 检查是否可以增加浏览次数10分钟限制检查优先Redis
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="postId">帖子ID</param>
/// <returns>是否可以增加浏览次数</returns>
Task<bool> CanAddViewAsync(long userId, long postId);
/// <summary>
/// 获取浏览次数优先Redis再查数据库
/// </summary>
/// <param name="postId">帖子ID</param>
/// <returns>浏览次数</returns>
Task<int> GetViewCountAsync(long postId);
/// <summary>
/// 批量查询浏览次数
/// </summary>
/// <param name="postIds">帖子ID列表</param>
/// <returns>帖子ID到浏览次数的映射</returns>
Task<Dictionary<long, int>> BatchGetViewCountAsync(List<long> postIds);
/// <summary>
/// 执行增加浏览操作Redis+队列)
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="postId">帖子ID</param>
/// <returns>是否操作成功</returns>
Task<bool> AddViewAsync(long userId, long postId);
}
}