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

[Feature/176] 유저 프로필 수정 및 관심 카테고리 수정 api 에러 픽스 #177

Merged
merged 2 commits into from
Feb 26, 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 @@ -124,6 +124,7 @@ public void updateUserProfile(Users user, MypageRequest.UpdateProfileRequest req
// 2. 프로필 정보 수정
UsersDetail detail = user.getUsersDetail();
detail.updateProfile(request, profileImageUrl);
userService.updateUserDetail(detail);
}

private String uploadProfileImage(Users user, MultipartFile image) {
Expand All @@ -138,6 +139,6 @@ private void checkUploadProfileImageRequestValidation(MultipartFile image) {
}

public void updateUserCategory(Users user, MypageRequest.UpdateCategoryRequest request) {
user.setUsersCategory(request.getCategories());
userService.updateUserCategory(user, request.getCategories());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import com.example.betteriter.fo_domain.user.domain.UsersWithdrawReason;
import com.example.betteriter.fo_domain.user.dto.info.GetUserInfoResponseDto;
import com.example.betteriter.fo_domain.user.exception.UserHandler;
import com.example.betteriter.fo_domain.user.repository.UserDetailRepository;
import com.example.betteriter.fo_domain.user.repository.UsersRepository;
import com.example.betteriter.fo_domain.user.repository.UsersWithdrawReasonRepository;
import com.example.betteriter.global.common.code.status.ErrorStatus;
import com.example.betteriter.global.constant.Category;
import com.example.betteriter.global.util.RedisUtil;
import com.example.betteriter.global.util.SecurityUtil;
import com.example.betteriter.infra.s3.S3Service;
Expand All @@ -16,9 +18,9 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
Expand All @@ -30,6 +32,7 @@
@Service
public class UserService {
private final UsersRepository usersRepository;
private final UserDetailRepository userDetailRepository;
private final UsersWithdrawReasonRepository usersWithdrawReasonRepository;
private final RedisUtil redisUtil;
private final SecurityUtil securityUtil;
Expand Down Expand Up @@ -99,4 +102,12 @@ public Users getUserByEmail(String email) {
.orElseThrow(() -> new UserHandler(ErrorStatus._USER_NOT_FOUND));
}

public void updateUserDetail(UsersDetail detail) {
this.userDetailRepository.save(detail);
}

public void updateUserCategory(Users user, List<Category> categories) {
user.setUsersCategory(categories);
this.usersRepository.save(user);
}
}
Loading