Skip to content

Commit

Permalink
Merge pull request #86 from SWM-Flash/feature/FLASH-294-report-conten…
Browse files Browse the repository at this point in the history
…t-type

신고 콘텐츠 타입 추가
  • Loading branch information
ChoiWonYu authored Oct 16, 2024
2 parents be66345 + be05af0 commit 257a635
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Original file line number Diff line number Diff line change
@@ -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) {

}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.first.flash.account.member.domain;

import lombok.ToString;

@ToString
public enum ContentType {
SOLUTION, COMMENT;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

0 comments on commit 257a635

Please sign in to comment.