Skip to content

Commit

Permalink
feat : 음식점 상세 정보 응답 구현 #68
Browse files Browse the repository at this point in the history
- 전달받은 음식점 id를 이용하여 해당 음식점에 대한 상세 정보 조회
- 조회할 때 필요 컬럼만 받아서 전달
- todo: 맛집리스트 추가 여부, 리뷰 목록 추가
  • Loading branch information
LeeTH916 committed Nov 23, 2023
1 parent fb8f696 commit 79de23e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
16 changes: 16 additions & 0 deletions be/src/restaurant/restaurant.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,20 @@ export class RestaurantController {
const searchInfoDto = new SearchInfoDto(partialName, location, radius);
return this.restaurantService.searchRestaurant(searchInfoDto);
}

@Get(":restaurantId/details")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
@ApiOperation({ summary: "음식점 상세 페이지" })
@ApiResponse({
status: 200,
description: "음식점 상세 페이지 요청 성공",
})
@ApiResponse({ status: 401, description: "인증 실패" })
@ApiResponse({ status: 404, description: "존재하지 않는 음식점" })
detailInfo(
@Param("restaurantId") restaurantId: string,
) {
return this.restaurantService.detailInfo(parseInt(restaurantId));
}
}
9 changes: 8 additions & 1 deletion be/src/restaurant/restaurant.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class RestaurantRepository extends Repository<RestaurantInfoEntity> {

async searchRestarant(searchInfoDto: SearchInfoDto) {
const rawQuery = `
SELECT * FROM (
SELECT id, name, location, address, "phoneNumber", "reviewCnt", category, distance FROM (
SELECT *,
ST_DistanceSphere(
location,
Expand All @@ -26,6 +26,13 @@ export class RestaurantRepository extends Repository<RestaurantInfoEntity> {
return this.query(rawQuery)
}

async detailInfo(restaurantId: number){
return this.findOne({
select: ['id', 'name', 'location', 'address', 'phoneNumber', 'reviewCnt', 'category'],
where: {id: restaurantId}
})
}

async updateRestaurantsFromSeoulData(data: RestaurantInfoEntity[]) {
const uniqueData = Array.from(
new Map(
Expand Down
4 changes: 4 additions & 0 deletions be/src/restaurant/restaurant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export class RestaurantService implements OnModuleInit {
return this.restaurantRepository.searchRestarant(searchInfoDto);
}

async detailInfo(restaurantId: number){
return this.restaurantRepository.detailInfo(restaurantId);
}

async getRestaurantsListFromSeoulData(startPage) {
const tm2097 =
"+proj=tmerc +lat_0=38 +lon_0=127.0028902777778 +k=1 +x_0=200000 +y_0=500000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43";
Expand Down

0 comments on commit 79de23e

Please sign in to comment.