-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDashboardController.java
More file actions
52 lines (43 loc) · 1.97 KB
/
DashboardController.java
File metadata and controls
52 lines (43 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.example.backend.dashboard.controller;
import com.example.backend.dashboard.dto.*;
import com.example.backend.dashboard.service.DashboardService;
import jakarta.servlet.http.HttpSession;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/api/v1/case")
@RequiredArgsConstructor
public class DashboardController {
private final DashboardService dashboardService;
// 사건 정보 조회
@GetMapping("")
public ResponseEntity<?> getCases(HttpSession session) {
List<DashboardResponse> cases = dashboardService.getCases(session);
return ResponseEntity.ok(cases);
}
// 사건 영상 확인
@GetMapping("/{id}")
public ResponseEntity<?> getCaseVideo(@PathVariable("id") int id, HttpSession session) {
Map<String, String> videoResponse = dashboardService.getCaseVideo(id, session);
return ResponseEntity.ok(videoResponse);
}
// 출동 | 미출동 클릭 시 => 1. 이미 출동인 상태 or 2. state를 업데이트
@PutMapping("/ready/{id}")
public ResponseEntity<?> updateCaseState(@PathVariable("id") int id,
@RequestBody StateRequest request,
HttpSession session) {
Map<String, String> message = dashboardService.updateCaseState(id, request, session);
return ResponseEntity.ok(message);
}
// 출동 중인 사건 해결 처리
@PutMapping("/complete/{id}")
public ResponseEntity<?> completeCase(@PathVariable("id") int id,
@RequestBody SurveyRequest surveyRequest,
HttpSession session) {
Map<String, String> completedCase = dashboardService.completeCase(id, surveyRequest, session);
return ResponseEntity.ok(completedCase);
}
}