blob: fabf2540644d29868d3c866845d1c35cf2b7579d [file] [log] [blame]
ym923f1d9f452025-05-27 18:29:44 +08001package com.pt5.pthouduan.service;
2
3import com.pt5.pthouduan.entity.Post;
4
5import java.util.List;
6
7/**
8 * <p>
9 * 帖子服务接口
10 * </p>
11 *
12 * 功能:
13 * - 增、删、改、查(按标签或标题)
14 * - 点赞、取消点赞
15 * - 设置置顶状态
16 * - 可设置可见范围
17 * - 上传图片(通常可选放在 Controller)
18 * - 查找用户所有帖子
19 * - 查找置顶帖子
20 * - 获取所有帖子(置顶优先,时间倒序)
21 *
22 * @author 杨蔓
23 * @since 2025-04-14
24 */
25public interface PostService {
26
27 Post createPost(Post post); // 创建帖子
28
29 boolean deletePost(Integer postid); // 删除帖子
30
31 boolean updatePost(Post post); // 更新帖子
32
33 List<Post> searchPostsByKeyword(String keyword); // 查找帖子(标题或标签)
34
35 boolean incrementLikes(Integer postid); // 点赞(likes + 1)
36
37 boolean decrementLikes(Integer postid); // 取消点赞(likes - 1,最小为0)
38
39 boolean setPinnedStatus(Integer postid, boolean pinned); // 设置是否置顶
40
41 List<Post> findByUserid(Long userid); // 根据用户 ID 获取帖子
42
43 List<Post> findPinnedPosts(); // 查找所有置顶帖子
44
45 List<Post> getAllPostsSorted(); // ✅ 获取所有帖子(置顶优先,按时间排序)
46}