diff --git a/src/main/java/com/example/betteriter/fo_domain/mypage/service/MypageService.java b/src/main/java/com/example/betteriter/fo_domain/mypage/service/MypageService.java index 6603dac..448df82 100644 --- a/src/main/java/com/example/betteriter/fo_domain/mypage/service/MypageService.java +++ b/src/main/java/com/example/betteriter/fo_domain/mypage/service/MypageService.java @@ -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) { @@ -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()); } } diff --git a/src/main/java/com/example/betteriter/fo_domain/user/service/UserService.java b/src/main/java/com/example/betteriter/fo_domain/user/service/UserService.java index 5bb4b75..61ccf6f 100644 --- a/src/main/java/com/example/betteriter/fo_domain/user/service/UserService.java +++ b/src/main/java/com/example/betteriter/fo_domain/user/service/UserService.java @@ -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; @@ -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; /** @@ -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; @@ -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 categories) { + user.setUsersCategory(categories); + this.usersRepository.save(user); + } }