-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
554 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.drugbox.controller; | ||
|
||
import com.drugbox.dto.request.CoordRequest; | ||
import com.drugbox.dto.response.BinLocationResponse; | ||
import com.drugbox.dto.response.MapDetailResponse; | ||
import com.drugbox.dto.response.MapResponse; | ||
import com.drugbox.service.MapService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.json.simple.parser.ParseException; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@RequestMapping("maps") | ||
public class MapController { | ||
private final MapService mapService; | ||
|
||
@PostMapping("/seoul/save") | ||
public ResponseEntity<Void> saveSeoulDrugBinLocations() { | ||
mapService.saveSeoulDrugBinLocations(); | ||
return new ResponseEntity(HttpStatus.OK); | ||
} | ||
|
||
@PostMapping("/division/save") | ||
public ResponseEntity<Void> saveDrugBinLocations() { | ||
mapService.saveDrugBinLocations(); | ||
return new ResponseEntity(HttpStatus.OK); | ||
} | ||
|
||
@GetMapping("/seoul") | ||
public ResponseEntity<List<BinLocationResponse>> getSeoulDrugBinLocations(){ | ||
List<BinLocationResponse> response = mapService.getSeoulDrugBinLocations(); | ||
return ResponseEntity.status(HttpStatus.OK).body(response); | ||
} | ||
|
||
@GetMapping("/division") | ||
public ResponseEntity<List<BinLocationResponse>> getDivisionDrugBinLocations( | ||
@RequestParam(value="addrLvl1") String addrLvl1, | ||
@RequestParam(value="addrLvl2", required = false) String addrLvl2){ | ||
List<BinLocationResponse> response = mapService.getDivisionDrugBinLocations(addrLvl1, addrLvl2); | ||
return ResponseEntity.status(HttpStatus.OK).body(response); | ||
} | ||
|
||
@GetMapping("/nearby") | ||
public ResponseEntity<List<MapResponse>> getNearbyPharmacyAndConvenienceLocations( | ||
@ModelAttribute CoordRequest coordRequest) throws IOException, ParseException { | ||
List<MapResponse> response = mapService.getNearbyPharmacyAndConvenienceLocations(coordRequest); | ||
return ResponseEntity.status(HttpStatus.OK).body(response); | ||
} | ||
|
||
@GetMapping("/search") | ||
public ResponseEntity<List<MapResponse>> searchLocations(@RequestParam String name) throws IOException, ParseException { | ||
List<MapResponse> responses = mapService.searchLocations(name); | ||
return ResponseEntity.status(HttpStatus.OK).body(responses); | ||
} | ||
|
||
@GetMapping("/detail") | ||
public ResponseEntity<MapDetailResponse> getLocationDetail(@RequestParam String id) throws IOException, ParseException { | ||
MapDetailResponse response = mapService.searchLocationDetail(id); | ||
return ResponseEntity.status(HttpStatus.OK).body(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.drugbox.domain; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Embeddable; | ||
import java.io.Serializable; | ||
|
||
@Embeddable | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@EqualsAndHashCode | ||
@Data | ||
public class BinId implements Serializable { | ||
@Column(name = "bin_id") | ||
private Long binId; | ||
@Column(name = "division_key") | ||
private Integer divisionKey; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.drugbox.domain; | ||
|
||
import com.drugbox.common.entity.BaseEntity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import javax.persistence.*; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class BinLocation extends BaseEntity { | ||
|
||
@EmbeddedId | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "binlocation_id") | ||
private BinId id; | ||
|
||
@Column(nullable = false) | ||
private String lat; | ||
@Column(nullable = false) | ||
private String lng; | ||
@Column(nullable = false) | ||
private String address; | ||
private String addrLvl1; // 시,도 | ||
private String addrLvl2; // 시,군,구 | ||
private String detail; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.drugbox.dto.request; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Builder | ||
public class CoordRequest { | ||
private String latitude; | ||
private String longitude; | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
src/main/java/com/drugbox/dto/response/BinLocationResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.drugbox.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
|
||
@Getter | ||
@Builder | ||
public class BinLocationResponse { | ||
private Long id; | ||
private String lat; | ||
private String lng; | ||
private String address; | ||
private String addrLvl1; // 시,도 | ||
private String addrLvl2; // 시,군,구 | ||
private String detail; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/com/drugbox/dto/response/MapDetailResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.drugbox.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class MapDetailResponse { | ||
private String locationName; | ||
private String locationId; | ||
private String locationPhotos; | ||
private String formattedAddress; | ||
private String currentOpeningHours; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.drugbox.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class MapResponse { | ||
private String locationName; | ||
private String locationAddress; | ||
private String locationId; | ||
private String latitude; | ||
private String longitude; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/com/drugbox/repository/BinLocationRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.drugbox.repository; | ||
|
||
import com.drugbox.domain.BinLocation; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.util.List; | ||
|
||
public interface BinLocationRepository extends JpaRepository<BinLocation, Long> { | ||
List<BinLocation> findAllByAddrLvl1AndAddrLvl2(String addrLvl1, String addrLvl2); | ||
List<BinLocation> findAllByAddrLvl1(String addrLvl1); | ||
} |
Oops, something went wrong.