feat: add user leveling and experience system

This commit is contained in:
Tim
2025-07-28 12:34:45 +08:00
parent a5900aa60d
commit 1c2751422d
18 changed files with 167 additions and 10 deletions

View File

@@ -19,4 +19,8 @@ public interface CommentRepository extends JpaRepository<Comment, Long> {
@org.springframework.data.jpa.repository.Query("SELECT MAX(c.createdAt) FROM Comment c WHERE c.post = :post")
java.time.LocalDateTime findLastCommentTime(@org.springframework.data.repository.query.Param("post") Post post);
@org.springframework.data.jpa.repository.Query("SELECT COUNT(c) FROM Comment c WHERE c.author.username = :username AND c.createdAt >= :start")
long countByAuthorAfter(@org.springframework.data.repository.query.Param("username") String username,
@org.springframework.data.repository.query.Param("start") java.time.LocalDateTime start);
}

View File

@@ -87,6 +87,9 @@ public interface PostRepository extends JpaRepository<Post, Long> {
@Query("SELECT SUM(p.views) FROM Post p WHERE p.author.username = :username AND p.status = com.openisle.model.PostStatus.PUBLISHED")
Long sumViews(@Param("username") String username);
@Query("SELECT COUNT(p) FROM Post p WHERE p.author.username = :username AND p.createdAt >= :start")
long countByAuthorAfter(@Param("username") String username, @Param("start") java.time.LocalDateTime start);
long countByCategory_Id(Long categoryId);
long countDistinctByTags_Id(Long tagId);

View File

@@ -27,6 +27,9 @@ public interface ReactionRepository extends JpaRepository<Reaction, Long> {
@Query("SELECT COUNT(r) FROM Reaction r WHERE r.user.username = :username AND r.type = com.openisle.model.ReactionType.LIKE")
long countLikesSent(@Param("username") String username);
@Query("SELECT COUNT(r) FROM Reaction r WHERE r.user.username = :username AND r.createdAt >= :start")
long countByUserAfter(@Param("username") String username, @Param("start") java.time.LocalDateTime start);
@Query("SELECT COUNT(r) FROM Reaction r WHERE r.type = com.openisle.model.ReactionType.LIKE AND ((r.post IS NOT NULL AND r.post.author.username = :username) OR (r.comment IS NOT NULL AND r.comment.author.username = :username))")
long countLikesReceived(@Param("username") String username);
}