Skip to content

Commit

Permalink
style : prettier 적용 #35
Browse files Browse the repository at this point in the history
Co-authored-by: GeunH <[email protected]>
  • Loading branch information
LeeTH916 and GeunH committed Nov 28, 2023
1 parent f5c0026 commit eade072
Show file tree
Hide file tree
Showing 20 changed files with 627 additions and 359 deletions.
25 changes: 11 additions & 14 deletions be/src/restaurant/dto/filterInfo.dto.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { LocationDto } from "./location.dto";

export class FilterInfoDto {
filter: string;
filter: string;

latitude: number;
latitude: number;

longitude: number;
longitude: number;

radius: number;
radius: number;

constructor(
filter: string,
location: LocationDto
) {
this.filter = filter;
this.latitude = location.latitude ? parseFloat(location.latitude) : null;
this.longitude = location.longitude ? parseFloat(location.longitude) : null;
this.radius = location.radius ? parseInt(location.radius) : 500000;
}
}
constructor(filter: string, location: LocationDto) {
this.filter = filter;
this.latitude = location.latitude ? parseFloat(location.latitude) : null;
this.longitude = location.longitude ? parseFloat(location.longitude) : null;
this.radius = location.radius ? parseInt(location.radius) : 500000;
}
}
22 changes: 11 additions & 11 deletions be/src/restaurant/dto/location.dto.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { IsString, IsNumberString, IsOptional } from 'class-validator';
import { IsString, IsNumberString, IsOptional } from "class-validator";

export class LocationDto {
@IsNumberString({}, { message: 'Latitude must be a valid number.' })
@IsOptional()
latitude: string;
@IsNumberString({}, { message: "Latitude must be a valid number." })
@IsOptional()
latitude: string;

@IsNumberString({}, { message: 'Longitude must be a valid number.' })
@IsOptional()
longitude: string;
@IsNumberString({}, { message: "Longitude must be a valid number." })
@IsOptional()
longitude: string;

@IsNumberString({}, { message: 'Radius must be a valid number.' })
@IsOptional()
radius: string;
}
@IsNumberString({}, { message: "Radius must be a valid number." })
@IsOptional()
radius: string;
}
25 changes: 11 additions & 14 deletions be/src/restaurant/dto/seachInfo.dto.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { LocationDto } from "./location.dto";

