-
Notifications
You must be signed in to change notification settings - Fork 2
/
InformationController.java
42 lines (33 loc) · 1.35 KB
/
InformationController.java
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
package com.swidx.mapservice.controller;
import com.swidx.mapservice.Repository.InformationRepository;
import com.swidx.mapservice.entity.InformationEntity;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@RestController
@RequiredArgsConstructor
@RequestMapping("/map-service")
public class InformationController {
private final InformationRepository informationRepository;
@GetMapping("information/get_all")
public List<InformationEntity> findAllInformation(){
return informationRepository.findAll();
}
@GetMapping("information/findByName/{name}")
public List<InformationEntity> findByNameLike(@PathVariable String name){
List<InformationEntity> result = informationRepository.findByNameLike("%"+name+"%");
if(result.isEmpty()){
return null;
}else {
return result;
}
}
@GetMapping("information/findByNearby")
public List<InformationEntity> findByNearby(@RequestParam("lat") Double lat,
@RequestParam("lng") Double lng,
@RequestParam("dist") Double dist){
List<InformationEntity> result = informationRepository.findByNearby(lat,lng,dist);
return result;
}
}