Skip to content

Commit

Permalink
refactor: 사용자 프로필 이미지 및 배경 이미지 수정 #157
Browse files Browse the repository at this point in the history
- 엔티티 썸네일, 배경 이미지 길이 수정
- dto 썸네일, 배경 이미지 추가
- 서비스 썸네일, 배경 이미지 수정 로직 추가
  • Loading branch information
FaberJoo committed Mar 17, 2024
1 parent 0563f23 commit 81fe5b2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/main/java/io/oduck/api/domain/member/dto/MemberReqDto.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.oduck.api.domain.member.dto;

import jakarta.persistence.Column;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Pattern;
Expand Down Expand Up @@ -39,10 +40,18 @@ public static class PatchReq {
message = "자기 소개는 100자 이내여야 합니다.")
private String description;

@Column(length = 250)
private String thumbnail;

@Column(length = 250)
private String backgroundImage;

@Builder
public PatchReq(String name, String description) {
public PatchReq(String name, String description, String thumbnail, String backgroundImage) {
this.name = name;
this.description = description;
this.thumbnail = thumbnail;
this.backgroundImage = backgroundImage;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ public class MemberProfile extends BaseEntity {
@Builder.Default
private String info = "";

@Column(length = 100)
@Column(length = 250)
@Builder.Default
private String thumbnail = "";

@Column(length = 100)
@Column(length = 250)
@Builder.Default
private String backgroundImage = "";

Expand Down Expand Up @@ -70,6 +70,13 @@ public void updateName(String name) {
public void updateInfo(String info) {
this.info = info;
}
public void updateThumbnail(String thumbnail) {
this.thumbnail = thumbnail;
}

public void updateBackgroundImage(String backgroundImage) {
this.backgroundImage = backgroundImage;
}

public void delete() {
this.deletedAt = LocalDateTime.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ public MemberProfileRes getProfileByName(String name, Long memberId) {

MemberProfileRes memberProfileRes = MemberProfileRes.builder()
.isMine(memberProfile.getMemberId().equals(memberId))
.memberId(memberProfile.getMemberId()).name(memberProfile.getName())
.description(memberProfile.getDescription()).thumbnail(memberProfile.getThumbnail())
.backgroundImage(memberProfile.getBackgroundImage()).activity(activity).build();
.memberId(memberProfile.getMemberId())
.name(memberProfile.getName())
.description(memberProfile.getDescription())
.thumbnail(memberProfile.getThumbnail())
.backgroundImage(memberProfile.getBackgroundImage())
.activity(activity)
.build();

return memberProfileRes;
}
Expand All @@ -104,6 +108,8 @@ public void updateProfile(PatchReq body, Long memberId) {

// Null 체크
Optional.ofNullable(body.getDescription()).ifPresent(memberProfile::updateInfo);
Optional.ofNullable(body.getThumbnail()).ifPresent(memberProfile::updateThumbnail);
Optional.ofNullable(body.getBackgroundImage()).ifPresent(memberProfile::updateBackgroundImage);

memberProfileRepository.save(memberProfile);
}
Expand Down

0 comments on commit 81fe5b2

Please sign in to comment.