diff --git a/src/main/java/balancetalk/global/oauth2/service/CustomOAuth2UserService.java b/src/main/java/balancetalk/global/oauth2/service/CustomOAuth2UserService.java index 9b05a7d51..af4bad147 100644 --- a/src/main/java/balancetalk/global/oauth2/service/CustomOAuth2UserService.java +++ b/src/main/java/balancetalk/global/oauth2/service/CustomOAuth2UserService.java @@ -45,7 +45,7 @@ public OAuth2User loadUser(OAuth2UserRequest userRequest) throws OAuth2Authentic String email = getEmail(oauth2Response); String provider = getProvider(oauth2Response); - Member findMember = memberRepository.findByEmail(email).orElse(null); + Member findMember = memberRepository.findByEmail(provider + "_" + email).orElse(null); if (findMember == null) { String encodedPassword = passwordEncoder().encode(oauth2Password); diff --git a/src/main/java/balancetalk/talkpick/dto/TalkPickDto.java b/src/main/java/balancetalk/talkpick/dto/TalkPickDto.java index e00c1b7d7..c371956e3 100644 --- a/src/main/java/balancetalk/talkpick/dto/TalkPickDto.java +++ b/src/main/java/balancetalk/talkpick/dto/TalkPickDto.java @@ -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; @@ -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개입니다.") @@ -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개입니다.") diff --git a/src/main/java/balancetalk/talkpick/dto/TempTalkPickDto.java b/src/main/java/balancetalk/talkpick/dto/TempTalkPickDto.java index aee5d5ddc..5fa1d3df5 100644 --- a/src/main/java/balancetalk/talkpick/dto/TempTalkPickDto.java +++ b/src/main/java/balancetalk/talkpick/dto/TempTalkPickDto.java @@ -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; @@ -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개입니다.") diff --git a/src/main/java/balancetalk/talkpick/dto/BaseTalkPickFields.java b/src/main/java/balancetalk/talkpick/dto/fields/BaseTalkPickFields.java similarity index 92% rename from src/main/java/balancetalk/talkpick/dto/BaseTalkPickFields.java rename to src/main/java/balancetalk/talkpick/dto/fields/BaseTalkPickFields.java index 439f2b57d..fb9be41e2 100644 --- a/src/main/java/balancetalk/talkpick/dto/BaseTalkPickFields.java +++ b/src/main/java/balancetalk/talkpick/dto/fields/BaseTalkPickFields.java @@ -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; @@ -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 이름") diff --git a/src/main/java/balancetalk/talkpick/dto/BaseTempTalkPickFields.java b/src/main/java/balancetalk/talkpick/dto/fields/ValidatedNotBlankTalkPickFields.java similarity index 73% rename from src/main/java/balancetalk/talkpick/dto/BaseTempTalkPickFields.java rename to src/main/java/balancetalk/talkpick/dto/fields/ValidatedNotBlankTalkPickFields.java index 4a9dfbd18..ff6b30cb6 100644 --- a/src/main/java/balancetalk/talkpick/dto/BaseTempTalkPickFields.java +++ b/src/main/java/balancetalk/talkpick/dto/fields/ValidatedNotBlankTalkPickFields.java @@ -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); }