-
Notifications
You must be signed in to change notification settings - Fork 0
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 #46 from Team-Shaka/feat/43
✨ Feat : 게시글 신고 API 구현
- Loading branch information
Showing
8 changed files
with
140 additions
and
0 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
19 changes: 19 additions & 0 deletions
19
src/main/java/treehouse/server/api/report/implementation/ReportCommandAdapter.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,19 @@ | ||
package treehouse.server.api.report.implementation; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import treehouse.server.api.report.persistent.ReportRepository; | ||
import treehouse.server.global.annotations.Adapter; | ||
import treehouse.server.global.entity.report.Report; | ||
|
||
@Adapter | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
public class ReportCommandAdapter { | ||
|
||
private final ReportRepository reportRepository; | ||
|
||
public Report createReport(Report report){ | ||
return reportRepository.save(report); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/treehouse/server/api/report/persistent/ReportRepository.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,7 @@ | ||
package treehouse.server.api.report.persistent; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import treehouse.server.global.entity.report.Report; | ||
|
||
public interface ReportRepository extends JpaRepository<Report, Long> { | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/treehouse/server/global/entity/report/Report.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,44 @@ | ||
package treehouse.server.global.entity.report; | ||
|
||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.NotNull; | ||
import lombok.*; | ||
import treehouse.server.global.entity.comment.Comment; | ||
import treehouse.server.global.entity.member.Member; | ||
import treehouse.server.global.entity.post.Post; | ||
|
||
@Entity | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Report { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private String reason; | ||
|
||
@JoinColumn(name = "reporterId") | ||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member reporterMember; | ||
|
||
@JoinColumn(name = "targetId") | ||
@NotNull | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Member targetMember; | ||
|
||
@JoinColumn(name = "postId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Post post; | ||
|
||
@JoinColumn(name = "commentId") | ||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Comment comment; | ||
|
||
public void setReporterMember(Member reporterMember) { | ||
this.reporterMember = reporterMember; | ||
} | ||
} |
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