mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-11 00:06:12 +00:00
fix: 后端代码格式化
This commit is contained in:
@@ -4,5 +4,5 @@ import com.openisle.model.Activity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface ActivityRepository extends JpaRepository<Activity, Long> {
|
||||
Activity findByType(com.openisle.model.ActivityType type);
|
||||
Activity findByType(com.openisle.model.ActivityType type);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.AiFormatUsage;
|
||||
import com.openisle.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface AiFormatUsageRepository extends JpaRepository<AiFormatUsage, Long> {
|
||||
Optional<AiFormatUsage> findByUserAndUseDate(User user, LocalDate useDate);
|
||||
Optional<AiFormatUsage> findByUserAndUseDate(User user, LocalDate useDate);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Category;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface CategoryRepository extends JpaRepository<Category, Long> {
|
||||
List<Category> findByNameContainingIgnoreCase(String keyword);
|
||||
List<Category> findByNameContainingIgnoreCase(String keyword);
|
||||
|
||||
Optional<Category> findByName(String name);
|
||||
Optional<Category> findByName(String name);
|
||||
}
|
||||
|
||||
@@ -2,38 +2,59 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Comment;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.User;
|
||||
import java.util.List;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import com.openisle.model.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CommentRepository extends JpaRepository<Comment, Long> {
|
||||
List<Comment> findByPostAndParentIsNullOrderByCreatedAtAsc(Post post);
|
||||
List<Comment> findByParentOrderByCreatedAtAsc(Comment parent);
|
||||
List<Comment> findByAuthorOrderByCreatedAtDesc(User author, Pageable pageable);
|
||||
List<Comment> findByContentContainingIgnoreCase(String keyword);
|
||||
List<Comment> findByPostAndParentIsNullOrderByCreatedAtAsc(Post post);
|
||||
List<Comment> findByParentOrderByCreatedAtAsc(Comment parent);
|
||||
List<Comment> findByAuthorOrderByCreatedAtDesc(User author, Pageable pageable);
|
||||
List<Comment> findByContentContainingIgnoreCase(String keyword);
|
||||
|
||||
@org.springframework.data.jpa.repository.Query("SELECT DISTINCT c.author FROM Comment c WHERE c.post = :post")
|
||||
java.util.List<User> findDistinctAuthorsByPost(@org.springframework.data.repository.query.Param("post") Post post);
|
||||
@org.springframework.data.jpa.repository.Query(
|
||||
"SELECT DISTINCT c.author FROM Comment c WHERE c.post = :post"
|
||||
)
|
||||
java.util.List<User> findDistinctAuthorsByPost(
|
||||
@org.springframework.data.repository.query.Param("post") Post post
|
||||
);
|
||||
|
||||
@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 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);
|
||||
@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
|
||||
);
|
||||
|
||||
@org.springframework.data.jpa.repository.Query("SELECT MAX(c.createdAt) FROM Comment c WHERE c.author.id = :userId")
|
||||
java.time.LocalDateTime findLastCommentTimeOfUserByUserId(@org.springframework.data.repository.query.Param("userId") Long userId);
|
||||
@org.springframework.data.jpa.repository.Query(
|
||||
"SELECT MAX(c.createdAt) FROM Comment c WHERE c.author.id = :userId"
|
||||
)
|
||||
java.time.LocalDateTime findLastCommentTimeOfUserByUserId(
|
||||
@org.springframework.data.repository.query.Param("userId") Long userId
|
||||
);
|
||||
|
||||
@org.springframework.data.jpa.repository.Query("SELECT COUNT(c) FROM Comment c WHERE c.post.id = :postId")
|
||||
long countByPostId(@org.springframework.data.repository.query.Param("postId") Long postId);
|
||||
@org.springframework.data.jpa.repository.Query(
|
||||
"SELECT COUNT(c) FROM Comment c WHERE c.post.id = :postId"
|
||||
)
|
||||
long countByPostId(@org.springframework.data.repository.query.Param("postId") Long postId);
|
||||
|
||||
long countByAuthor_Id(Long userId);
|
||||
long countByAuthor_Id(Long userId);
|
||||
|
||||
@org.springframework.data.jpa.repository.Query("SELECT FUNCTION('date', c.createdAt) AS d, COUNT(c) AS c FROM Comment c " +
|
||||
"WHERE c.createdAt >= :start AND c.createdAt < :end GROUP BY d ORDER BY d")
|
||||
java.util.List<Object[]> countDailyRange(@org.springframework.data.repository.query.Param("start") java.time.LocalDateTime start,
|
||||
@org.springframework.data.repository.query.Param("end") java.time.LocalDateTime end);
|
||||
@org.springframework.data.jpa.repository.Query(
|
||||
"SELECT FUNCTION('date', c.createdAt) AS d, COUNT(c) AS c FROM Comment c " +
|
||||
"WHERE c.createdAt >= :start AND c.createdAt < :end GROUP BY d ORDER BY d"
|
||||
)
|
||||
java.util.List<Object[]> countDailyRange(
|
||||
@org.springframework.data.repository.query.Param("start") java.time.LocalDateTime start,
|
||||
@org.springframework.data.repository.query.Param("end") java.time.LocalDateTime end
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ package com.openisle.repository;
|
||||
import com.openisle.model.Comment;
|
||||
import com.openisle.model.CommentSubscription;
|
||||
import com.openisle.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface CommentSubscriptionRepository extends JpaRepository<CommentSubscription, Long> {
|
||||
List<CommentSubscription> findByComment(Comment comment);
|
||||
List<CommentSubscription> findByUser(User user);
|
||||
Optional<CommentSubscription> findByUserAndComment(User user, Comment comment);
|
||||
List<CommentSubscription> findByComment(Comment comment);
|
||||
List<CommentSubscription> findByUser(User user);
|
||||
Optional<CommentSubscription> findByUserAndComment(User user, Comment comment);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.ContributorConfig;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ContributorConfigRepository extends JpaRepository<ContributorConfig, Long> {
|
||||
Optional<ContributorConfig> findByUserIname(String userIname);
|
||||
Optional<ContributorConfig> findByUserIname(String userIname);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Draft;
|
||||
import com.openisle.model.User;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface DraftRepository extends JpaRepository<Draft, Long> {
|
||||
Optional<Draft> findByAuthor(User author);
|
||||
void deleteByAuthor(User author);
|
||||
Optional<Draft> findByAuthor(User author);
|
||||
void deleteByAuthor(User author);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.ExperienceLog;
|
||||
import com.openisle.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface ExperienceLogRepository extends JpaRepository<ExperienceLog, Long> {
|
||||
Optional<ExperienceLog> findByUserAndLogDate(User user, LocalDate logDate);
|
||||
Optional<ExperienceLog> findByUserAndLogDate(User user, LocalDate logDate);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Image;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/**
|
||||
* Repository for images stored on COS.
|
||||
*/
|
||||
public interface ImageRepository extends JpaRepository<Image, Long> {
|
||||
Optional<Image> findByUrl(String url);
|
||||
Optional<Image> findByUrl(String url);
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.InviteToken;
|
||||
import com.openisle.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface InviteTokenRepository extends JpaRepository<InviteToken, String> {
|
||||
Optional<InviteToken> findByInviterAndCreatedDate(User inviter, LocalDate createdDate);
|
||||
Optional<InviteToken> findByInviterAndCreatedDate(User inviter, LocalDate createdDate);
|
||||
|
||||
Optional<InviteToken> findByShortToken(String shortToken);
|
||||
Optional<InviteToken> findByShortToken(String shortToken);
|
||||
|
||||
boolean existsByShortToken(String shortToken);
|
||||
boolean existsByShortToken(String shortToken);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.LotteryPost;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface LotteryPostRepository extends JpaRepository<LotteryPost, Long> {
|
||||
List<LotteryPost> findByEndTimeAfterAndWinnersIsEmpty(LocalDateTime now);
|
||||
List<LotteryPost> findByEndTimeAfterAndWinnersIsEmpty(LocalDateTime now);
|
||||
|
||||
List<LotteryPost> findByEndTimeBeforeAndWinnersIsEmpty(LocalDateTime now);
|
||||
List<LotteryPost> findByEndTimeBeforeAndWinnersIsEmpty(LocalDateTime now);
|
||||
}
|
||||
|
||||
@@ -2,36 +2,46 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.MessageConversation;
|
||||
import com.openisle.model.User;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface MessageConversationRepository extends JpaRepository<MessageConversation, Long> {
|
||||
@Query(
|
||||
"SELECT c FROM MessageConversation c LEFT JOIN FETCH c.participants p LEFT JOIN FETCH p.user WHERE c.id = :id"
|
||||
)
|
||||
java.util.Optional<MessageConversation> findByIdWithParticipantsAndUsers(@Param("id") Long id);
|
||||
|
||||
@Query("SELECT c FROM MessageConversation c LEFT JOIN FETCH c.participants p LEFT JOIN FETCH p.user WHERE c.id = :id")
|
||||
java.util.Optional<MessageConversation> findByIdWithParticipantsAndUsers(@Param("id") Long id);
|
||||
@Query("SELECT c FROM MessageConversation c " +
|
||||
"WHERE c.channel = false AND size(c.participants) = 2 " +
|
||||
"AND EXISTS (SELECT 1 FROM c.participants p1 WHERE p1.user = :user1) " +
|
||||
"AND EXISTS (SELECT 1 FROM c.participants p2 WHERE p2.user = :user2) " +
|
||||
"ORDER BY c.createdAt DESC")
|
||||
List<MessageConversation> findConversationsByUsers(@Param("user1") User user1, @Param("user2") User user2);
|
||||
|
||||
@Query("SELECT DISTINCT c FROM MessageConversation c " +
|
||||
"JOIN c.participants p " +
|
||||
"LEFT JOIN FETCH c.lastMessage lm " +
|
||||
"LEFT JOIN FETCH lm.sender " +
|
||||
"LEFT JOIN FETCH c.participants cp " +
|
||||
"LEFT JOIN FETCH cp.user " +
|
||||
"WHERE p.user.id = :userId " +
|
||||
"ORDER BY COALESCE(lm.createdAt, c.createdAt) DESC")
|
||||
List<MessageConversation> findConversationsByUserIdOrderByLastMessageDesc(@Param("userId") Long userId);
|
||||
@Query(
|
||||
"SELECT c FROM MessageConversation c " +
|
||||
"WHERE c.channel = false AND size(c.participants) = 2 " +
|
||||
"AND EXISTS (SELECT 1 FROM c.participants p1 WHERE p1.user = :user1) " +
|
||||
"AND EXISTS (SELECT 1 FROM c.participants p2 WHERE p2.user = :user2) " +
|
||||
"ORDER BY c.createdAt DESC"
|
||||
)
|
||||
List<MessageConversation> findConversationsByUsers(
|
||||
@Param("user1") User user1,
|
||||
@Param("user2") User user2
|
||||
);
|
||||
|
||||
List<MessageConversation> findByChannelTrue();
|
||||
@Query(
|
||||
"SELECT DISTINCT c FROM MessageConversation c " +
|
||||
"JOIN c.participants p " +
|
||||
"LEFT JOIN FETCH c.lastMessage lm " +
|
||||
"LEFT JOIN FETCH lm.sender " +
|
||||
"LEFT JOIN FETCH c.participants cp " +
|
||||
"LEFT JOIN FETCH cp.user " +
|
||||
"WHERE p.user.id = :userId " +
|
||||
"ORDER BY COALESCE(lm.createdAt, c.createdAt) DESC"
|
||||
)
|
||||
List<MessageConversation> findConversationsByUserIdOrderByLastMessageDesc(
|
||||
@Param("userId") Long userId
|
||||
);
|
||||
|
||||
long countByChannelTrue();
|
||||
List<MessageConversation> findByChannelTrue();
|
||||
|
||||
long countByChannelTrue();
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.MessageParticipant;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface MessageParticipantRepository extends JpaRepository<MessageParticipant, Long> {
|
||||
Optional<MessageParticipant> findByConversationIdAndUserId(Long conversationId, Long userId);
|
||||
List<MessageParticipant> findByUserId(Long userId);
|
||||
}
|
||||
Optional<MessageParticipant> findByConversationIdAndUserId(Long conversationId, Long userId);
|
||||
List<MessageParticipant> findByUserId(Long userId);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,27 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Message;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import java.util.List;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface MessageRepository extends JpaRepository<Message, Long> {
|
||||
List<Message> findByConversationIdOrderByCreatedAtAsc(Long conversationId);
|
||||
List<Message> findByConversationIdOrderByCreatedAtAsc(Long conversationId);
|
||||
|
||||
Page<Message> findByConversationId(Long conversationId, Pageable pageable);
|
||||
Page<Message> findByConversationId(Long conversationId, Pageable pageable);
|
||||
|
||||
long countByConversationIdAndCreatedAtAfter(Long conversationId, java.time.LocalDateTime createdAt);
|
||||
|
||||
// 只计算不是指定用户发送的消息(即别人发给当前用户的消息)
|
||||
long countByConversationIdAndCreatedAtAfterAndSenderIdNot(Long conversationId, java.time.LocalDateTime createdAt, Long senderId);
|
||||
}
|
||||
long countByConversationIdAndCreatedAtAfter(
|
||||
Long conversationId,
|
||||
java.time.LocalDateTime createdAt
|
||||
);
|
||||
|
||||
// 只计算不是指定用户发送的消息(即别人发给当前用户的消息)
|
||||
long countByConversationIdAndCreatedAtAfterAndSenderIdNot(
|
||||
Long conversationId,
|
||||
java.time.LocalDateTime createdAt,
|
||||
Long senderId
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,37 +1,63 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Notification;
|
||||
import com.openisle.model.User;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.Comment;
|
||||
import com.openisle.model.Notification;
|
||||
import com.openisle.model.NotificationType;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.ReactionType;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import com.openisle.model.User;
|
||||
import java.util.List;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/** Repository for Notification entities. */
|
||||
public interface NotificationRepository extends JpaRepository<Notification, Long> {
|
||||
List<Notification> findByUserOrderByCreatedAtDesc(User user);
|
||||
List<Notification> findByUserAndReadOrderByCreatedAtDesc(User user, boolean read);
|
||||
Page<Notification> findByUserOrderByCreatedAtDesc(User user, Pageable pageable);
|
||||
Page<Notification> findByUserAndReadOrderByCreatedAtDesc(User user, boolean read, Pageable pageable);
|
||||
Page<Notification> findByUserAndTypeNotInOrderByCreatedAtDesc(User user, java.util.Collection<NotificationType> types, Pageable pageable);
|
||||
Page<Notification> findByUserAndReadAndTypeNotInOrderByCreatedAtDesc(User user, boolean read, java.util.Collection<NotificationType> types, Pageable pageable);
|
||||
long countByUserAndRead(User user, boolean read);
|
||||
long countByUserAndReadAndTypeNotIn(User user, boolean read, java.util.Collection<NotificationType> types);
|
||||
List<Notification> findByPost(Post post);
|
||||
List<Notification> findByComment(Comment comment);
|
||||
List<Notification> findByUserOrderByCreatedAtDesc(User user);
|
||||
List<Notification> findByUserAndReadOrderByCreatedAtDesc(User user, boolean read);
|
||||
Page<Notification> findByUserOrderByCreatedAtDesc(User user, Pageable pageable);
|
||||
Page<Notification> findByUserAndReadOrderByCreatedAtDesc(
|
||||
User user,
|
||||
boolean read,
|
||||
Pageable pageable
|
||||
);
|
||||
Page<Notification> findByUserAndTypeNotInOrderByCreatedAtDesc(
|
||||
User user,
|
||||
java.util.Collection<NotificationType> types,
|
||||
Pageable pageable
|
||||
);
|
||||
Page<Notification> findByUserAndReadAndTypeNotInOrderByCreatedAtDesc(
|
||||
User user,
|
||||
boolean read,
|
||||
java.util.Collection<NotificationType> types,
|
||||
Pageable pageable
|
||||
);
|
||||
long countByUserAndRead(User user, boolean read);
|
||||
long countByUserAndReadAndTypeNotIn(
|
||||
User user,
|
||||
boolean read,
|
||||
java.util.Collection<NotificationType> types
|
||||
);
|
||||
List<Notification> findByPost(Post post);
|
||||
List<Notification> findByComment(Comment comment);
|
||||
|
||||
void deleteByTypeAndFromUser(NotificationType type, User fromUser);
|
||||
void deleteByTypeAndFromUser(NotificationType type, User fromUser);
|
||||
|
||||
List<Notification> findByTypeAndFromUser(NotificationType type, User fromUser);
|
||||
List<Notification> findByTypeAndFromUser(NotificationType type, User fromUser);
|
||||
|
||||
void deleteByTypeAndFromUserAndPost(NotificationType type, User fromUser, Post post);
|
||||
void deleteByTypeAndFromUserAndPost(NotificationType type, User fromUser, Post post);
|
||||
|
||||
void deleteByTypeAndFromUserAndPostAndReactionType(NotificationType type, User fromUser, Post post, ReactionType reactionType);
|
||||
void deleteByTypeAndFromUserAndPostAndReactionType(
|
||||
NotificationType type,
|
||||
User fromUser,
|
||||
Post post,
|
||||
ReactionType reactionType
|
||||
);
|
||||
|
||||
void deleteByTypeAndFromUserAndCommentAndReactionType(NotificationType type, User fromUser, Comment comment, ReactionType reactionType);
|
||||
void deleteByTypeAndFromUserAndCommentAndReactionType(
|
||||
NotificationType type,
|
||||
User fromUser,
|
||||
Comment comment,
|
||||
ReactionType reactionType
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,4 @@ import com.openisle.model.PointGood;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
/** Repository for point mall goods. */
|
||||
public interface PointGoodRepository extends JpaRepository<PointGood, Long> {
|
||||
}
|
||||
public interface PointGoodRepository extends JpaRepository<PointGood, Long> {}
|
||||
|
||||
@@ -4,19 +4,21 @@ import com.openisle.model.Comment;
|
||||
import com.openisle.model.PointHistory;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PointHistoryRepository extends JpaRepository<PointHistory, Long> {
|
||||
List<PointHistory> findByUserOrderByIdDesc(User user);
|
||||
List<PointHistory> findByUserOrderByIdAsc(User user);
|
||||
long countByUser(User user);
|
||||
List<PointHistory> findByUserOrderByIdDesc(User user);
|
||||
List<PointHistory> findByUserOrderByIdAsc(User user);
|
||||
long countByUser(User user);
|
||||
|
||||
List<PointHistory> findByUserAndCreatedAtAfterOrderByCreatedAtDesc(User user, LocalDateTime createdAt);
|
||||
List<PointHistory> findByUserAndCreatedAtAfterOrderByCreatedAtDesc(
|
||||
User user,
|
||||
LocalDateTime createdAt
|
||||
);
|
||||
|
||||
List<PointHistory> findByComment(Comment comment);
|
||||
List<PointHistory> findByComment(Comment comment);
|
||||
|
||||
List<PointHistory> findByPost(Post post);
|
||||
List<PointHistory> findByPost(Post post);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.PointLog;
|
||||
import com.openisle.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PointLogRepository extends JpaRepository<PointLog, Long> {
|
||||
Optional<PointLog> findByUserAndLogDate(User user, LocalDate logDate);
|
||||
Optional<PointLog> findByUserAndLogDate(User user, LocalDate logDate);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.PollPost;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PollPostRepository extends JpaRepository<PollPost, Long> {
|
||||
List<PollPost> findByEndTimeAfterAndResultAnnouncedFalse(LocalDateTime now);
|
||||
List<PollPost> findByEndTimeAfterAndResultAnnouncedFalse(LocalDateTime now);
|
||||
|
||||
List<PollPost> findByEndTimeBeforeAndResultAnnouncedFalse(LocalDateTime now);
|
||||
List<PollPost> findByEndTimeBeforeAndResultAnnouncedFalse(LocalDateTime now);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.PollVote;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PollVoteRepository extends JpaRepository<PollVote, Long> {
|
||||
List<PollVote> findByPostId(Long postId);
|
||||
List<PollVote> findByPostId(Long postId);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.PostChangeLog;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PostChangeLogRepository extends JpaRepository<PostChangeLog, Long> {
|
||||
List<PostChangeLog> findByPostOrderByCreatedAtAsc(Post post);
|
||||
List<PostChangeLog> findByPostOrderByCreatedAtAsc(Post post);
|
||||
|
||||
void deleteByPost(Post post);
|
||||
void deleteByPost(Post post);
|
||||
}
|
||||
|
||||
@@ -3,12 +3,11 @@ package com.openisle.repository;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.PostRead;
|
||||
import com.openisle.model.User;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface PostReadRepository extends JpaRepository<PostRead, Long> {
|
||||
Optional<PostRead> findByUserAndPost(User user, Post post);
|
||||
long countByUser(User user);
|
||||
void deleteByPost(Post post);
|
||||
Optional<PostRead> findByUserAndPost(User user, Post post);
|
||||
long countByUser(User user);
|
||||
void deleteByPost(Post post);
|
||||
}
|
||||
|
||||
@@ -1,113 +1,277 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Category;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.PostStatus;
|
||||
import com.openisle.model.User;
|
||||
import com.openisle.model.Category;
|
||||
import com.openisle.model.Tag;
|
||||
import com.openisle.model.User;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface PostRepository extends JpaRepository<Post, Long> {
|
||||
List<Post> findByStatus(PostStatus status);
|
||||
List<Post> findByStatus(PostStatus status, Pageable pageable);
|
||||
List<Post> findByStatusOrderByCreatedAtDesc(PostStatus status);
|
||||
List<Post> findByStatusOrderByCreatedAtDesc(PostStatus status, Pageable pageable);
|
||||
List<Post> findByStatusOrderByViewsDesc(PostStatus status);
|
||||
List<Post> findByStatusOrderByViewsDesc(PostStatus status, Pageable pageable);
|
||||
List<Post> findByAuthorAndStatusOrderByCreatedAtDesc(User author, PostStatus status, Pageable pageable);
|
||||
List<Post> findByCategoryInAndStatus(List<Category> categories, PostStatus status);
|
||||
List<Post> findByCategoryInAndStatus(List<Category> categories, PostStatus status, Pageable pageable);
|
||||
List<Post> findByCategoryInAndStatusOrderByCreatedAtDesc(List<Category> categories, PostStatus status);
|
||||
List<Post> findByCategoryInAndStatusOrderByCreatedAtDesc(List<Category> categories, PostStatus status, Pageable pageable);
|
||||
List<Post> findDistinctByTagsInAndStatus(List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByTagsInAndStatus(List<Tag> tags, PostStatus status, Pageable pageable);
|
||||
List<Post> findDistinctByTagsInAndStatusOrderByCreatedAtDesc(List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByTagsInAndStatusOrderByCreatedAtDesc(List<Tag> tags, PostStatus status, Pageable pageable);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatus(List<Category> categories, List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatus(List<Category> categories, List<Tag> tags, PostStatus status, Pageable pageable);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatusOrderByCreatedAtDesc(List<Category> categories, List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatusOrderByCreatedAtDesc(List<Category> categories, List<Tag> tags, PostStatus status, Pageable pageable);
|
||||
List<Post> findByStatus(PostStatus status);
|
||||
List<Post> findByStatus(PostStatus status, Pageable pageable);
|
||||
List<Post> findByStatusOrderByCreatedAtDesc(PostStatus status);
|
||||
List<Post> findByStatusOrderByCreatedAtDesc(PostStatus status, Pageable pageable);
|
||||
List<Post> findByStatusOrderByViewsDesc(PostStatus status);
|
||||
List<Post> findByStatusOrderByViewsDesc(PostStatus status, Pageable pageable);
|
||||
List<Post> findByAuthorAndStatusOrderByCreatedAtDesc(
|
||||
User author,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
List<Post> findByCategoryInAndStatus(List<Category> categories, PostStatus status);
|
||||
List<Post> findByCategoryInAndStatus(
|
||||
List<Category> categories,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
List<Post> findByCategoryInAndStatusOrderByCreatedAtDesc(
|
||||
List<Category> categories,
|
||||
PostStatus status
|
||||
);
|
||||
List<Post> findByCategoryInAndStatusOrderByCreatedAtDesc(
|
||||
List<Category> categories,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
List<Post> findDistinctByTagsInAndStatus(List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByTagsInAndStatus(List<Tag> tags, PostStatus status, Pageable pageable);
|
||||
List<Post> findDistinctByTagsInAndStatusOrderByCreatedAtDesc(List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByTagsInAndStatusOrderByCreatedAtDesc(
|
||||
List<Tag> tags,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatus(
|
||||
List<Category> categories,
|
||||
List<Tag> tags,
|
||||
PostStatus status
|
||||
);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatus(
|
||||
List<Category> categories,
|
||||
List<Tag> tags,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatusOrderByCreatedAtDesc(
|
||||
List<Category> categories,
|
||||
List<Tag> tags,
|
||||
PostStatus status
|
||||
);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatusOrderByCreatedAtDesc(
|
||||
List<Category> categories,
|
||||
List<Tag> tags,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
// Queries requiring all provided tags to be present
|
||||
@Query("SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount")
|
||||
List<Post> findByAllTags(@Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount);
|
||||
// Queries requiring all provided tags to be present
|
||||
@Query(
|
||||
"SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount"
|
||||
)
|
||||
List<Post> findByAllTags(
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount
|
||||
);
|
||||
|
||||
@Query(value = "SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount")
|
||||
List<Post> findByAllTags(@Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount, Pageable pageable);
|
||||
@Query(
|
||||
value = "SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount"
|
||||
)
|
||||
List<Post> findByAllTags(
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
@Query("SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.createdAt DESC")
|
||||
List<Post> findByAllTagsOrderByCreatedAtDesc(@Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount);
|
||||
@Query(
|
||||
"SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.createdAt DESC"
|
||||
)
|
||||
List<Post> findByAllTagsOrderByCreatedAtDesc(
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount
|
||||
);
|
||||
|
||||
@Query(value = "SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.createdAt DESC")
|
||||
List<Post> findByAllTagsOrderByCreatedAtDesc(@Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount, Pageable pageable);
|
||||
@Query(
|
||||
value = "SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.createdAt DESC"
|
||||
)
|
||||
List<Post> findByAllTagsOrderByCreatedAtDesc(
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
@Query("SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.views DESC")
|
||||
List<Post> findByAllTagsOrderByViewsDesc(@Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount);
|
||||
@Query(
|
||||
"SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.views DESC"
|
||||
)
|
||||
List<Post> findByAllTagsOrderByViewsDesc(
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount
|
||||
);
|
||||
|
||||
@Query(value = "SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.views DESC")
|
||||
List<Post> findByAllTagsOrderByViewsDesc(@Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount, Pageable pageable);
|
||||
@Query(
|
||||
value = "SELECT p FROM Post p JOIN p.tags t WHERE t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.views DESC"
|
||||
)
|
||||
List<Post> findByAllTagsOrderByViewsDesc(
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
@Query("SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount")
|
||||
List<Post> findByCategoriesAndAllTags(@Param("categories") List<Category> categories, @Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount);
|
||||
@Query(
|
||||
"SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount"
|
||||
)
|
||||
List<Post> findByCategoriesAndAllTags(
|
||||
@Param("categories") List<Category> categories,
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount
|
||||
);
|
||||
|
||||
@Query(value = "SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount")
|
||||
List<Post> findByCategoriesAndAllTags(@Param("categories") List<Category> categories, @Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount, Pageable pageable);
|
||||
@Query(
|
||||
value = "SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount"
|
||||
)
|
||||
List<Post> findByCategoriesAndAllTags(
|
||||
@Param("categories") List<Category> categories,
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
@Query("SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.views DESC")
|
||||
List<Post> findByCategoriesAndAllTagsOrderByViewsDesc(@Param("categories") List<Category> categories, @Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount);
|
||||
@Query(
|
||||
"SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.views DESC"
|
||||
)
|
||||
List<Post> findByCategoriesAndAllTagsOrderByViewsDesc(
|
||||
@Param("categories") List<Category> categories,
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount
|
||||
);
|
||||
|
||||
@Query(value = "SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.views DESC")
|
||||
List<Post> findByCategoriesAndAllTagsOrderByViewsDesc(@Param("categories") List<Category> categories, @Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount, Pageable pageable);
|
||||
@Query(
|
||||
value = "SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.views DESC"
|
||||
)
|
||||
List<Post> findByCategoriesAndAllTagsOrderByViewsDesc(
|
||||
@Param("categories") List<Category> categories,
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
@Query("SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.createdAt DESC")
|
||||
List<Post> findByCategoriesAndAllTagsOrderByCreatedAtDesc(@Param("categories") List<Category> categories, @Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount);
|
||||
@Query(
|
||||
"SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.createdAt DESC"
|
||||
)
|
||||
List<Post> findByCategoriesAndAllTagsOrderByCreatedAtDesc(
|
||||
@Param("categories") List<Category> categories,
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount
|
||||
);
|
||||
|
||||
@Query(value = "SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.createdAt DESC")
|
||||
List<Post> findByCategoriesAndAllTagsOrderByCreatedAtDesc(@Param("categories") List<Category> categories, @Param("tags") List<Tag> tags, @Param("status") PostStatus status, @Param("tagCount") long tagCount, Pageable pageable);
|
||||
@Query(
|
||||
value = "SELECT p FROM Post p JOIN p.tags t WHERE p.category IN :categories AND t IN :tags AND p.status = :status GROUP BY p.id HAVING COUNT(DISTINCT t.id) = :tagCount ORDER BY p.createdAt DESC"
|
||||
)
|
||||
List<Post> findByCategoriesAndAllTagsOrderByCreatedAtDesc(
|
||||
@Param("categories") List<Category> categories,
|
||||
@Param("tags") List<Tag> tags,
|
||||
@Param("status") PostStatus status,
|
||||
@Param("tagCount") long tagCount,
|
||||
Pageable pageable
|
||||
);
|
||||
|
||||
List<Post> findByCategoryInAndStatusOrderByViewsDesc(List<Category> categories, PostStatus status);
|
||||
List<Post> findByCategoryInAndStatusOrderByViewsDesc(List<Category> categories, PostStatus status, Pageable pageable);
|
||||
List<Post> findDistinctByTagsInAndStatusOrderByViewsDesc(List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByTagsInAndStatusOrderByViewsDesc(List<Tag> tags, PostStatus status, Pageable pageable);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatusOrderByViewsDesc(List<Category> categories, List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatusOrderByViewsDesc(List<Category> categories, List<Tag> tags, PostStatus status, Pageable pageable);
|
||||
List<Post> findByTitleContainingIgnoreCaseOrContentContainingIgnoreCaseAndStatus(String titleKeyword, String contentKeyword, PostStatus status);
|
||||
List<Post> findByContentContainingIgnoreCaseAndStatus(String keyword, PostStatus status);
|
||||
List<Post> findByTitleContainingIgnoreCaseAndStatus(String keyword, PostStatus status);
|
||||
List<Post> findByCategoryInAndStatusOrderByViewsDesc(
|
||||
List<Category> categories,
|
||||
PostStatus status
|
||||
);
|
||||
List<Post> findByCategoryInAndStatusOrderByViewsDesc(
|
||||
List<Category> categories,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
List<Post> findDistinctByTagsInAndStatusOrderByViewsDesc(List<Tag> tags, PostStatus status);
|
||||
List<Post> findDistinctByTagsInAndStatusOrderByViewsDesc(
|
||||
List<Tag> tags,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatusOrderByViewsDesc(
|
||||
List<Category> categories,
|
||||
List<Tag> tags,
|
||||
PostStatus status
|
||||
);
|
||||
List<Post> findDistinctByCategoryInAndTagsInAndStatusOrderByViewsDesc(
|
||||
List<Category> categories,
|
||||
List<Tag> tags,
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
List<Post> findByTitleContainingIgnoreCaseOrContentContainingIgnoreCaseAndStatus(
|
||||
String titleKeyword,
|
||||
String contentKeyword,
|
||||
PostStatus status
|
||||
);
|
||||
List<Post> findByContentContainingIgnoreCaseAndStatus(String keyword, PostStatus status);
|
||||
List<Post> findByTitleContainingIgnoreCaseAndStatus(String keyword, PostStatus status);
|
||||
|
||||
@Query("SELECT MAX(p.createdAt) FROM Post p WHERE p.author.username = :username AND p.status = com.openisle.model.PostStatus.PUBLISHED")
|
||||
LocalDateTime findLastPostTime(@Param("username") String username);
|
||||
@Query(
|
||||
"SELECT MAX(p.createdAt) FROM Post p WHERE p.author.username = :username AND p.status = com.openisle.model.PostStatus.PUBLISHED"
|
||||
)
|
||||
LocalDateTime findLastPostTime(@Param("username") String username);
|
||||
|
||||
@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 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);
|
||||
@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 countByCategory_Id(Long categoryId);
|
||||
|
||||
@Query("SELECT c.id, COUNT(p) FROM Post p JOIN p.category c WHERE c.id IN :categoryIds GROUP BY c.id")
|
||||
List<Object[]> countPostsByCategoryIds(@Param("categoryIds") List<Long> categoryIds);
|
||||
@Query(
|
||||
"SELECT c.id, COUNT(p) FROM Post p JOIN p.category c WHERE c.id IN :categoryIds GROUP BY c.id"
|
||||
)
|
||||
List<Object[]> countPostsByCategoryIds(@Param("categoryIds") List<Long> categoryIds);
|
||||
|
||||
long countDistinctByTags_Id(Long tagId);
|
||||
long countDistinctByTags_Id(Long tagId);
|
||||
|
||||
long countByAuthor_IdAndRssExcludedFalse(Long userId);
|
||||
long countByAuthor_IdAndRssExcludedFalse(Long userId);
|
||||
|
||||
@Query("SELECT t.id, COUNT(DISTINCT p) FROM Post p JOIN p.tags t WHERE t.id IN :tagIds GROUP BY t.id")
|
||||
List<Object[]> countPostsByTagIds(@Param("tagIds") List<Long> tagIds);
|
||||
@Query(
|
||||
"SELECT t.id, COUNT(DISTINCT p) FROM Post p JOIN p.tags t WHERE t.id IN :tagIds GROUP BY t.id"
|
||||
)
|
||||
List<Object[]> countPostsByTagIds(@Param("tagIds") List<Long> tagIds);
|
||||
|
||||
long countByAuthor_Id(Long userId);
|
||||
long countByAuthor_Id(Long userId);
|
||||
|
||||
@Query("SELECT FUNCTION('date', p.createdAt) AS d, COUNT(p) AS c FROM Post p " +
|
||||
"WHERE p.createdAt >= :start AND p.createdAt < :end GROUP BY d ORDER BY d")
|
||||
java.util.List<Object[]> countDailyRange(@Param("start") LocalDateTime start,
|
||||
@Param("end") LocalDateTime end);
|
||||
@Query(
|
||||
"SELECT FUNCTION('date', p.createdAt) AS d, COUNT(p) AS c FROM Post p " +
|
||||
"WHERE p.createdAt >= :start AND p.createdAt < :end GROUP BY d ORDER BY d"
|
||||
)
|
||||
java.util.List<Object[]> countDailyRange(
|
||||
@Param("start") LocalDateTime start,
|
||||
@Param("end") LocalDateTime end
|
||||
);
|
||||
|
||||
List<Post> findByStatusAndRssExcludedFalseOrderByCreatedAtDesc(PostStatus status, Pageable pageable);
|
||||
List<Post> findByStatusAndRssExcludedFalseOrderByCreatedAtDesc(
|
||||
PostStatus status,
|
||||
Pageable pageable
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,13 +3,12 @@ package com.openisle.repository;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.PostSubscription;
|
||||
import com.openisle.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface PostSubscriptionRepository extends JpaRepository<PostSubscription, Long> {
|
||||
List<PostSubscription> findByPost(Post post);
|
||||
List<PostSubscription> findByUser(User user);
|
||||
Optional<PostSubscription> findByUserAndPost(User user, Post post);
|
||||
List<PostSubscription> findByPost(Post post);
|
||||
List<PostSubscription> findByUser(User user);
|
||||
Optional<PostSubscription> findByUserAndPost(User user, Post post);
|
||||
}
|
||||
|
||||
@@ -2,11 +2,10 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.PushSubscription;
|
||||
import com.openisle.model.User;
|
||||
import java.util.List;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PushSubscriptionRepository extends JpaRepository<PushSubscription, Long> {
|
||||
List<PushSubscription> findByUser(User user);
|
||||
void deleteByUserAndEndpoint(User user, String endpoint);
|
||||
List<PushSubscription> findByUser(User user);
|
||||
void deleteByUserAndEndpoint(User user, String endpoint);
|
||||
}
|
||||
|
||||
@@ -5,55 +5,81 @@ import com.openisle.model.Message;
|
||||
import com.openisle.model.Post;
|
||||
import com.openisle.model.Reaction;
|
||||
import com.openisle.model.User;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ReactionRepository extends JpaRepository<Reaction, Long> {
|
||||
Optional<Reaction> findByUserAndPostAndType(User user, Post post, com.openisle.model.ReactionType type);
|
||||
Optional<Reaction> findByUserAndCommentAndType(User user, Comment comment, com.openisle.model.ReactionType type);
|
||||
Optional<Reaction> findByUserAndMessageAndType(User user, Message message, com.openisle.model.ReactionType type);
|
||||
List<Reaction> findByPost(Post post);
|
||||
List<Reaction> findByComment(Comment comment);
|
||||
List<Reaction> findByMessage(Message message);
|
||||
Optional<Reaction> findByUserAndPostAndType(
|
||||
User user,
|
||||
Post post,
|
||||
com.openisle.model.ReactionType type
|
||||
);
|
||||
Optional<Reaction> findByUserAndCommentAndType(
|
||||
User user,
|
||||
Comment comment,
|
||||
com.openisle.model.ReactionType type
|
||||
);
|
||||
Optional<Reaction> findByUserAndMessageAndType(
|
||||
User user,
|
||||
Message message,
|
||||
com.openisle.model.ReactionType type
|
||||
);
|
||||
List<Reaction> findByPost(Post post);
|
||||
List<Reaction> findByComment(Comment comment);
|
||||
List<Reaction> findByMessage(Message message);
|
||||
|
||||
@Query("SELECT r.post.id FROM Reaction r WHERE r.post IS NOT NULL AND r.post.author.username = :username AND r.type = com.openisle.model.ReactionType.LIKE GROUP BY r.post.id ORDER BY COUNT(r.id) DESC")
|
||||
List<Long> findTopPostIds(@Param("username") String username, Pageable pageable);
|
||||
@Query(
|
||||
"SELECT r.post.id FROM Reaction r WHERE r.post IS NOT NULL AND r.post.author.username = :username AND r.type = com.openisle.model.ReactionType.LIKE GROUP BY r.post.id ORDER BY COUNT(r.id) DESC"
|
||||
)
|
||||
List<Long> findTopPostIds(@Param("username") String username, Pageable pageable);
|
||||
|
||||
@Query("SELECT r.comment.id FROM Reaction r WHERE r.comment IS NOT NULL AND r.comment.author.username = :username AND r.type = com.openisle.model.ReactionType.LIKE GROUP BY r.comment.id ORDER BY COUNT(r.id) DESC")
|
||||
List<Long> findTopCommentIds(@Param("username") String username, Pageable pageable);
|
||||
@Query(
|
||||
"SELECT r.comment.id FROM Reaction r WHERE r.comment IS NOT NULL AND r.comment.author.username = :username AND r.type = com.openisle.model.ReactionType.LIKE GROUP BY r.comment.id ORDER BY COUNT(r.id) DESC"
|
||||
)
|
||||
List<Long> findTopCommentIds(@Param("username") String username, Pageable pageable);
|
||||
|
||||
@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.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.user.username = :username AND r.createdAt >= :start"
|
||||
)
|
||||
long countByUserAfter(
|
||||
@Param("username") String username,
|
||||
@Param("start") java.time.LocalDateTime start
|
||||
);
|
||||
|
||||
@Query("""
|
||||
SELECT COUNT(DISTINCT r.id)
|
||||
FROM Reaction r
|
||||
LEFT JOIN r.post p
|
||||
LEFT JOIN p.author pa
|
||||
LEFT JOIN r.comment c
|
||||
LEFT JOIN c.author ca
|
||||
WHERE r.type = com.openisle.model.ReactionType.LIKE
|
||||
AND (
|
||||
(r.post IS NOT NULL AND pa.username = :username)
|
||||
OR (r.comment IS NOT NULL AND ca.username = :username)
|
||||
)
|
||||
""")
|
||||
long countLikesReceived(@Param("username") String username);
|
||||
@Query(
|
||||
"""
|
||||
SELECT COUNT(DISTINCT r.id)
|
||||
FROM Reaction r
|
||||
LEFT JOIN r.post p
|
||||
LEFT JOIN p.author pa
|
||||
LEFT JOIN r.comment c
|
||||
LEFT JOIN c.author ca
|
||||
WHERE r.type = com.openisle.model.ReactionType.LIKE
|
||||
AND (
|
||||
(r.post IS NOT NULL AND pa.username = :username)
|
||||
OR (r.comment IS NOT NULL AND ca.username = :username)
|
||||
)
|
||||
"""
|
||||
)
|
||||
long countLikesReceived(@Param("username") String username);
|
||||
|
||||
@Query("""
|
||||
SELECT COUNT(r) FROM Reaction r
|
||||
LEFT JOIN r.post p
|
||||
LEFT JOIN r.comment c
|
||||
WHERE (p IS NOT NULL AND p.author.username = :username) OR
|
||||
(c IS NOT NULL AND c.author.username = :username)
|
||||
""")
|
||||
long countReceived(@Param("username") String username);
|
||||
@Query(
|
||||
"""
|
||||
SELECT COUNT(r) FROM Reaction r
|
||||
LEFT JOIN r.post p
|
||||
LEFT JOIN r.comment c
|
||||
WHERE (p IS NOT NULL AND p.author.username = :username) OR
|
||||
(c IS NOT NULL AND c.author.username = :username)
|
||||
"""
|
||||
)
|
||||
long countReceived(@Param("username") String username);
|
||||
}
|
||||
|
||||
@@ -2,20 +2,19 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.Tag;
|
||||
import com.openisle.model.User;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface TagRepository extends JpaRepository<Tag, Long> {
|
||||
List<Tag> findByNameContainingIgnoreCase(String keyword);
|
||||
List<Tag> findByApproved(boolean approved);
|
||||
List<Tag> findByApprovedTrue();
|
||||
List<Tag> findByNameContainingIgnoreCaseAndApprovedTrue(String keyword);
|
||||
List<Tag> findByNameContainingIgnoreCase(String keyword);
|
||||
List<Tag> findByApproved(boolean approved);
|
||||
List<Tag> findByApprovedTrue();
|
||||
List<Tag> findByNameContainingIgnoreCaseAndApprovedTrue(String keyword);
|
||||
|
||||
List<Tag> findByCreatorOrderByCreatedAtDesc(User creator, Pageable pageable);
|
||||
List<Tag> findByCreator(User creator);
|
||||
List<Tag> findByCreatorOrderByCreatedAtDesc(User creator, Pageable pageable);
|
||||
List<Tag> findByCreator(User creator);
|
||||
|
||||
Optional<Tag> findByName(String name);
|
||||
Optional<Tag> findByName(String name);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
package com.openisle.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import com.openisle.model.User;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
Optional<User> findByUsername(String username);
|
||||
Optional<User> findByEmail(String email);
|
||||
java.util.List<User> findByUsernameContainingIgnoreCase(String keyword);
|
||||
java.util.List<User> findByRole(com.openisle.model.Role role);
|
||||
long countByExperienceGreaterThanEqual(int experience);
|
||||
long countByCreatedAtBefore(LocalDateTime createdAt);
|
||||
Optional<User> findByUsername(String username);
|
||||
Optional<User> findByEmail(String email);
|
||||
java.util.List<User> findByUsernameContainingIgnoreCase(String keyword);
|
||||
java.util.List<User> findByRole(com.openisle.model.Role role);
|
||||
long countByExperienceGreaterThanEqual(int experience);
|
||||
long countByCreatedAtBefore(LocalDateTime createdAt);
|
||||
|
||||
@Query("SELECT FUNCTION('date', u.createdAt) AS d, COUNT(u) AS c FROM User u " +
|
||||
"WHERE u.createdAt >= :start AND u.createdAt < :end GROUP BY d ORDER BY d")
|
||||
java.util.List<Object[]> countDailyRange(@Param("start") LocalDateTime start,
|
||||
@Param("end") LocalDateTime end);
|
||||
@Query(
|
||||
"SELECT FUNCTION('date', u.createdAt) AS d, COUNT(u) AS c FROM User u " +
|
||||
"WHERE u.createdAt >= :start AND u.createdAt < :end GROUP BY d ORDER BY d"
|
||||
)
|
||||
java.util.List<Object[]> countDailyRange(
|
||||
@Param("start") LocalDateTime start,
|
||||
@Param("end") LocalDateTime end
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,15 +2,14 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.User;
|
||||
import com.openisle.model.UserSubscription;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface UserSubscriptionRepository extends JpaRepository<UserSubscription, Long> {
|
||||
List<UserSubscription> findBySubscriber(User subscriber);
|
||||
List<UserSubscription> findByTarget(User target);
|
||||
Optional<UserSubscription> findBySubscriberAndTarget(User subscriber, User target);
|
||||
long countByTarget(User target);
|
||||
long countBySubscriber(User subscriber);
|
||||
List<UserSubscription> findBySubscriber(User subscriber);
|
||||
List<UserSubscription> findByTarget(User target);
|
||||
Optional<UserSubscription> findBySubscriberAndTarget(User subscriber, User target);
|
||||
long countByTarget(User target);
|
||||
long countBySubscriber(User subscriber);
|
||||
}
|
||||
|
||||
@@ -2,18 +2,19 @@ package com.openisle.repository;
|
||||
|
||||
import com.openisle.model.User;
|
||||
import com.openisle.model.UserVisit;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface UserVisitRepository extends JpaRepository<UserVisit, Long> {
|
||||
Optional<UserVisit> findByUserAndVisitDate(User user, LocalDate visitDate);
|
||||
long countByUser(User user);
|
||||
long countByVisitDate(LocalDate visitDate);
|
||||
Optional<UserVisit> findByUserAndVisitDate(User user, LocalDate visitDate);
|
||||
long countByUser(User user);
|
||||
long countByVisitDate(LocalDate visitDate);
|
||||
|
||||
@Query("SELECT uv.visitDate AS d, COUNT(uv) AS c FROM UserVisit uv WHERE uv.visitDate BETWEEN :start AND :end GROUP BY uv.visitDate ORDER BY uv.visitDate")
|
||||
java.util.List<Object[]> countRange(@Param("start") LocalDate start, @Param("end") LocalDate end);
|
||||
@Query(
|
||||
"SELECT uv.visitDate AS d, COUNT(uv) AS c FROM UserVisit uv WHERE uv.visitDate BETWEEN :start AND :end GROUP BY uv.visitDate ORDER BY uv.visitDate"
|
||||
)
|
||||
java.util.List<Object[]> countRange(@Param("start") LocalDate start, @Param("end") LocalDate end);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user