Skip to content

Commit

Permalink
Merge pull request #177 from BETTER-iTER/feature/176
Browse files Browse the repository at this point in the history
[Feature/176] 유저 프로필 수정 및 관심 카테고리 수정 api 에러 픽스
  • Loading branch information
luke0408 authored Feb 26, 2024
2 parents edb98c3 + 93ea12a commit fe19496
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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);
}
}

0 comments on commit fe19496

Please sign in to comment.