export class SearchInfoDto {
partialName: string;
partialName: string;

latitude: number;
latitude: number;

longitude: number;
longitude: number;

radius: number;
radius: number;

constructor(
partialName: string,
location: LocationDto
) {
this.partialName = partialName;
this.latitude = location.latitude ? parseFloat(location.latitude) : null;
this.longitude = location.longitude ? parseFloat(location.longitude) : null;
this.radius = location.radius ? parseInt(location.radius) : 500000;
}
}
constructor(partialName: string, location: LocationDto) {
this.partialName = partialName;
this.latitude = location.latitude ? parseFloat(location.latitude) : null;
this.longitude = location.longitude ? parseFloat(location.longitude) : null;
this.radius = location.radius ? parseInt(location.radius) : 500000;
}
}
13 changes: 8 additions & 5 deletions be/src/restaurant/entities/restaurant.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ export class RestaurantInfoEntity {
@UpdateDateColumn({ name: "updated_at" })
updatedAt: Date;

@OneToMany(() => UserRestaurantListEntity, userRestaurant => userRestaurant.restaurant)
userRestaurant: UserRestaurantListEntity

@OneToMany(() => ReviewInfoEntity, review => review.restaurant)
review: ReviewInfoEntity
@OneToMany(
() => UserRestaurantListEntity,
(userRestaurant) => userRestaurant.restaurant
)
userRestaurant: UserRestaurantListEntity;

@OneToMany(() => ReviewInfoEntity, (review) => review.restaurant)
review: ReviewInfoEntity;
}
125 changes: 103 additions & 22 deletions be/src/restaurant/restaurant.controller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { Controller, Get, Param, Query, UseGuards, UsePipes, ValidationPipe } from "@nestjs/common";
import {
Controller,
Get,
Param,
Query,
UseGuards,
UsePipes,
ValidationPipe,
} from "@nestjs/common";
import { AuthGuard } from "@nestjs/passport";
import { ApiBearerAuth, ApiOperation, ApiParam, ApiQuery, ApiResponse } from "@nestjs/swagger";
import {
ApiBearerAuth,
ApiOperation,
ApiParam,
ApiQuery,
ApiResponse,
} from "@nestjs/swagger";
import { RestaurantService } from "./restaurant.service";
import { SearchInfoDto } from "./dto/seachInfo.dto";
import { FilterInfoDto } from "./dto/filterInfo.dto";
Expand All @@ -14,10 +28,30 @@ export class RestaurantController {
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
@ApiOperation({ summary: "음식점 검색 자동완성" })
@ApiParam({ name: 'partialRestaurantName', required: true, type: String, description: '부분 음식점 이름' })
@ApiQuery({ name: 'latitude', required: false, type: String, description: '위도' })
@ApiQuery({ name: 'longitude', required: false, type: String, description: '경도' })
@ApiQuery({ name: 'radius', required: false, type: String, description: '검색 반경' })
@ApiParam({
name: "partialRestaurantName",
required: true,
type: String,
description: "부분 음식점 이름",
})
@ApiQuery({
name: "latitude",
required: false,
type: String,
description: "위도",
})
@ApiQuery({
name: "longitude",
required: false,
type: String,
description: "경도",
})
@ApiQuery({
name: "radius",
required: false,
type: String,
description: "검색 반경",
})
@ApiResponse({
status: 200,
description: "음식점 검색 성공",
Expand All @@ -28,7 +62,7 @@ export class RestaurantController {
searchRestaurant(
@GetUser() tokenInfo: TokenInfo,
@Query() locationDto: LocationDto,
@Param('partialRestaurantName') partialName: string
@Param("partialRestaurantName") partialName: string
) {
const searchInfoDto = new SearchInfoDto(partialName, locationDto);
return this.restaurantService.searchRestaurant(searchInfoDto, tokenInfo);
Expand All @@ -46,7 +80,7 @@ export class RestaurantController {
@ApiResponse({ status: 404, description: "존재하지 않는 음식점" })
detailInfo(
@GetUser() tokenInfo: TokenInfo,
@Param("restaurantId") restaurantId: string,
@Param("restaurantId") restaurantId: string
) {
return this.restaurantService.detailInfo(parseInt(restaurantId), tokenInfo);
}
Expand All @@ -55,43 +89,90 @@ export class RestaurantController {
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
@ApiOperation({ summary: "필터링된 음식점 리스트 응답" })
@ApiQuery({ name: 'filter', required: true, type: String, description: '팔로우한 유저의 nickName' })
@ApiQuery({ name: 'latitude', required: false, type: String, description: '위도' })
@ApiQuery({ name: 'longitude', required: false, type: String, description: '경도' })
@ApiQuery({ name: 'radius', required: false, type: String, description: '검색 반경' })
@ApiQuery({
name: "filter",
required: true,
type: String,
description: "팔로우한 유저의 nickName",
})
@ApiQuery({
name: "latitude",
required: false,
type: String,
description: "위도",
})
@ApiQuery({
name: "longitude",
required: false,
type: String,
description: "경도",
})
@ApiQuery({
name: "radius",
required: false,
type: String,
description: "검색 반경",
})
@ApiResponse({
status: 200,
description: "필터링된 음식점 리스트 요청 성공",
})
@ApiResponse({ status: 401, description: "인증 실패" })
@ApiResponse({ status: 400, description: "쿼리파라미터 형식이 올바르지 않음" })
@ApiResponse({ status: 404, description: "존재하지 않는 필터(유저 닉네임)를 요청" })
@ApiResponse({
status: 400,
description: "쿼리파라미터 형식이 올바르지 않음",
})
@ApiResponse({
status: 404,
description: "존재하지 않는 필터(유저 닉네임)를 요청",
})
@UsePipes(new ValidationPipe())
filteredRestaurantList(
@GetUser() tokenInfo: TokenInfo,
@Query() locationDto: LocationDto,
@Query('filter') filter: string
@Query("filter") filter: string
) {
const filterInfoDto = new FilterInfoDto(filter, locationDto);
return this.restaurantService.filteredRestaurantList(filterInfoDto, tokenInfo);
return this.restaurantService.filteredRestaurantList(
filterInfoDto,
tokenInfo
);
}
@Get('all')
@Get("all")
@UseGuards(AuthGuard("jwt"))
@ApiBearerAuth()
@ApiOperation({ summary: "현위치 기반 반경 내의 전체 음식점 리스트 응답" })
@ApiQuery({ name: 'latitude', required: true, type: String, description: '위도' })
@ApiQuery({ name: 'longitude', required: true, type: String, description: '경도' })
@ApiQuery({ name: 'radius', required: true, type: String, description: '검색 반경' })
@ApiQuery({
name: "latitude",
required: true,
type: String,
description: "위도",
})
@ApiQuery({
name: "longitude",
required: true,
type: String,
description: "경도",
})
@ApiQuery({
name: "radius",
required: true,
type: String,
description: "검색 반경",
})
@ApiResponse({
status: 200,
description: "전체 음식점 리스트 요청 성공",
})
@ApiResponse({ status: 401, description: "인증 실패" })
@ApiResponse({ status: 400, description: "쿼리파라미터 형식이 올바르지 않음" })
@ApiResponse({
status: 400,
description: "쿼리파라미터 형식이 올바르지 않음",
})
@UsePipes(new ValidationPipe())
entireRestaurantList(
@GetUser() tokenInfo: TokenInfo,
@Query() locationDto: LocationDto,
@Query() locationDto: LocationDto
) {
return this.restaurantService.entireRestaurantList(locationDto, tokenInfo);
}
Expand Down
Loading

0 comments on commit eade072

Please sign in to comment.