Skip to content

Commit

Permalink
Merge pull request #161 from Leets-Official/refactor/#160-reporttype-…
Browse files Browse the repository at this point in the history
…값이-μœ νš¨ν•˜μ§€-μ•Šμ€-경우-μ˜ˆμ™Έ-처리-μΆ”κ°€

[Refactor] ReportType 값이 μœ νš¨ν•˜μ§€ μ•Šμ€ 경우 검증 μΆ”κ°€
  • Loading branch information
jj0526 authored Feb 4, 2025
2 parents 565a0c8 + 1a19582 commit 8b08159
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.example.eatmate.app.domain.report.domain;

import java.util.stream.Stream;

import com.fasterxml.jackson.annotation.JsonCreator;

import lombok.Getter;

@Getter
Expand All @@ -13,4 +17,15 @@ public enum ReportType {
ReportType(String description) {
this.description = description;
}

@JsonCreator
public static ReportType parsing(String inputValue) {
if (inputValue == null) {
return null;
}
return Stream.of(ReportType.values())
.filter(category -> category.toString().equals(inputValue.toUpperCase()))
.findFirst()
.orElse(null);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.eatmate.app.domain.report.dto;

import com.example.eatmate.app.domain.report.domain.ReportType;
import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
Expand All @@ -10,14 +9,13 @@
@Getter
public class ReportRequestDto {

@NotNull(message = "μ‹ κ³  μœ ν˜•μ΄ λΉ„μ–΄μžˆμ„ 수 μ—†μŠ΅λ‹ˆλ‹€.")
@JsonProperty("reportType")
@NotNull(message = "μ‹ κ³  μœ ν˜•μ€ ν•„μˆ˜μ΄λ©°, OFFENSIVE, HARASSMENT, OTHER 쀑 ν•˜λ‚˜μ—¬μ•Ό ν•©λ‹ˆλ‹€.")
private ReportType reportType;

@NotBlank(message = "μ‹ κ³  μ‚¬μœ λŠ” λΉ„μ–΄μžˆμ„ 수 μ—†μŠ΅λ‹ˆλ‹€.")
@NotBlank(message = "μ‹ κ³  μ‚¬μœ λ₯Ό μž…λ ₯ν•΄ μ£Όμ„Έμš”.")
private String reportingReasonDescription; // ꡬ체적인 μ‹ κ³  μ‚¬μœ 

@NotNull(message = "μ‹ κ³  λŒ€μƒμ΄ λΉ„μ–΄μžˆμ„ 수 μ—†μŠ΅λ‹ˆλ‹€.")
@NotNull(message = "μ‹ κ³ ν•  μ‚¬μš©μžλ₯Ό 지정해 μ£Όμ„Έμš”.")
private Long reportedMemberId;

@NotBlank(message = "μ±„νŒ… 메세지가 λΉ„μ–΄μžˆμ„ 수 μ—†μŠ΅λ‹ˆλ‹€.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public enum ErrorCode {
INVALID_EMAIL_DOMAIN(400, "INVALID_EMAIL_DOMAIN", "κ°€μ²œλŒ€ν•™κ΅ 이메일이 μ•„λ‹™λ‹ˆλ‹€."),
INVALID_PARAMETER_TYPE(400, "INVALID_PARAMETER_TYPE", "μ μ ˆν•˜μ§€ μ•Šμ€ νŒŒλΌλ―Έν„° νƒ€μž…μž…λ‹ˆλ‹€."),


//νšŒμ›
USER_NOT_FOUND(404, "USER_NOT_FOUND", "μœ μ €λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
TOKEN_NOT_FOUND(404, "TOKEN_NOT_FOUND", "토큰λ₯Ό 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."),
Expand Down Expand Up @@ -46,7 +45,6 @@ public enum ErrorCode {

// μ‹ κ³ 
SELF_REPORT_NOT_ALLOWED(400, "SELF_REPORT_NOT_ALLOWED", "자기 μžμ‹ μ„ μ‹ κ³ ν•  수 μ—†μŠ΅λ‹ˆλ‹€."),
INVALID_REPORT_TYPE_LIST(400, "INVALID_REPORT_TYPE_LIST", "μ˜¬λ°”λ₯΄μ§€ μ•Šμ€ μ‹ κ³  μ‚¬μœ  λ¦¬μŠ€νŠΈμž…λ‹ˆλ‹€."),
DUPLICATE_REPORT_NOT_ALLOWED(400, "DUPLICATE_REPORT_NOT_ALLOWED", "같은 μœ μ €λ₯Ό μ—°μ†μ μœΌλ‘œ μ‹ κ³ ν•  수 μ—†μŠ΅λ‹ˆλ‹€."),

// 곡지사항
Expand Down

0 comments on commit 8b08159

Please sign in to comment.