From fc442d74997e71f48adbf3cf3eabd36d66d19bb3 Mon Sep 17 00:00:00 2001 From: seokjin8678 Date: Thu, 9 May 2024 00:04:20 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20SocialMedia=20logoUrl=20null=20?= =?UTF-8?q?=ED=98=B9=EC=9D=80=20=EA=B3=B5=EB=B0=B1=20=EB=AC=B8=EC=9E=90?= =?UTF-8?q?=EC=97=B4=20=EC=8B=9C=20=EB=B9=88=20=EB=AC=B8=EC=9E=90=EC=97=B4?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95=20=EB=B0=8F=20=EA=B2=80=EC=A6=9D=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 --- .../socialmedia/SocialMediaCreateV1Request.java | 3 ++- .../socialmedia/SocialMediaUpdateV1Request.java | 3 ++- .../festago/socialmedia/domain/SocialMedia.java | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/com/festago/admin/dto/socialmedia/SocialMediaCreateV1Request.java b/backend/src/main/java/com/festago/admin/dto/socialmedia/SocialMediaCreateV1Request.java index 05074c44c..054f109a6 100644 --- a/backend/src/main/java/com/festago/admin/dto/socialmedia/SocialMediaCreateV1Request.java +++ b/backend/src/main/java/com/festago/admin/dto/socialmedia/SocialMediaCreateV1Request.java @@ -3,6 +3,7 @@ import com.festago.socialmedia.domain.OwnerType; import com.festago.socialmedia.domain.SocialMediaType; import com.festago.socialmedia.dto.command.SocialMediaCreateCommand; +import jakarta.annotation.Nullable; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.Builder; @@ -17,7 +18,7 @@ public record SocialMediaCreateV1Request( SocialMediaType socialMediaType, @NotBlank String name, - @NotBlank + @Nullable String logoUrl, @NotBlank String url diff --git a/backend/src/main/java/com/festago/admin/dto/socialmedia/SocialMediaUpdateV1Request.java b/backend/src/main/java/com/festago/admin/dto/socialmedia/SocialMediaUpdateV1Request.java index 82fa5adca..b02f9f996 100644 --- a/backend/src/main/java/com/festago/admin/dto/socialmedia/SocialMediaUpdateV1Request.java +++ b/backend/src/main/java/com/festago/admin/dto/socialmedia/SocialMediaUpdateV1Request.java @@ -1,6 +1,7 @@ package com.festago.admin.dto.socialmedia; import com.festago.socialmedia.dto.command.SocialMediaUpdateCommand; +import jakarta.annotation.Nullable; import jakarta.validation.constraints.NotBlank; import lombok.Builder; @@ -8,7 +9,7 @@ public record SocialMediaUpdateV1Request( @NotBlank String name, - @NotBlank + @Nullable String logoUrl, @NotBlank String url diff --git a/backend/src/main/java/com/festago/socialmedia/domain/SocialMedia.java b/backend/src/main/java/com/festago/socialmedia/domain/SocialMedia.java index 4271cf2e7..5d3b39aca 100644 --- a/backend/src/main/java/com/festago/socialmedia/domain/SocialMedia.java +++ b/backend/src/main/java/com/festago/socialmedia/domain/SocialMedia.java @@ -1,6 +1,8 @@ package com.festago.socialmedia.domain; import com.festago.common.domain.BaseTimeEntity; +import com.festago.common.util.ImageUrlHelper; +import com.festago.common.util.Validator; import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.EnumType; @@ -19,7 +21,7 @@ name = "social_media", uniqueConstraints = { @UniqueConstraint( - columnNames= {"owner_id", "owner_type", "media_type"} + columnNames = {"owner_id", "owner_type", "media_type"} ) } ) @@ -47,14 +49,18 @@ public class SocialMedia extends BaseTimeEntity { private String url; public SocialMedia(Long id, Long ownerId, OwnerType ownerType, SocialMediaType mediaType, String name, - String logoUrl, - String url) { + String logoUrl, String url) { + Validator.notNull(ownerId, "ownerId"); + Validator.notNull(ownerType, "ownerType"); + Validator.notNull(mediaType, "mediaType"); + Validator.notBlank(name, "name"); + Validator.notBlank(url, "url"); this.id = id; this.ownerId = ownerId; this.ownerType = ownerType; this.mediaType = mediaType; this.name = name; - this.logoUrl = logoUrl; + this.logoUrl = ImageUrlHelper.getBlankStringIfBlank(logoUrl); this.url = url; } @@ -64,10 +70,12 @@ public SocialMedia(Long ownerId, OwnerType ownerType, SocialMediaType mediaType, } public void changeName(String name) { + Validator.notBlank(name, "name"); this.name = name; } public void changeUrl(String url) { + Validator.notBlank(url, "url"); this.url = url; }