- 프로젝트별 외주사·필드워커 배정 현황 API 추가 - 진행 현황을 리스트 배정 기준으로 변경 및 미배정 집계 추가 - 마지막 이벤트 일자 필터·정렬 추가 - 예약 알림·기간 조회·확인 API 추가 - 이벤트 이력 단건 삭제 기능 추가 - 일반 리스트 헤더 ID를 101부터 생성 - 비밀번호 검증 규칙 완화
90 lines
3.2 KiB
Java
90 lines
3.2 KiB
Java
package com.kri.contact.server.controller;
|
|
|
|
import com.kri.common.feature.datetime.DateTimeUtil;
|
|
import com.kri.common.feature.web.RequestUserContext;
|
|
import com.kri.contact.server.dto.reserve.ListReserveDto;
|
|
import com.kri.contact.server.dto.reserve.ListReserveRequestDto;
|
|
import com.kri.contact.server.service.ReserveService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import jakarta.validation.Valid;
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDateTime;
|
|
import java.util.List;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.PatchMapping;
|
|
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.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
@RestController
|
|
@RequestMapping("/api/v1/reserve")
|
|
@RequiredArgsConstructor
|
|
@Tag(name = "Reserve", description = "List reserve API")
|
|
public class ReserveController {
|
|
|
|
private final ReserveService reserveService;
|
|
|
|
@Operation(summary = "Reserve list")
|
|
@PutMapping
|
|
public ListReserveDto reserve(
|
|
@Valid @RequestBody ListReserveRequestDto request,
|
|
RequestUserContext ctx
|
|
) {
|
|
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
|
return reserveService.reserve(request, ctx.getUserId(), now);
|
|
}
|
|
|
|
@Operation(summary = "Find reserve notifications by user")
|
|
@GetMapping("/user/{userId}")
|
|
public List<ListReserveDto> findNotifications(
|
|
@PathVariable String userId,
|
|
@RequestParam(defaultValue = "false") boolean requestPast
|
|
) {
|
|
LocalDateTime now = DateTimeUtil.nowKstLocalDateTime();
|
|
return reserveService.findNotifications(userId, requestPast, now);
|
|
}
|
|
|
|
@Operation(summary = "Find reserves by user and date range")
|
|
@GetMapping("/user/{userId}/search")
|
|
public List<ListReserveDto> findByUserAndDateRange(
|
|
@PathVariable String userId,
|
|
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate fromDt,
|
|
@RequestParam @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate toDt
|
|
) {
|
|
return reserveService.findByUserAndDateRange(userId, fromDt, toDt);
|
|
}
|
|
|
|
@Operation(summary = "Find reserves by user")
|
|
@GetMapping("/{prjctIdx}/user/{userId}")
|
|
public List<ListReserveDto> findByUser(
|
|
@PathVariable Long prjctIdx,
|
|
@PathVariable String userId
|
|
) {
|
|
return reserveService.findByUser(prjctIdx, userId);
|
|
}
|
|
|
|
@Operation(summary = "Find reserves by sid")
|
|
@GetMapping("/{prjctIdx}/sid/{sid}")
|
|
public List<ListReserveDto> findBySid(
|
|
@PathVariable Long prjctIdx,
|
|
@PathVariable String sid
|
|
) {
|
|
return reserveService.findBySid(prjctIdx, sid);
|
|
}
|
|
|
|
@Operation(summary = "Confirm reserve notification")
|
|
@PatchMapping("/confirm/{listResveIdx}")
|
|
public void confirm(
|
|
@PathVariable Long listResveIdx,
|
|
RequestUserContext ctx
|
|
) {
|
|
reserveService.confirm(listResveIdx, ctx.getUserId());
|
|
}
|
|
}
|