-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSafetyLocationController.java
More file actions
31 lines (24 loc) · 1.01 KB
/
Copy pathSafetyLocationController.java
File metadata and controls
31 lines (24 loc) · 1.01 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
package com.crimeLink.analyzer.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.crimeLink.analyzer.entity.SafetyLocation;
import com.crimeLink.analyzer.entity.SafetyType;
import com.crimeLink.analyzer.service.SafetyLocationService;
@RestController
@RequestMapping("/api/safety-locations")
public class SafetyLocationController {
@Autowired
private SafetyLocationService service;
@GetMapping
public List<SafetyLocation> getByType(@RequestParam(required = false) String type) {
if (type == null || type.isEmpty()) {
return service.getAllLocations();
}
SafetyType safetyType = SafetyType.valueOf(type.toUpperCase());
return service.getByType(safetyType);
}
}