Skip to content

Commit

Permalink
feat: SocialMedia logoUrl null 혹은 공백 문자열 시 빈 문자열 설정 및 검증 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seokjin8678 committed May 8, 2024
1 parent f836b87 commit fc442d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -17,7 +18,7 @@ public record SocialMediaCreateV1Request(
SocialMediaType socialMediaType,
@NotBlank
String name,
@NotBlank
@Nullable
String logoUrl,
@NotBlank
String url
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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;

@Builder
public record SocialMediaUpdateV1Request(
@NotBlank
String name,
@NotBlank
@Nullable
String logoUrl,
@NotBlank
String url
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,7 +21,7 @@
name = "social_media",
uniqueConstraints = {
@UniqueConstraint(
columnNames= {"owner_id", "owner_type", "media_type"}
columnNames = {"owner_id", "owner_type", "media_type"}
)
}
)
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit fc442d7

Please sign in to comment.