-
Notifications
You must be signed in to change notification settings - Fork 2
/
TourInformationController.java
52 lines (38 loc) · 1.66 KB
/
TourInformationController.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
43
44
45
46
47
48
49
50
51
52
package com.swidx.mapservice.controller;
import com.swidx.mapservice.Repository.TourInformationRepository;
import com.swidx.mapservice.entity.InformationEntity;
import com.swidx.mapservice.entity.TourId;
import com.swidx.mapservice.entity.TourInformationEntity;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Optional;
@RestController
@RequiredArgsConstructor
@RequestMapping("/map-service")
public class TourInformationController {
private final TourInformationRepository tourInformationRepository;
@GetMapping("tour-information/findByName")
public TourInformationEntity findByName(@RequestParam("name") String name){
TourInformationEntity result = tourInformationRepository.findByName(name);
return result;
}
@GetMapping("tour-information/findByName/{name}")
public List<TourInformationEntity> findByNameLike(@PathVariable String name){
List<TourInformationEntity> result = tourInformationRepository.findByNameLike("%"+name+"%");
if(result.isEmpty()){
return null;
} else {
return result;
}
}
// findByGubun
@GetMapping("tour-information/findByNearby")
public List<TourInformationEntity> findByNearby(@RequestParam("lat") Double lat,
@RequestParam("lng") Double lng,
@RequestParam("dist") Double dist){
List<TourInformationEntity> result = tourInformationRepository.findByNearby(lat,lng,dist);
return result;
}
}