blob: cd82ef41c94849dea568aaa3561cf6cdfcfe7f00 [file] [log] [blame]
wuchimedese5722e32025-04-13 17:38:50 +08001package com.example.g8backend.service;
2
夜雨声烦368e3562025-04-24 01:49:46 +08003import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
夜雨声烦ef46ac52025-04-24 20:56:47 +08004import com.example.g8backend.dto.PostHistoryDTO;
wuchimedese5722e32025-04-13 17:38:50 +08005import com.example.g8backend.entity.Post;
6import com.baomidou.mybatisplus.extension.service.IService;
夜雨声烦368e3562025-04-24 01:49:46 +08007import org.springframework.scheduling.annotation.Scheduled;
夜雨声烦f4b8b6f2025-04-24 00:58:36 +08008import org.springframework.transaction.annotation.Transactional;
wuchimedes5a842b22025-04-21 22:01:39 +08009
wuchimedese5722e32025-04-13 17:38:50 +080010import java.util.List;
11
12public interface IPostService extends IService<Post> {
13 List<Post> getPostsByUserId(Long userId);
wuchimedes5a842b22025-04-21 22:01:39 +080014 void createPost(Post post);
15 void createPost(Post post, Long[] tagIds);
223010711f457dc2025-04-15 17:35:55 +080016 Post updatePost(Post post);
17 List<Post> getPostsByType(String postType);
18 Long getPostLikeCount(Long postId);
19 void likePost(Long userId, Long postId);
20 void unlikePost(Long userId, Long postId);
夜雨声烦4527a722025-04-23 17:04:25 +080021
22 List<Post> searchPosts(String keyword, List<Long> tagIds, String author); // 更新为支持多个标签
夜雨声烦f4b8b6f2025-04-24 00:58:36 +080023
24 @Transactional
25 void recordViewHistory(Long userId, Long postId);
夜雨声烦368e3562025-04-24 01:49:46 +080026
27 @Scheduled(cron = "0 */10 * * * *") // 每10分钟执行一次
28 @Transactional
29 void calculateHotScores();
30
31 Page<Post> getRecommendedPosts(int page, int size, Long userId);
夜雨声烦f77d8132025-04-24 19:31:18 +080032
33 Page<Post> getRecommendedByTags(int page, int size, Long userId);
夜雨声烦ef46ac52025-04-24 20:56:47 +080034
35 List<PostHistoryDTO> getViewHistoryWithTitles(Long userId);
wuchimedese5722e32025-04-13 17:38:50 +080036}