-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from minseok1015/dev
feat : 최근본 유저와 토론을 저장할 Model(테이블 생성) 및 토론상세페이지 요청 시 로직 추가
- Loading branch information
Showing
4 changed files
with
97 additions
and
1 deletion.
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
30 changes: 30 additions & 0 deletions
30
src/main/java/store/itpick/backend/model/RecentViewedDebate.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,30 @@ | ||
package store.itpick.backend.model; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.*; | ||
import java.sql.Timestamp; | ||
|
||
|
||
@Entity | ||
@Table(name = "recent_viewed_debate") | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class RecentViewedDebate { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "recent_viewed_debate_id") | ||
private Long id; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "user_id", nullable = false) | ||
private User user; | ||
|
||
@ManyToOne | ||
@JoinColumn(name = "debate_id", nullable = false) | ||
private Debate debate; | ||
|
||
@Column(name = "viewed_at", nullable = false) | ||
private Timestamp viewedAt; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/store/itpick/backend/repository/RecentViewedDebateRepository.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,14 @@ | ||
package store.itpick.backend.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import store.itpick.backend.model.RecentViewedDebate; | ||
|
||
import java.util.List; | ||
|
||
@Repository | ||
public interface RecentViewedDebateRepository extends JpaRepository<RecentViewedDebate, Long> { | ||
List<RecentViewedDebate> findByUser_UserIdOrderByViewedAtDesc(Long userId); | ||
|
||
} | ||
|
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