wuchimedes | e5722e3 | 2025-04-13 17:38:50 +0800 | [diff] [blame] | 1 | package com.example.g8backend.service; |
| 2 | |
夜雨声烦 | 368e356 | 2025-04-24 01:49:46 +0800 | [diff] [blame] | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
夜雨声烦 | ef46ac5 | 2025-04-24 20:56:47 +0800 | [diff] [blame^] | 4 | import com.example.g8backend.dto.PostHistoryDTO; |
wuchimedes | e5722e3 | 2025-04-13 17:38:50 +0800 | [diff] [blame] | 5 | import com.example.g8backend.entity.Post; |
| 6 | import com.baomidou.mybatisplus.extension.service.IService; |
夜雨声烦 | 368e356 | 2025-04-24 01:49:46 +0800 | [diff] [blame] | 7 | import org.springframework.scheduling.annotation.Scheduled; |
夜雨声烦 | f4b8b6f | 2025-04-24 00:58:36 +0800 | [diff] [blame] | 8 | import org.springframework.transaction.annotation.Transactional; |
wuchimedes | 5a842b2 | 2025-04-21 22:01:39 +0800 | [diff] [blame] | 9 | |
wuchimedes | e5722e3 | 2025-04-13 17:38:50 +0800 | [diff] [blame] | 10 | import java.util.List; |
| 11 | |
| 12 | public interface IPostService extends IService<Post> { |
| 13 | List<Post> getPostsByUserId(Long userId); |
wuchimedes | 5a842b2 | 2025-04-21 22:01:39 +0800 | [diff] [blame] | 14 | void createPost(Post post); |
| 15 | void createPost(Post post, Long[] tagIds); |
22301071 | 1f457dc | 2025-04-15 17:35:55 +0800 | [diff] [blame] | 16 | 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); |
夜雨声烦 | 4527a72 | 2025-04-23 17:04:25 +0800 | [diff] [blame] | 21 | |
| 22 | List<Post> searchPosts(String keyword, List<Long> tagIds, String author); // 更新为支持多个标签 |
夜雨声烦 | f4b8b6f | 2025-04-24 00:58:36 +0800 | [diff] [blame] | 23 | |
| 24 | @Transactional |
| 25 | void recordViewHistory(Long userId, Long postId); |
夜雨声烦 | 368e356 | 2025-04-24 01:49:46 +0800 | [diff] [blame] | 26 | |
| 27 | @Scheduled(cron = "0 */10 * * * *") // 每10分钟执行一次 |
| 28 | @Transactional |
| 29 | void calculateHotScores(); |
| 30 | |
| 31 | Page<Post> getRecommendedPosts(int page, int size, Long userId); |
夜雨声烦 | f77d813 | 2025-04-24 19:31:18 +0800 | [diff] [blame] | 32 | |
| 33 | Page<Post> getRecommendedByTags(int page, int size, Long userId); |
夜雨声烦 | ef46ac5 | 2025-04-24 20:56:47 +0800 | [diff] [blame^] | 34 | |
| 35 | List<PostHistoryDTO> getViewHistoryWithTitles(Long userId); |
wuchimedes | e5722e3 | 2025-04-13 17:38:50 +0800 | [diff] [blame] | 36 | } |