Skip to content

Commit

Permalink
Merge pull request #94 from Korea-Certified-Store/feature/fix-api-ver…
Browse files Browse the repository at this point in the history
…sioning(#93)

API Versioning 방식 변경 (#93)
  • Loading branch information
sungjindev authored Feb 9, 2024
2 parents 1aa1cc9 + e9bcdf7 commit cf4e681
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/main/java/com/nainga/nainga/domain/store/api/StoreApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class StoreApi {
@Hidden
@Tag(name = "초기 Data 생성")
@Operation(summary = "모범음식점 데이터 생성", description = "[WARNING] DB에 처음으로 모든 모범음식점 데이터를 주입해주는 API입니다. DB에 엄청난 부하가 가는 작업으로, 합의 없이 실행시켜선 안됩니다!")
@GetMapping("api/v1/store/mobeom")
@GetMapping("api/store/mobeom/v1")
public Result<String> createAllMobeomStores(@RequestParam(value = "fileName") String fileName) {
mobeomGoogleMapStoreService.createAllMobeomStores(fileName);
return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, null);
Expand All @@ -34,7 +34,7 @@ public Result<String> createAllMobeomStores(@RequestParam(value = "fileName") St
@Hidden
@Tag(name = "초기 Data 생성")
@Operation(summary = "지정한 Credit까지만 사용하여 모범음식점 데이터 생성", description = "[WARNING] 지정한 Credit까지만 사용하여 그동안 DB에 모범음식점 데이터를 주입해주는 API입니다. DB에 엄청난 부하가 가는 작업으로, 합의 없이 실행시켜선 안됩니다!")
@GetMapping("api/v1/store/dividedMobeom")
@GetMapping("api/store/dividedMobeom/v1")
public Result<CreateDividedMobeomStoresResponse> createDividedMobeomStores(@RequestParam(value = "fileName") String fileName, @RequestParam(value = "dollars") double dollars, @RequestParam(value = "startIndex") int startIndex) {
CreateDividedMobeomStoresResponse response = mobeomGoogleMapStoreService.createDividedMobeomStores(fileName, dollars, startIndex);
System.out.println("response = " + response); //편하게 콘솔 로그에서 확인하기 위한 용도
Expand All @@ -44,7 +44,7 @@ public Result<CreateDividedMobeomStoresResponse> createDividedMobeomStores(@Requ
@Hidden
@Tag(name = "초기 Data 생성")
@Operation(summary = "안심식당 데이터 생성", description = "[WARNING] DB에 처음으로 모든 안심식당 데이터를 주입해주는 API입니다. DB에 엄청난 부하가 가는 작업으로, 합의 없이 실행시켜선 안됩니다!")
@GetMapping("api/v1/store/safe")
@GetMapping("api/store/safe/v1")
public Result<String> createAllSafeStores(@RequestParam(value = "fileName") String fileName) {
safeGoogleMapStoreService.createAllSafeStores(fileName);
return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, null);
Expand All @@ -53,7 +53,7 @@ public Result<String> createAllSafeStores(@RequestParam(value = "fileName") Stri
@Hidden
@Tag(name = "초기 Data 생성")
@Operation(summary = "지정한 Credit까지만 사용하여 안심식당 데이터 생성", description = "[WARNING] 지정한 Credit까지만 사용하여 그동안 DB에 안심식당 데이터를 주입해주는 API입니다. DB에 엄청난 부하가 가는 작업으로, 합의 없이 실행시켜선 안됩니다!")
@GetMapping("api/v1/store/dividedSafe")
@GetMapping("api/store/dividedSafe/v1")
public Result<CreateDividedSafeStoresResponse> createDividedSafeStores(@RequestParam(value = "fileName") String fileName, @RequestParam(value = "dollars") double dollars, @RequestParam(value = "startIndex") int startIndex) {
CreateDividedSafeStoresResponse response = safeGoogleMapStoreService.createDividedSafeStores(fileName, dollars, startIndex);
System.out.println("response = " + response); //편하게 콘솔 로그에서 확인하기 위한 용도
Expand All @@ -63,7 +63,7 @@ public Result<CreateDividedSafeStoresResponse> createDividedSafeStores(@RequestP
@Hidden
@Tag(name = "초기 Data 생성")
@Operation(summary = "착한가격업소 데이터 생성", description = "[WARNING] DB에 처음으로 모든 착한가격업소 데이터를 주입해주는 API입니다. DB에 엄청난 부하가 가는 작업으로, 합의 없이 실행시켜선 안됩니다!")
@GetMapping("api/v1/store/goodPrice")
@GetMapping("api/store/goodPrice/v1")
public Result<String> createAllGoodPriceStores(@RequestParam(value = "fileName") String fileName) {
goodPriceGoogleMapStoreService.createAllGoodPriceStores(fileName);
return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, null);
Expand All @@ -72,7 +72,7 @@ public Result<String> createAllGoodPriceStores(@RequestParam(value = "fileName")
@Hidden
@Tag(name = "초기 Data 생성")
@Operation(summary = "지정한 Credit까지만 사용하여 착한가격업소 데이터 생성", description = "[WARNING] 지정한 Credit까지만 사용하여 그동안 DB에 착한가격업소 데이터를 주입해주는 API입니다. DB에 엄청난 부하가 가는 작업으로, 합의 없이 실행시켜선 안됩니다!")
@GetMapping("api/v1/store/dividedGoodPrice")
@GetMapping("api/store/dividedGoodPrice/v1")
public Result<CreateDividedGoodPriceStoresResponse> createDividedGoodPriceStores(@RequestParam(value = "fileName") String fileName, @RequestParam(value = "dollars") double dollars, @RequestParam(value = "startIndex") int startIndex) {
CreateDividedGoodPriceStoresResponse response = goodPriceGoogleMapStoreService.createDividedGoodPriceStores(fileName, dollars, startIndex);
System.out.println("response = " + response); //편하게 콘솔 로그에서 확인하기 위한 용도
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class StoreCertificationApi {
private final StoreCertificationService storeCertificationService;

//총 사각형 영역의 네 꼭짓점 좌표를 받아, 해당 가게들의 상세 정보를 반환
@Tag(name = "가게 상세 정보")
@Tag(name = "[Legacy] 가게 상세 정보")
@Operation(summary = "사용자 위치 기반 가게 상세 정보 제공 V1", description = "총 사각형 영역의 네 꼭짓점 좌표를 받아 해당 가게들의 상세 정보를 반환해줍니다.<br><br>" +
"[Request Body]<br>" +
"nwLong: 북서쪽 좌표 경도<br>" +
Expand All @@ -44,7 +44,7 @@ public class StoreCertificationApi {
"certificationName: 가게의 인증제 목록<br>" +
"=> 각 인증제별 순서는 보장되지 않습니다.")
@GetMapping("api/v1/storecertification/byLocation")
public Result<List<StoreCertificationsByLocationResponse>> findStoreCertificationsByLocation(@RequestParam("nwLong") double nwLong, @RequestParam("nwLat") double nwLat, @RequestParam("swLong") double swLong, @RequestParam("swLat") double swLat, @RequestParam("seLong") double seLong, @RequestParam("seLat") double seLat, @RequestParam("neLong") double neLong, @RequestParam("neLat") double neLat) {
public Result<List<StoreCertificationsByLocationResponse>> findStoreCertificationsByLocationLegacy(@RequestParam("nwLong") double nwLong, @RequestParam("nwLat") double nwLat, @RequestParam("swLong") double swLong, @RequestParam("swLat") double swLat, @RequestParam("seLong") double seLong, @RequestParam("seLat") double seLat, @RequestParam("neLong") double neLong, @RequestParam("neLat") double neLat) {
List<StoreCertification> storeCertificationsByLocation = storeCertificationService.findStoreCertificationsByLocation(new Location(nwLong, nwLat), new Location(swLong, swLat), new Location(seLong, seLat), new Location(neLong, neLat));
List<Long> storeIdsWithMultipleCertifications = storeCertificationService.getDuplicatedStoreIds(); //여러 인증제를 가지고 있는 가게의 id 리스트
List<StoreCertificationsByLocationResponse> storeCertificationsByLocationResponses = new ArrayList<>(); //반환해줄 StoreCertificationsByLocationResponse들의 List
Expand All @@ -71,7 +71,7 @@ public Result<List<StoreCertificationsByLocationResponse>> findStoreCertificatio
}

//총 사각형 영역의 네 꼭짓점 좌표를 받아 최대 75개를 랜덤하게 뽑아낸 뒤, 해당 가게들의 상세 정보를 반환
@Tag(name = "가게 상세 정보")
@Tag(name = "[Legacy] 가게 상세 정보")
@Operation(summary = "사용자 위치 기반 가게 상세 정보 제공 V2", description = "총 사각형 영역의 네 꼭짓점 좌표를 받아 최대 75개를 랜덤하게 뽑아낸 뒤, 해당 가게들의 상세 정보를 반환해줍니다.<br><br>" +
"[Request Body]<br>" +
"nwLong: 북서쪽 좌표 경도<br>" +
Expand All @@ -91,13 +91,13 @@ public Result<List<StoreCertificationsByLocationResponse>> findStoreCertificatio
"certificationName: 가게의 인증제 목록<br>" +
"=> 각 인증제별 순서는 보장되지 않습니다.")
@GetMapping("api/v2/storecertification/byLocation")
public Result<List<List<StoreCertificationsByLocationResponse>>> findStoreCertificationsByLocationRandomly(@RequestParam("nwLong") double nwLong, @RequestParam("nwLat") double nwLat, @RequestParam("swLong") double swLong, @RequestParam("swLat") double swLat, @RequestParam("seLong") double seLong, @RequestParam("seLat") double seLat, @RequestParam("neLong") double neLong, @RequestParam("neLat") double neLat) {
public Result<List<List<StoreCertificationsByLocationResponse>>> findStoreCertificationsByLocationRandomlyLegacy(@RequestParam("nwLong") double nwLong, @RequestParam("nwLat") double nwLat, @RequestParam("swLong") double swLong, @RequestParam("swLat") double swLat, @RequestParam("seLong") double seLong, @RequestParam("seLat") double seLat, @RequestParam("neLong") double neLong, @RequestParam("neLat") double neLat) {
List<List<StoreCertificationsByLocationResponse>> storeCertificationsByLocationRandomly = storeCertificationService.findStoreCertificationsByLocationRandomly(new Location(nwLong, nwLat), new Location(swLong, swLat), new Location(seLong, seLat), new Location(neLong, neLat));
return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, storeCertificationsByLocationRandomly);
}

//검색어를 이용해 가게 이름, 업종, 주소에 대해 검색하고 나온 검색 결과 중 사용자로부터 가까운 순으로 최대 30개의 가게 정보를 리턴
@Tag(name = "가게 상세 정보")
@Tag(name = "[Legacy] 가게 상세 정보")
@Operation(summary = "사용자 위치 및 검색어 기반 가게 상세 정보 제공", description = "현재 사용자의 위치 좌표와 검색 키워드를 전달받아 가게 DB에서 검색한 뒤, 사용자와 가까운 순으로 최대 30개의 가게 상세 정보를 반환해줍니다.<br><br>" +
"[Request Body]<br>" +
"currLong: 현재 사용자의 위치 좌표 경도값<br>" +
Expand All @@ -116,8 +116,65 @@ public Result<List<List<StoreCertificationsByLocationResponse>>> findStoreCertif
"certificationName: 가게의 인증제 목록<br>" +
"=> 각 인증제별 순서는 보장되지 않습니다.")
@GetMapping("api/v1/storecertification/byLocationAndKeyword")
public Result<List<StoreCertificationsByLocationResponse>> searchStoreCertificationsByLocationAndKeywordLegacy(@RequestParam("currLong") double currLong, @RequestParam("currLat") double currLat, @RequestParam("searchKeyword") String searchKeyword) {
List<StoreCertificationsByLocationResponse> storeCertificationsByLocationAndKeyword = storeCertificationService.searchStoreCertificationsByLocationAndKeyword(currLong, currLat, searchKeyword);
return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, storeCertificationsByLocationAndKeyword);
}

/*
이 이하로는 모두 새로운 API Versioning 적용! Version이 URI에서 제일 뒤에 가도록 변경하였습니다.
한 동안은 전 API Versioning 방식과 후 API Versioning 방식 모두 유지시키고 나중에는 최근 API Versioning 방식만 남겨둘 계획입니다.
*/

//총 사각형 영역의 네 꼭짓점 좌표를 받아 최대 75개를 랜덤하게 뽑아낸 뒤, 해당 가게들의 상세 정보를 반환
@Tag(name = "[New] 가게 상세 정보")
@Operation(summary = "사용자 위치 기반 가게 상세 정보 제공 V2", description = "총 사각형 영역의 네 꼭짓점 좌표를 받아 최대 75개를 랜덤하게 뽑아낸 뒤, 해당 가게들의 상세 정보를 반환해줍니다.<br><br>" +
"[Request Body]<br>" +
"nwLong: 북서쪽 좌표 경도<br>" +
"nwLat: 북서쪽 좌표 위도<br>" +
"seLong: 남동쪽 좌표 경도<br>" +
"seLat: 남동쪽 좌표 위도<br><br>" +
"[Response Body]<br>" +
"id: Database 내 Primary Key값<br>" +
"displayName: 가게 이름<br>" +
"primaryTypeDisplayName: 업종<br>" +
"formattedAddress: 주소<br>" +
"phoneNumber: 전화번호<br>" +
"location: (경도, 위도) 가게 좌표<br>" +
"regularOpeningHours: 영업 시간<br>" +
"=> 특정 요일이 휴무인 경우에는 해당 요일에 대한 데이터가 들어있지 않습니다. Break time이 있는 경우 동일한 요일에 대해 영업 시간 데이터가 여러 개 존재할 수 있습니다. <br>" +
"localPhotos: 저장된 가게 사진 URL<br>" +
"certificationName: 가게의 인증제 목록<br>" +
"=> 각 인증제별 순서는 보장되지 않습니다.")
@GetMapping("api/storecertification/byLocation/v2")
public Result<List<List<StoreCertificationsByLocationResponse>>> findStoreCertificationsByLocationRandomly(@RequestParam("nwLong") double nwLong, @RequestParam("nwLat") double nwLat, @RequestParam("swLong") double swLong, @RequestParam("swLat") double swLat, @RequestParam("seLong") double seLong, @RequestParam("seLat") double seLat, @RequestParam("neLong") double neLong, @RequestParam("neLat") double neLat) {
List<List<StoreCertificationsByLocationResponse>> storeCertificationsByLocationRandomly = storeCertificationService.findStoreCertificationsByLocationRandomly(new Location(nwLong, nwLat), new Location(swLong, swLat), new Location(seLong, seLat), new Location(neLong, neLat));
return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, storeCertificationsByLocationRandomly);
}

//검색어를 이용해 가게 이름, 업종, 주소에 대해 검색하고 나온 검색 결과 중 사용자로부터 가까운 순으로 최대 30개의 가게 정보를 리턴
@Tag(name = "[New] 가게 상세 정보")
@Operation(summary = "사용자 위치 및 검색어 기반 가게 상세 정보 제공", description = "현재 사용자의 위치 좌표와 검색 키워드를 전달받아 가게 DB에서 검색한 뒤, 사용자와 가까운 순으로 최대 30개의 가게 상세 정보를 반환해줍니다.<br><br>" +
"[Request Body]<br>" +
"currLong: 현재 사용자의 위치 좌표 경도값<br>" +
"currLat: 현재 사용자의 위치 좌표 위도값<br>" +
"searchKeyword: 검색할 키워드<br><br>" +
"[Response Body]<br>" +
"id: Database 내 Primary Key값<br>" +
"displayName: 가게 이름<br>" +
"primaryTypeDisplayName: 업종<br>" +
"formattedAddress: 주소<br>" +
"phoneNumber: 전화번호<br>" +
"location: (경도, 위도) 가게 좌표<br>" +
"regularOpeningHours: 영업 시간<br>" +
"=> 특정 요일이 휴무인 경우에는 해당 요일에 대한 데이터가 들어있지 않습니다. Break time이 있는 경우 동일한 요일에 대해 영업 시간 데이터가 여러 개 존재할 수 있습니다. <br>" +
"localPhotos: 저장된 가게 사진 URL<br>" +
"certificationName: 가게의 인증제 목록<br>" +
"=> 각 인증제별 순서는 보장되지 않습니다.")
@GetMapping("api/storecertification/byLocationAndKeyword/v1")
public Result<List<StoreCertificationsByLocationResponse>> searchStoreCertificationsByLocationAndKeyword(@RequestParam("currLong") double currLong, @RequestParam("currLat") double currLat, @RequestParam("searchKeyword") String searchKeyword) {
List<StoreCertificationsByLocationResponse> storeCertificationsByLocationAndKeyword = storeCertificationService.searchStoreCertificationsByLocationAndKeyword(currLong, currLat, searchKeyword);
return new Result<>(Result.CODE_SUCCESS, Result.MESSAGE_OK, storeCertificationsByLocationAndKeyword);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public OpenAPI customOpenAPI() {
"참고로 Swagger 상에서는 Base URL이 달라 테스트가 불가능합니다.<br>" +
"만약 테스트를 원하신다면 브라우저 상에서 직접 URL을 입력해주시면 됩니다.<br>" +
"예) https://storage.googleapis.com/kcs-dev-bucket1/ad06294c-d4ed-42bd-9839-82af8714bd1e")
.tags(List.of("가게 상세 정보"))
.tags(List.of("[New] 가게 상세 정보"))
.responses(new ApiResponses().addApiResponse("200",
new ApiResponse().description("OK")
.content(new Content().addMediaType("image/jpeg", new MediaType()
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/backend-submodule

0 comments on commit cf4e681

Please sign in to comment.