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

[FEAT] 유저 프로필 수정 API - #88 #96

Merged
merged 2 commits into from
Jul 14, 2024
Merged

[FEAT] 유저 프로필 수정 API - #88 #96

merged 2 commits into from
Jul 14, 2024

Conversation

sjk4618
Copy link
Member

@sjk4618 sjk4618 commented Jul 14, 2024

🔥Pull requests

⛳️ 작업한 브랜치

👷 작업한 내용

    @Transactional
    public void editUserProfile(final Long userId,
                                final String name,
                                final List<DateTagType> tags,
                                final MultipartFile newImage) throws IOException, ExecutionException, InterruptedException {
        User foundUser = findUserById(userId);

        //이름 변경
        foundUser.setName(name);

        //tag 변경
        userTagRepository.deleteAllByUserId(foundUser.getId());
        saveUserTag(foundUser, tags);

        //이미지 변경
        String userImage = foundUser.getImageUrl();

        // 1. 원래 이미지가 있다가 null로 변경
        if (userImage != null && newImage == null) {
            deleteImage(userImage);
            foundUser.setImageUrl(null);

        // 2. 원래 이미지가 있다가 새로운 이미지로 변경
        }  else if (userImage != null && newImage != null) {
            deleteImage(userImage);
            String newImageUrl = uploadImage(newImage);
            foundUser.setImageUrl(newImageUrl);

        // 3. 원래 이미지가 없다가 새로운 이미지로 변경
        } else if (userImage == null && newImage != null) {
            String newImageUrl = uploadImage(newImage);
            foundUser.setImageUrl(newImageUrl);
        }
        userRepository.save(foundUser);
    }

📟 관련 이슈

Copy link
Contributor

@gardening-y gardening-y left a comment

Choose a reason for hiding this comment

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

Gang Gang Gang~

@sjk4618 sjk4618 merged commit 175d9c7 into develop Jul 14, 2024
1 check passed
@sjk4618 sjk4618 deleted the feature/#88 branch July 14, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEAT] 유저 프로필 수정 API
2 participants