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

마이페이지 버그 수정 #643

Merged
merged 1 commit into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,20 @@ public DarakbangMemberInfoResponse findMyInfo(DarakbangMember darakbangMember) {
}

public void updateMyInfo(
DarakbangMember darakbangMember, MultipartFile file,
String nickname, String description
DarakbangMember darakbangMember, String isReset,
MultipartFile file, String nickname, String description
) {
String url = s3Client.uploadFile(file);
String profile = imageParser.parse(url);
darakbangMemberWriter.updateMyInfo(darakbangMember, nickname, description, profile);
if (file != null) { // 새로 추가된 파일이 있는 경우
String url = s3Client.uploadFile(file); // S3 Upload
String newProfileUrl = imageParser.parse(url); // 새로 저장할 profile url
darakbangMemberWriter.updateMyInfo(darakbangMember, nickname, description, newProfileUrl);
return;
}
if (isReset.equals("true")) { // 기본 이미지 변경 시
// darakbangMemberWriter.removeProfile(darakbangMember); // 기본 이미지가 원래 있는데 true => db propfile -> null
darakbangMemberWriter.updateMyInfo(darakbangMember, nickname, description, null);
} else { // 이미지 변경 없이 닉네임과 소개을 그대로 저장하는 경우
darakbangMemberWriter.updateMyInfo(darakbangMember, nickname, description);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ public boolean isNotManager() {
return role != DarakBangMemberRole.MANAGER;
}

public DarakbangMember updateMyInfo(String nickname, String description) {
this.nickname = nickname;
this.description = description;

return this;
}

public DarakbangMember updateMyInfo(String nickname, String description, String profile) {
this.nickname = nickname;
this.description = description;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public DarakbangMember saveMember(Darakbang darakbang, String nickname, Member m
}
}

public void updateMyInfo(DarakbangMember darakbangMember, String nickname, String description) {
darakbangMemberRepository.save(darakbangMember.updateMyInfo(nickname, description));
}

public void updateMyInfo(DarakbangMember darakbangMember, String nickname, String description, String profile) {
darakbangMemberRepository.save(darakbangMember.updateMyInfo(nickname, description, profile));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,12 @@ public ResponseEntity<RestResponse<DarakbangMemberInfoResponse>> findMyInfo(
})
public ResponseEntity<Void> updateMyInfo(
@LoginDarakbangMember DarakbangMember darakbangMember,
@RequestPart(value = "isReset") String isReset,
@RequestPart(value = "file", required = false) MultipartFile file,
@RequestPart(value = "profile", required = false) String profile,
@RequestPart("nickname") String nickname,
@RequestPart(value = "description", required = false) String description
) {

log.info("file : {}, profile : {}, nickname : {}, description : {}", file.toString(), profile, nickname,
description);
darakbangMemberService.updateMyInfo(darakbangMember, file, nickname, description);
darakbangMemberService.updateMyInfo(darakbangMember, isReset, file, nickname, description);

return ResponseEntity.ok().build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package mouda.backend.darakbangmember.presentation.controller.swagger;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

Expand Down Expand Up @@ -51,11 +53,14 @@ ResponseEntity<RestResponse<DarakbangMemberInfoResponse>> findMyInfo(
@ApiResponses({
@ApiResponse(responseCode = "200", description = "마이페이지 수정 성공!")
})
@PostMapping(path = "/{darakbangId}/member/mine", consumes = {
MediaType.MULTIPART_FORM_DATA_VALUE
})
ResponseEntity<Void> updateMyInfo(
@LoginDarakbangMember DarakbangMember member,
@RequestPart MultipartFile file,
@RequestPart String profile,
@RequestPart String nickname,
@RequestPart String description
@LoginDarakbangMember DarakbangMember darakbangMember,
@RequestPart(value = "isReset") String isReset,
@RequestPart(value = "file", required = false) MultipartFile file,
@RequestPart("nickname") String nickname,
@RequestPart(value = "description", required = false) String description
);
}