-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.ewhatever.qna.scrap.entity; | ||
|
||
import com.ewhatever.qna.common.Base.BaseEntity; | ||
import com.ewhatever.qna.post.entity.Post; | ||
import com.ewhatever.qna.user.entity.User; | ||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class Scrap extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long scrapIdx; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "post_idx") | ||
private Post post; | ||
|
||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
@JoinColumn(name = "user_idx") | ||
private User user; | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/ewhatever/qna/scrap/repository/ScrapRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.ewhatever.qna.scrap.repository; | ||
|
||
import com.ewhatever.qna.scrap.entity.Scrap; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface ScrapRepository extends JpaRepository<Scrap, Long> { | ||
Long countByUser_UserIdxAndStatusEquals(Long userIdx, String status); | ||
Page<Scrap> findByUser_UserIdxAndStatusEquals(Long userIdx, String status, Pageable pageable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters