Skip to content

Commit

Permalink
Merge branch 'main' into feat/board
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaktmchl committed Nov 8, 2022
2 parents 2fc56fd + d70bd54 commit 26a869b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.yogit.server.user.exception;


import static com.yogit.server.user.exception.UserExceptionList.NOT_FOUND_PROFILE_IMG;

public class NotFoundUserProfileImg extends UserException{
public NotFoundUserProfileImg(){
super(NOT_FOUND_PROFILE_IMG.getCODE(), NOT_FOUND_PROFILE_IMG.getHTTPSTATUS(), NOT_FOUND_PROFILE_IMG.getMESSAGE());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
public enum UserExceptionList {

NOT_FOUND_ID("U0001", NOT_FOUND,"존재하지 않는 아이디입니다."),
DUPLICATE_LOGIN_ID("U0002", CONFLICT,"이미 존재하는 아이디입니다.");
DUPLICATE_LOGIN_ID("U0002", CONFLICT,"이미 존재하는 아이디입니다."),
NOT_FOUND_PROFILE_IMG("U0003", NOT_FOUND, "프로필 사진은 필수 값 입니다.");

private final String CODE;
private final HttpStatus HTTPSTATUS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.yogit.server.user.dto.response.UserProfileRes;
import com.yogit.server.user.entity.*;
import com.yogit.server.user.exception.NotFoundUserException;
import com.yogit.server.user.exception.NotFoundUserProfileImg;
import com.yogit.server.user.exception.UserDuplicationLoginId;
import com.yogit.server.user.repository.*;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -107,17 +108,17 @@ public ApplicationResponse<UserImagesRes> enterUserImage(CreateUserImageReq crea
User user = userRepository.findById(createUserImageReq.getUserId()).orElseThrow(NotFoundUserException::new);
UserImagesRes userImagesRes = new UserImagesRes();

userImageRepository.deleteAllByUserId(user.getId());
if(createUserImageReq.getProfileImage().isEmpty()) throw new NotFoundUserProfileImg();

// 메인 프로필 사진 업로드
if (createUserImageReq.getProfileImage() != null){
String mainImageUUid = awsS3Service.uploadImage(createUserImageReq.getProfileImage());
user.changeMainImgUUid(mainImageUUid);
userImagesRes.setProfileImageUrl(awsS3Service.makeUrlOfFilename(mainImageUUid));
}
String mainImageUUid = awsS3Service.uploadImage(createUserImageReq.getProfileImage());
user.changeMainImgUUid(mainImageUUid);
userImagesRes.setProfileImageUrl(awsS3Service.makeUrlOfFilename(mainImageUUid));

// 나머지 사진 업로드
if(createUserImageReq.getImages() != null){
userImageRepository.deleteAllByUserId(user.getId());

List<String> imageUUids = awsS3Service.uploadImages(createUserImageReq.getImages());
for(String i : imageUUids){
UserImage userImage = createUserImageReq.toEntityUserImage(user, i);
Expand Down

0 comments on commit 26a869b

Please sign in to comment.