1+ package com .factoreal .backend .controller ;
2+
3+ import com .factoreal .backend .dto .WorkerDto ;
4+ import com .factoreal .backend .dto .ZoneManagerResponseDto ;
5+ import com .factoreal .backend .service .WorkerService ;
6+
7+ import io .swagger .v3 .oas .annotations .Operation ;
8+ import io .swagger .v3 .oas .annotations .tags .Tag ;
9+ import lombok .RequiredArgsConstructor ;
10+ import lombok .extern .slf4j .Slf4j ;
11+ import org .springframework .http .ResponseEntity ;
12+ import org .springframework .web .bind .annotation .*;
13+
14+ import java .util .List ;
15+
16+ @ RestController
17+ @ RequestMapping ("/api/workers" )
18+ @ RequiredArgsConstructor
19+ @ Slf4j
20+ @ Tag (name = "작업자 API" , description = "작업자 조회 API" )
21+ public class WorkerController {
22+ private final WorkerService workerService ;
23+
24+ @ Operation (summary = "전체 작업자 목록 조회" , description = "전체 작업자 목록을 조회합니다." )
25+ @ GetMapping
26+ public ResponseEntity <List <WorkerDto >> getAllWorkers () {
27+ log .info ("전체 작업자 목록 조회 요청" );
28+ List <WorkerDto > workers = workerService .getAllWorkers ();
29+ return ResponseEntity .ok (workers );
30+ }
31+
32+ @ Operation (summary = "공간별 작업자 목록 조회" , description = "공간 ID를 기반으로 현재 해당 공간에 들어가있는 작업자 리스트를 조회합니다." )
33+ @ GetMapping ("/zone/{zoneId}" )
34+ public ResponseEntity <List <WorkerDto >> getWorkersByZoneId (@ PathVariable String zoneId ) {
35+ log .info ("공간 ID: {}의 작업자 목록 조회 요청" , zoneId );
36+ List <WorkerDto > zoneWorkers = workerService .getWorkersByZoneId (zoneId );
37+ return ResponseEntity .ok (zoneWorkers );
38+ }
39+
40+ @ Operation (summary = "공간 담당자 정보 조회" ,
41+ description = "공간 ID를 기반으로 해당 공간의 담당자와 현재 위치 정보를 조회합니다." )
42+ @ GetMapping ("/zone/{zoneId}/manager" )
43+ public ResponseEntity <ZoneManagerResponseDto > getZoneManager (@ PathVariable String zoneId ) {
44+ log .info ("공간 ID: {}의 담당자 정보 조회 요청" , zoneId );
45+ ZoneManagerResponseDto manager = workerService .getZoneManagerWithLocation (zoneId );
46+ return ResponseEntity .ok (manager );
47+ }
48+ }
0 commit comments