From cf4e5f6c3a01b78befa8983291b250bb77caf680 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 13 Oct 2024 17:18:52 +0900 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=EC=8B=A0=EA=B3=A0=ED=95=A0=20?= =?UTF-8?q?=EC=BD=98=ED=85=90=EC=B8=A0=EC=9D=98=20=ED=83=80=EC=9E=85=20enu?= =?UTF-8?q?m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../first/flash/account/member/domain/ContentType.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/main/java/com/first/flash/account/member/domain/ContentType.java diff --git a/src/main/java/com/first/flash/account/member/domain/ContentType.java b/src/main/java/com/first/flash/account/member/domain/ContentType.java new file mode 100644 index 00000000..d84eedfb --- /dev/null +++ b/src/main/java/com/first/flash/account/member/domain/ContentType.java @@ -0,0 +1,8 @@ +package com.first.flash.account.member.domain; + +import lombok.ToString; + +@ToString +public enum ContentType { + SOLUTION, COMMENT; +} From d5d4e59775d0bfc9617f7462b907e7b681de0cce Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 13 Oct 2024 17:19:22 +0900 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20report=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=EC=97=90=20content=20type=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/account/member/domain/MemberReport.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/first/flash/account/member/domain/MemberReport.java b/src/main/java/com/first/flash/account/member/domain/MemberReport.java index 729ecb6c..280fc350 100644 --- a/src/main/java/com/first/flash/account/member/domain/MemberReport.java +++ b/src/main/java/com/first/flash/account/member/domain/MemberReport.java @@ -3,6 +3,8 @@ import com.first.flash.global.domain.BaseEntity; import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -27,15 +29,19 @@ public class MemberReport extends BaseEntity { @JoinColumn(name = "reporterId") private Member reporter; private Long reportedContentId; + @Enumerated(EnumType.STRING) + private ContentType contentType; - private MemberReport(final String reason, final Member reporter, final Long reportedContentId) { + private MemberReport(final String reason, final Member reporter, final Long reportedContentId, + final ContentType contentType) { this.reason = reason; this.reporter = reporter; this.reportedContentId = reportedContentId; + this.contentType = contentType; } public static MemberReport reportContent(final String reason, final Member reporter, - final Long reportedContentId) { - return new MemberReport(reason, reporter, reportedContentId); + final Long reportedContentId, final ContentType contentType) { + return new MemberReport(reason, reporter, reportedContentId, contentType); } } From be05af0d89a2daacc5b45ed57b359428f9f46df2 Mon Sep 17 00:00:00 2001 From: WonyuChoi Date: Sun, 13 Oct 2024 17:20:08 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=EC=8B=A0=EA=B3=A0=20=EC=8B=9C?= =?UTF-8?q?=EB=82=98=EB=A6=AC=EC=98=A4=EC=97=90=20content=20type=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flash/account/member/application/ReportService.java | 7 ++++--- .../member/application/dto/MemberReportRequest.java | 6 +++++- .../member/application/dto/MemberReportResponse.java | 9 ++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/first/flash/account/member/application/ReportService.java b/src/main/java/com/first/flash/account/member/application/ReportService.java index 67892ac8..bf7657c2 100644 --- a/src/main/java/com/first/flash/account/member/application/ReportService.java +++ b/src/main/java/com/first/flash/account/member/application/ReportService.java @@ -25,8 +25,9 @@ public MemberReportResponse reportMember(final Long reportedContentId, UUID reporterId = AuthUtil.getId(); Member reporter = memberService.findById(reporterId); MemberReport memberReport = MemberReport.reportContent(request.reason(), reporter, - reportedContentId); - reportRepository.save(memberReport); - return MemberReportResponse.toDto(reportedContentId, request.reason()); + reportedContentId, request.contentType()); + MemberReport savedReport = reportRepository.save(memberReport); + return MemberReportResponse.toDto(savedReport.getReportedContentId(), + savedReport.getContentType(), savedReport.getReason()); } } diff --git a/src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.java b/src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.java index 90ff2035..d9199d5b 100644 --- a/src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.java +++ b/src/main/java/com/first/flash/account/member/application/dto/MemberReportRequest.java @@ -1,7 +1,11 @@ package com.first.flash.account.member.application.dto; +import com.first.flash.account.member.domain.ContentType; +import com.first.flash.global.annotation.ValidEnum; import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; -public record MemberReportRequest(@NotEmpty(message = "신고 사유는 필수입니다.") String reason) { +public record MemberReportRequest(@NotEmpty(message = "신고 사유는 필수입니다.") String reason, + @NotNull(message = "콘텐츠 타입은 필수입니다.") @ValidEnum(enumClass = ContentType.class) ContentType contentType) { } diff --git a/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java b/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java index 94e916dc..87923b55 100644 --- a/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java +++ b/src/main/java/com/first/flash/account/member/application/dto/MemberReportResponse.java @@ -1,8 +1,11 @@ package com.first.flash.account.member.application.dto; -public record MemberReportResponse(Long reportedContentId, String reason) { +import com.first.flash.account.member.domain.ContentType; - public static MemberReportResponse toDto(final Long reportedContentId, final String reason) { - return new MemberReportResponse(reportedContentId, reason); +public record MemberReportResponse(Long reportedContentId, String contentType, String reason) { + + public static MemberReportResponse toDto(final Long reportedContentId, + final ContentType contentType, final String reason) { + return new MemberReportResponse(reportedContentId, contentType.name(), reason); } }