Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

옵션 값이 있는 요청, 응답에서 값이 빈 경우 타입 통일 #161

Merged
merged 8 commits into from
Mar 14, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import static sixgaezzang.sidepeek.projects.exception.message.FileErrorMessage.OVERVIEW_IMAGE_OVER_MAX_COUNT;
import static sixgaezzang.sidepeek.projects.exception.message.MemberErrorMessage.MEMBER_IS_EMPTY;
import static sixgaezzang.sidepeek.projects.exception.message.MemberErrorMessage.MEMBER_OVER_MAX_COUNT;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.DEPLOY_URL_IS_INVALID;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.DEPLOY_URL_OVER_MAX_LENGTH;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.DESCRIPTION_IS_NULL;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.DESCRIPTION_OVER_MAX_LENGTH;
Expand All @@ -22,7 +21,6 @@
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.OVERVIEW_OVER_MAX_LENGTH;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.OWNER_ID_IS_NULL;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.SUB_NAME_OVER_MAX_LENGTH;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.THUMBNAIL_URL_IS_INVALID;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.THUMBNAIL_URL_OVER_MAX_LENGTH;
import static sixgaezzang.sidepeek.projects.exception.message.ProjectErrorMessage.TROUBLESHOOTING_OVER_MAX_LENGTH;
import static sixgaezzang.sidepeek.projects.util.ProjectConstant.MAX_MEMBER_COUNT;
Expand Down Expand Up @@ -85,12 +83,10 @@ public record SaveProjectRequest(

@Schema(description = "프로젝트 썸네일 이미지 URL", example = "https://sidepeek.image/imageeUrl")
@Size(max = MAX_TEXT_LENGTH, message = THUMBNAIL_URL_OVER_MAX_LENGTH)
@URL(message = THUMBNAIL_URL_IS_INVALID, regexp = URL_REGEXP)
String thumbnailUrl,

@Schema(description = "프로젝트 배포 URL", example = "https://www.sidepeek.com")
@Size(max = MAX_TEXT_LENGTH, message = DEPLOY_URL_OVER_MAX_LENGTH)
@URL(message = DEPLOY_URL_IS_INVALID, regexp = URL_REGEXP)
String deployUrl,

@Schema(description = "프로젝트 시작 연-월", example = "2024-02")
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/sixgaezzang/sidepeek/users/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ private void setNickname(String nickname) {
// Option
private void setIntroduction(String introduction) {
validateIntroduction(introduction);
this.introduction = introduction;
this.introduction = getBlankIfNullOrBlank(introduction);
}

private void setProfileImageUrl(String profileImageUrl) {
validateProfileImageUrl(profileImageUrl);
this.profileImageUrl = profileImageUrl;
this.profileImageUrl = getBlankIfNullOrBlank(profileImageUrl);
}

private void setJob(String jobName) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package sixgaezzang.sidepeek.users.dto.response;

import static sixgaezzang.sidepeek.common.util.CommonConstant.BLANK_STRING;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -40,10 +42,10 @@ public record UserProfileResponse(
) {
public static UserProfileResponse from(User user, boolean isSocialLogin, List<UserSkillSummary> techStacks) {
Job userJob = user.getJob();
String jobName = Objects.nonNull(userJob) ? userJob.getName() : null;
String jobName = Objects.nonNull(userJob) ? userJob.getName() : BLANK_STRING;

Career userCareer = user.getCareer();
String careerDescription = Objects.nonNull(userCareer) ? userCareer.getDescription() : null;
String careerDescription = Objects.nonNull(userCareer) ? userCareer.getDescription() : BLANK_STRING;

return UserProfileResponse.builder()
.isSocialLogin(isSocialLogin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package sixgaezzang.sidepeek.users.dto.response;

import static sixgaezzang.sidepeek.common.util.CommonConstant.BLANK_STRING;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Objects;
import lombok.Builder;
import sixgaezzang.sidepeek.users.domain.User;

Expand All @@ -11,6 +15,7 @@ public record UserSummary(
Long id,

@Schema(description = "소셜 로그인 회원 여부", nullable = true, example = "false")
@JsonInclude(JsonInclude.Include.NON_NULL)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오! 이렇게 설정할 수도 있군요! 😮

Boolean isSocialLogin,

@Schema(description = "회원/비회원 닉네임", example = "의진")
Expand All @@ -22,7 +27,7 @@ public record UserSummary(
) {

public UserSummary(Long id, String nickname, String profileImageUrl) {
this(id, null, nickname, profileImageUrl);
this(id, null, nickname, Objects.isNull(profileImageUrl) ? BLANK_STRING : profileImageUrl);
}

public static UserSummary fromWithIsSocialLogin(User user, boolean isSocialLogin) {
Expand Down Expand Up @@ -59,7 +64,7 @@ public static UserSummary from(String nickname) {
.id(null)
.isSocialLogin(null)
.nickname(nickname)
.profileImageUrl(null)
.profileImageUrl(BLANK_STRING)
.build();
}

Expand Down
Loading
Loading