diff --git a/src/main/java/com/example/betteriter/fo_domain/mypage/controller/MypageController.java b/src/main/java/com/example/betteriter/fo_domain/mypage/controller/MypageController.java index f9eb482..a1cc23f 100644 --- a/src/main/java/com/example/betteriter/fo_domain/mypage/controller/MypageController.java +++ b/src/main/java/com/example/betteriter/fo_domain/mypage/controller/MypageController.java @@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.RestController; @@ -165,4 +166,19 @@ public ResponseDto updateUserProfile( mypageService.updateUserProfile(user, request, image); return ResponseDto.onSuccess(null); } + + /** + * user 관심 카테고리 수정 + * + * @param request 수정할 user 정보 + * @return void + */ + @PutMapping("/category") + public ResponseDto updateUserCategory( + @Valid @RequestBody MypageRequest.UpdateCategoryRequest request + ) { + Users user = mypageService.getCurrentUser(); + mypageService.updateUserCategory(user, request); + return ResponseDto.onSuccess(null); + } } diff --git a/src/main/java/com/example/betteriter/fo_domain/mypage/dto/MypageRequest.java b/src/main/java/com/example/betteriter/fo_domain/mypage/dto/MypageRequest.java index 7c56a45..f6ce995 100644 --- a/src/main/java/com/example/betteriter/fo_domain/mypage/dto/MypageRequest.java +++ b/src/main/java/com/example/betteriter/fo_domain/mypage/dto/MypageRequest.java @@ -1,5 +1,8 @@ package com.example.betteriter.fo_domain.mypage.dto; +import java.util.List; + +import com.example.betteriter.global.constant.Category; import com.example.betteriter.global.constant.Job; import lombok.AllArgsConstructor; @@ -11,8 +14,15 @@ public class MypageRequest { @Getter @NoArgsConstructor @AllArgsConstructor - public class UpdateProfileRequest { + public static class UpdateProfileRequest { private String nickname; private Job job; } + + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class UpdateCategoryRequest { + private List categories; + } } 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 98ec8ae..6603dac 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 @@ -136,4 +136,8 @@ private void checkUploadProfileImageRequestValidation(MultipartFile image) { throw new MypageHandler(_IMAGE_FILE_UPLOAD_REQUEST_IS_NOT_VALID); } } + + public void updateUserCategory(Users user, MypageRequest.UpdateCategoryRequest request) { + user.setUsersCategory(request.getCategories()); + } }