From cae792801786341d0951c8cb8dfcf4abf5eeae6f Mon Sep 17 00:00:00 2001 From: dyhj625 Date: Tue, 11 Mar 2025 16:14:09 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9C=B4=EA=B0=80=20=EC=BF=BC=EB=A6=AC?= =?UTF-8?q?=EB=AC=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/api/VacationController.java | 22 ++++++++++++++----- src/main/resources/mapper/localvacaMapper.xml | 22 ++++++++++++++----- 2 files changed, 33 insertions(+), 11 deletions(-) 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 @@ -