Merge branch 'main' of http://192.168.0.251:3000/localnet/localhost-back.git into main
This commit is contained in:
commit
c182f749b8
@ -13,6 +13,7 @@
|
||||
*
|
||||
*************************************************************/
|
||||
package io.company.localhost.controller.api;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -54,11 +55,12 @@ public class VacationController {
|
||||
@PostMapping
|
||||
public ApiResponse<?> insertVacations(@RequestBody List<MapDto> list) {
|
||||
Long user = AuthUtil.getUser().getId();
|
||||
List<MapDto> 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);
|
||||
@ -68,11 +70,21 @@ public class VacationController {
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -39,15 +39,25 @@
|
||||
|
||||
<!-- 사용자가 받은 연차 목록 조회 -->
|
||||
<select id="selectReceivedVacations" resultType="io.company.localhost.common.dto.MapDto">
|
||||
SELECT LOCVACUDT AS date, LOCVACTYP AS type, MEMBERSEQ AS senderId
|
||||
SELECT
|
||||
LOCVACUDT AS date,
|
||||
LOCVACTYP AS type,
|
||||
MEMBERSEQ AS senderId,
|
||||
-- 반차(700101, 700102)는 0.5, 연차(700103)는 1로 계산하여 받은 연차 수량 저장
|
||||
SUM(
|
||||
CASE
|
||||
WHEN LOCVACTYP IN ('700101', '700102') THEN 0.5
|
||||
WHEN LOCVACTYP = '700103' THEN 1
|
||||
ELSE 0
|
||||
END
|
||||
) AS received_quota
|
||||
FROM localvaca
|
||||
WHERE LOCVACRMM = #{userId}
|
||||
AND YEAR(LOCVACUDT) = #{year}
|
||||
GROUP BY LOCVACUDT, LOCVACTYP, MEMBERSEQ
|
||||
ORDER BY LOCVACUDT DESC
|
||||
WHERE LOCVACRMM = #{userId} -- 현재 로그인한 사용자가 받은 연차
|
||||
AND YEAR(LOCVACUDT) = #{year} -- 해당 연도의 데이터만 가져옴
|
||||
GROUP BY LOCVACUDT, LOCVACTYP, MEMBERSEQ -- 연차를 보낸 사람별로 그룹화
|
||||
ORDER BY LOCVACUDT DESC;
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 전체 직원 남은 연차 조회 -->
|
||||
<select id="selectEmployeeRemainingVacation" resultType="io.company.localhost.common.dto.MapDto">
|
||||
<![CDATA[
|
||||
|
||||
Loading…
Reference in New Issue
Block a user