Skip to content

Commit

Permalink
톡픽 DTO 내 공통 필드 클래스에 @Valid 추가 및 네이밍 개선 (#780)
Browse files Browse the repository at this point in the history
* refactor: 톡픽 DTO 내 공통 필드 클래스에 @Valid 추가 및 네이밍 개선

* style: 패키지 이름 오타 수정

* style: 120 라인 맞춤
  • Loading branch information
Hanjaemo authored Dec 5, 2024
1 parent f7ae91b commit 790ec2e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
9 changes: 7 additions & 2 deletions src/main/java/balancetalk/talkpick/dto/TalkPickDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
import balancetalk.comment.domain.Comment;
import balancetalk.member.domain.Member;
import balancetalk.talkpick.domain.TalkPick;
import balancetalk.talkpick.dto.fields.BaseTalkPickFields;
import balancetalk.talkpick.dto.fields.ValidatedNotBlankTalkPickFields;
import balancetalk.vote.domain.TalkPickVote;
import balancetalk.vote.domain.VoteOption;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.querydsl.core.annotations.QueryProjection;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Size;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -29,7 +32,8 @@ public class TalkPickDto {
@AllArgsConstructor
public static class CreateTalkPickRequest {

private BaseTalkPickFields baseFields;
@Valid
private ValidatedNotBlankTalkPickFields baseFields;

@Schema(description = "첨부한 이미지 파일 ID 목록", example = "[12, 41]")
@Size(max = 10, message = "톡픽 생성 시 업로드할 수 있는 파일 개수는 최대 10개입니다.")
Expand Down Expand Up @@ -60,7 +64,8 @@ public boolean containsFileIds() {
@AllArgsConstructor
public static class UpdateTalkPickRequest {

private BaseTalkPickFields baseFields;
@Valid
private ValidatedNotBlankTalkPickFields baseFields;

@Schema(description = "새로 첨부한 이미지 파일 ID 목록", example = "[12, 41]")
@Size(max = 10, message = "톡픽 생성 시 업로드할 수 있는 파일 개수는 최대 10개입니다.")
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/balancetalk/talkpick/dto/TempTalkPickDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import balancetalk.member.domain.Member;
import balancetalk.talkpick.domain.TempTalkPick;
import balancetalk.talkpick.dto.fields.BaseTalkPickFields;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.List;
Expand All @@ -18,7 +20,8 @@ public class TempTalkPickDto {
@AllArgsConstructor
public static class SaveTempTalkPickRequest {

private BaseTempTalkPickFields baseFields;
@Valid
private BaseTalkPickFields baseFields;

@Schema(description = "새로 첨부한 이미지 파일 ID 목록", example = "[12, 41]")
@Size(max = 10, message = "톡픽 생성 시 업로드할 수 있는 파일 개수는 최대 10개입니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package balancetalk.talkpick.dto;
package balancetalk.talkpick.dto.fields;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Size;
Expand All @@ -16,6 +16,7 @@ public class BaseTalkPickFields {
private String title;

@Schema(description = "본문 내용", example = "본문 내용")
@Size(max = 2000, message = "본문은 2,000자 이하여야 합니다.")
private String content;

@Schema(description = "선택지 A 이름", example = "선택지 A 이름")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package balancetalk.talkpick.dto;
package balancetalk.talkpick.dto.fields;

import jakarta.validation.constraints.NotBlank;

public class BaseTempTalkPickFields extends BaseTalkPickFields {
public class ValidatedNotBlankTalkPickFields extends BaseTalkPickFields {

public BaseTempTalkPickFields(String title, String content, String optionA, String optionB, String sourceUrl) {
public ValidatedNotBlankTalkPickFields(String title, String content,
String optionA, String optionB, String sourceUrl) {
super(title, content, optionA, optionB, sourceUrl);
}

Expand Down

0 comments on commit 790ec2e

Please sign in to comment.