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; }