|
|
@@ -8,17 +8,21 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.jpa.repository.JpaRepository;
|
|
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
|
+import org.springframework.data.jpa.repository.Modifying;
|
|
|
import org.springframework.data.jpa.repository.Query;
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
+import javax.transaction.Transactional;
|
|
|
import java.util.List;
|
|
|
|
|
|
public interface PostRepo extends JpaRepository<Post, Long>, JpaSpecificationExecutor<Post> {
|
|
|
|
|
|
@Query("update Post p set p.del = true where p.id = ?1")
|
|
|
+ @Transactional
|
|
|
+ @Modifying
|
|
|
void deleteById(@Nonnull Long id);
|
|
|
|
|
|
- @Query("select p, u.nickname, u.avatar from Post p left join User u on p.userId = u.id")
|
|
|
+ @Query("select p, u.nickname, u.avatar from Post p left join User u on p.userId = u.id where p.del = false")
|
|
|
Page<PostDTO> allDTO(PostType type, Pageable pageable);
|
|
|
|
|
|
@Query("select new com.izouma.jmrh.dto.MyPostAndComment(p, c, c.createdAt) from Comment c " +
|