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

66 lines
2.7 KiB
C#
Raw Permalink 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 ILikeService
{
/// <summary>
/// 查询是否已点赞优先Redis再查数据库
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="targetType">目标类型1-帖子2-评论</param>
/// <param name="targetId">目标ID</param>
/// <returns>是否已点赞</returns>
Task<bool> IsLikedAsync(long userId, int targetType, long targetId);
/// <summary>
/// 获取点赞数优先Redis再查数据库
/// </summary>
/// <param name="targetType">目标类型1-帖子2-评论</param>
/// <param name="targetId">目标ID</param>
/// <returns>点赞数</returns>
Task<int> GetLikeCountAsync(int targetType, long targetId);
/// <summary>
/// 批量查询点赞状态
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="targetType">目标类型1-帖子2-评论</param>
/// <param name="targetIds">目标ID列表</param>
/// <returns>目标ID到是否点赞的映射</returns>
Task<Dictionary<long, bool>> BatchIsLikedAsync(long userId, int targetType, List<long> targetIds);
/// <summary>
/// 批量查询点赞数
/// </summary>
/// <param name="targetType">目标类型1-帖子2-评论</param>
/// <param name="targetIds">目标ID列表</param>
/// <returns>目标ID到点赞数的映射</returns>
Task<Dictionary<long, int>> BatchGetLikeCountAsync(int targetType, List<long> targetIds);
/// <summary>
/// 执行点赞操作Redis+队列)
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="targetType">目标类型1-帖子2-评论</param>
/// <param name="targetId">目标ID</param>
/// <param name="receiverId">接收者ID用于消息通知</param>
/// <returns>是否操作成功</returns>
Task<bool> LikeAsync(long userId, int targetType, long targetId, long receiverId);
/// <summary>
/// 执行取消点赞操作Redis+队列)
/// </summary>
/// <param name="userId">用户ID</param>
/// <param name="targetType">目标类型1-帖子2-评论</param>
/// <param name="targetId">目标ID</param>
/// <returns>是否操作成功</returns>
Task<bool> UnlikeAsync(long userId, int targetType, long targetId);
}
}