added scheduler for delete old or found posts

This commit is contained in:
SlimusMinus
2026-06-25 00:48:55 +03:00
parent 6f90562982
commit ec5cc6cedd
8 changed files with 148 additions and 0 deletions

View File

@@ -12,6 +12,8 @@ public interface FavoriteRepository extends JpaRepository<Favorite, Long> {
boolean existsByUserAndPost(User user, Post post);
List<Favorite> findByUser(User user);
void deleteByUserAndPost(User user, Post post);
void deleteByPost(Post post);
void deleteByPostIn(List<Post> posts);
@Query("""
SELECT f.post.id FROM Favorite f

View File

@@ -1,6 +1,8 @@
package com.krylov.refound.repository;
import com.krylov.refound.entity.Post;
import com.krylov.refound.enums.PostStatus;
import java.time.LocalDateTime;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
@@ -9,4 +11,8 @@ public interface PostRepository extends JpaRepository<Post, Long>, JpaSpecificat
List<Post> findByUserId(Long userId);
List<Post> findByStatus(PostStatus status);
List<Post> findByCreatedAtBefore(LocalDateTime date);
}