diff --git a/user-service/src/main/java/com/waither/userservice/controller/SettingController.java b/user-service/src/main/java/com/waither/userservice/controller/SettingController.java index 1ce43a24..92440c9a 100644 --- a/user-service/src/main/java/com/waither/userservice/controller/SettingController.java +++ b/user-service/src/main/java/com/waither/userservice/controller/SettingController.java @@ -20,6 +20,51 @@ public class SettingController { private final SettingService settingService; private final SettingQueryService settingQueryService; + /* --------- ReadOnly (GET) <화면 별로 Response 구성> --------- */ + // 사용자 맞춤 서비스 제공 조히 + @GetMapping("/custom") + public ApiResponse getUserCustom(@AuthUser User user) { + return ApiResponse.onSuccess(settingQueryService.getUserCustom(user)); + } + + // 직장 지역 설정 조회 + @GetMapping("/region") + public ApiResponse getRegion(@AuthUser User user) { + return ApiResponse.onSuccess(settingQueryService.getRegion(user)); + } + + // 알림 설정 조회 + @GetMapping("/noti") + public ApiResponse getNotification(@AuthUser User user) { + return ApiResponse.onSuccess(settingQueryService.getNotification(user)); + } + + // 바람 세기 설정 조회 + @GetMapping("/noti/wind") + public ApiResponse getWind(@AuthUser User user) { + return ApiResponse.onSuccess(settingQueryService.getWind(user)); + } + + // 메인 화면 날씨 상세 정보 조회 + @GetMapping("/display") + public ApiResponse getDisplay(@AuthUser User user) { + return ApiResponse.onSuccess(settingQueryService.getDisplay(user)); + } + + // 사용자 가중치 설정 조회 + @GetMapping("/user-weight") + public ApiResponse getWeight(@AuthUser User user) { + return ApiResponse.onSuccess(settingQueryService.getWeight(user)); + } + + // 마이페이지 조회 + @GetMapping("/mypage") + public ApiResponse getUserInfo(@AuthUser User user) { + return ApiResponse.onSuccess(settingQueryService.getUserInfo(user)); + } + + /* --------- Update (Patch) --------- */ + // 사용자 맞춤 서비스 제공 @PatchMapping("/custom") public ApiResponse updateCustom(@AuthUser User user, @RequestBody SettingReqDto.CustomDto customDto) { @@ -98,40 +143,11 @@ public ApiResponse updateRegionReport(@AuthUser User user, @RequestBody return ApiResponse.onSuccess("직장 지역 레포트 알림 설정이 " + regionReportDto.regionReport() + "로 바뀌었습니다."); } - /* --------- ReadOnly (GET) --------- */ - @GetMapping("/custom") - public ApiResponse getUserCustom(@AuthUser User user) { - return ApiResponse.onSuccess(settingQueryService.getUserCustom(user)); - } - - @GetMapping("/region") - public ApiResponse getRegion(@AuthUser User user) { - return ApiResponse.onSuccess(settingQueryService.getRegion(user)); - } - - @GetMapping("/noti") - public ApiResponse getNotification(@AuthUser User user) { - return ApiResponse.onSuccess(settingQueryService.getNotification(user)); - } - - @GetMapping("/noti/wind") - public ApiResponse getWind(@AuthUser User user) { - return ApiResponse.onSuccess(settingQueryService.getWind(user)); - } - - @GetMapping("/display") - public ApiResponse getDisplay(@AuthUser User user) { - return ApiResponse.onSuccess(settingQueryService.getDisplay(user)); - } - - @GetMapping("/user-weight") - public ApiResponse getWeight(@AuthUser User user) { - return ApiResponse.onSuccess(settingQueryService.getWeight(user)); - } - - @GetMapping("/mypage") - public ApiResponse getUserInfo(@AuthUser User user) { - return ApiResponse.onSuccess(settingQueryService.getUserInfo(user)); + // 사용자 가중치 설정 + @PatchMapping("/user-weight") + public ApiResponse updateWeight(@AuthUser User user, @RequestBody SettingReqDto.WeightDto weightDto) { + settingService.updateWeight(user, weightDto); + return ApiResponse.onSuccess("사용자 가중치가 " + weightDto.weight() + "로 바뀌었습니다."); } } diff --git a/user-service/src/main/java/com/waither/userservice/dto/request/SettingReqDto.java b/user-service/src/main/java/com/waither/userservice/dto/request/SettingReqDto.java index 590de9cf..04a1f1fc 100644 --- a/user-service/src/main/java/com/waither/userservice/dto/request/SettingReqDto.java +++ b/user-service/src/main/java/com/waither/userservice/dto/request/SettingReqDto.java @@ -52,4 +52,8 @@ public record RegionReportDto( boolean regionReport ) { } + public record WeightDto( + Double weight + ) { } + } diff --git a/user-service/src/main/java/com/waither/userservice/service/SettingService.java b/user-service/src/main/java/com/waither/userservice/service/SettingService.java index 5bc3a758..eb025e4f 100644 --- a/user-service/src/main/java/com/waither/userservice/service/SettingService.java +++ b/user-service/src/main/java/com/waither/userservice/service/SettingService.java @@ -117,4 +117,10 @@ private void updateDays(Setting setting, List days) { settingRepository.save(setting); } + public void updateWeight(User user, SettingReqDto.WeightDto weightDto) { + Setting setting = user.getSetting(); + setting.setWeight(weightDto.weight()); + settingRepository.save(setting); + } + }