diff --git a/src/main/java/io/company/localhost/controller/api/VacationController.java b/src/main/java/io/company/localhost/controller/api/VacationController.java index 001fdec..c1eb988 100644 --- a/src/main/java/io/company/localhost/controller/api/VacationController.java +++ b/src/main/java/io/company/localhost/controller/api/VacationController.java @@ -13,6 +13,7 @@ * *************************************************************/ package io.company.localhost.controller.api; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -54,25 +55,36 @@ public class VacationController { @PostMapping public ApiResponse insertVacations(@RequestBody List list) { Long user = AuthUtil.getUser().getId(); + List savedVacations = new ArrayList<>(); + for (MapDto request : list) { String date = request.getString("date"); String type = request.getString("type"); Object receiverId = request.get("receiverId"); - request.put("employeeId", user); - + if (date == null || type == null) { throw new IllegalArgumentException("요청 데이터에 누락된 값이 있습니다: " + request); } - + Integer count = request.getInt("count"); if (count == null || count < 1) { count = 1; } + for (int i = 0; i < count; i++) { - localVacaService.insertVacation(request); + MapDto vacationRequest = new MapDto(); + vacationRequest.put("date", date); + vacationRequest.put("type", type); + vacationRequest.put("receiverId", receiverId); + vacationRequest.put("employeeId", user); + + // 실제 저장 + localVacaService.insertVacation(vacationRequest); + savedVacations.add(vacationRequest); } } - return ApiResponse.ok("모든 휴가가 성공적으로 저장되었습니다."); + + return ApiResponse.ok(savedVacations); } /** diff --git a/src/main/resources/mapper/localvacaMapper.xml b/src/main/resources/mapper/localvacaMapper.xml index bf53025..a39eb4b 100644 --- a/src/main/resources/mapper/localvacaMapper.xml +++ b/src/main/resources/mapper/localvacaMapper.xml @@ -39,15 +39,25 @@ -