From 81fe5b2623e0f137cd86fe636d153ca9e7ffc2c9 Mon Sep 17 00:00:00 2001 From: FaberJoo <79781818+FaberJoo@users.noreply.github.com> Date: Sun, 17 Mar 2024 15:23:54 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=B0=8F=20=EB=B0=B0=EA=B2=BD=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20#157?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 엔티티 썸네일, 배경 이미지 길이 수정 - dto 썸네일, 배경 이미지 추가 - 서비스 썸네일, 배경 이미지 수정 로직 추가 --- .../io/oduck/api/domain/member/dto/MemberReqDto.java | 11 ++++++++++- .../api/domain/member/entity/MemberProfile.java | 11 +++++++++-- .../api/domain/member/service/MemberServiceImpl.java | 12 +++++++++--- 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/oduck/api/domain/member/dto/MemberReqDto.java b/src/main/java/io/oduck/api/domain/member/dto/MemberReqDto.java index 55abcca2..a80a6e49 100644 --- a/src/main/java/io/oduck/api/domain/member/dto/MemberReqDto.java +++ b/src/main/java/io/oduck/api/domain/member/dto/MemberReqDto.java @@ -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; @@ -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; } } } diff --git a/src/main/java/io/oduck/api/domain/member/entity/MemberProfile.java b/src/main/java/io/oduck/api/domain/member/entity/MemberProfile.java index b970c3db..8ec53939 100644 --- a/src/main/java/io/oduck/api/domain/member/entity/MemberProfile.java +++ b/src/main/java/io/oduck/api/domain/member/entity/MemberProfile.java @@ -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 = ""; @@ -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(); diff --git a/src/main/java/io/oduck/api/domain/member/service/MemberServiceImpl.java b/src/main/java/io/oduck/api/domain/member/service/MemberServiceImpl.java index a1ef5772..4aaed1ef 100644 --- a/src/main/java/io/oduck/api/domain/member/service/MemberServiceImpl.java +++ b/src/main/java/io/oduck/api/domain/member/service/MemberServiceImpl.java @@ -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; } @@ -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); }