From c14ea1b7457346da54f15846ea44f4fb82885fdb Mon Sep 17 00:00:00 2001 From: GeunH Date: Mon, 20 Nov 2023 21:58:53 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20review=20Info=20dto=20=EB=B0=8F=20en?= =?UTF-8?q?tity=20=EA=B5=AC=ED=98=84=20#35?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../restaurant/entities/restaurant.entity.ts | 2 +- be/src/review/dto/reviewInfo.dto.ts | 56 +++++++++++++++++++ be/src/review/entities/review.entity.ts | 41 ++++++++++++++ be/src/review/review.module.ts | 4 ++ ...t.dot.ts => user.restaurantlist.entity.ts} | 14 ++--- 5 files changed, 109 insertions(+), 8 deletions(-) create mode 100644 be/src/review/dto/reviewInfo.dto.ts create mode 100644 be/src/review/entities/review.entity.ts create mode 100644 be/src/review/review.module.ts rename be/src/user/entities/{user.restaurantlist.dot.ts => user.restaurantlist.entity.ts} (64%) diff --git a/be/src/restaurant/entities/restaurant.entity.ts b/be/src/restaurant/entities/restaurant.entity.ts index 1c193212..e75141a1 100644 --- a/be/src/restaurant/entities/restaurant.entity.ts +++ b/be/src/restaurant/entities/restaurant.entity.ts @@ -14,7 +14,7 @@ export class RestaurantInfoEntity { srid: 4326, nullable: true }) - location: string | null; + location: string; @Column({ type: 'text', nullable: true }) address: string | null; diff --git a/be/src/review/dto/reviewInfo.dto.ts b/be/src/review/dto/reviewInfo.dto.ts new file mode 100644 index 00000000..f4d356d9 --- /dev/null +++ b/be/src/review/dto/reviewInfo.dto.ts @@ -0,0 +1,56 @@ +import { ApiProperty } from "@nestjs/swagger"; +import { + IsBoolean, + IsString, + IsNotEmpty, + IsInt, + MaxLength, + IsOptional, + MinLength +} from "class-validator"; + +export class ReviewInfoDto { + @ApiProperty({ + example: "true", + description: "The transportation for visiting", + }) + @IsBoolean() + @IsNotEmpty() + visitMethod: boolean; + + @ApiProperty({ example: "0", description: "transportation Accessibility for visiting" }) + @IsInt() + @IsOptional() + @MaxLength(1) + transportationAccessibility: number | null; + + @ApiProperty({ example: "0", description: "condition of the restaurant's parking area" }) + @IsInt() + @IsOptional() + @MaxLength(1) + parkingArea: number | null; + + @ApiProperty({ example: "0", description: "The taste of the food" }) + @IsInt() + @IsNotEmpty() + @MaxLength(1) + taste: number; + + @ApiProperty({ example: "0", description: "The service of the restaurant" }) + @IsInt() + @IsNotEmpty() + @MaxLength(1) + service: number; + + @ApiProperty({ example: "0", description: "The condition of the restaurant's restroom" }) + @IsInt() + @IsNotEmpty() + @MaxLength(1) + restroomtCleanliness: number; + + @ApiProperty({ example: "좋았음", description: "The overallExperience about the restaurant" }) + @IsString() + @IsNotEmpty() + @MinLength(20) + overallExperience: string; +} diff --git a/be/src/review/entities/review.entity.ts b/be/src/review/entities/review.entity.ts new file mode 100644 index 00000000..26521d13 --- /dev/null +++ b/be/src/review/entities/review.entity.ts @@ -0,0 +1,41 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn } from 'typeorm'; +import { User } from 'src/user/entities/user.entity'; +import { RestaurantInfoEntity } from 'src/restaurant/entities/restaurant.entity'; + +@Entity('review') +export class ReviewInfoEntity { + @PrimaryGeneratedColumn('increment') + id: number; + + @ManyToOne(() => User) + @JoinColumn({ name: 'user_id' }) + user: User; + + @ManyToOne(() => RestaurantInfoEntity) + @JoinColumn({ name: 'restaurant_id' }) + restaurant: RestaurantInfoEntity; + + @Column({ type: 'boolean' }) + visitMethod: boolean; + + @Column({ type: 'smallint', nullable: true }) + transportationAccessibility: number | null; + + @Column({ type: 'smallint', nullable: true }) + parkingArea: number | null; + + @Column({ type: 'smallint' }) + taste: number; + + @Column({ type: 'smallint' }) + service: number; + + @Column({ type: 'smallint' }) + restroomCleanliness: number; + + @Column({ type: 'text' }) + overallExperience: string; + + @CreateDateColumn({ name: 'created_at' }) + createdAt: Date; +} diff --git a/be/src/review/review.module.ts b/be/src/review/review.module.ts new file mode 100644 index 00000000..b3f019a1 --- /dev/null +++ b/be/src/review/review.module.ts @@ -0,0 +1,4 @@ +import { Module } from '@nestjs/common'; + +@Module({}) +export class ReviewModule {} diff --git a/be/src/user/entities/user.restaurantlist.dot.ts b/be/src/user/entities/user.restaurantlist.entity.ts similarity index 64% rename from be/src/user/entities/user.restaurantlist.dot.ts rename to be/src/user/entities/user.restaurantlist.entity.ts index 4bb78e49..f19b859e 100644 --- a/be/src/user/entities/user.restaurantlist.dot.ts +++ b/be/src/user/entities/user.restaurantlist.entity.ts @@ -7,22 +7,22 @@ import { PrimaryColumn, } from 'typeorm'; import { User } from './user.entity'; -import { Restaurant } from 'src/restaurant/entities/restaurant.entity'; -import { Review } from 'src/review/entities/review.entity'; +import { RestaurantInfoEntity } from 'src/restaurant/entities/restaurant.entity'; +import { ReviewInfoEntity } from 'src/review/entities/review.entity'; @Entity('user_restaurant_lists') export class UserRestaurantListEntity { @ManyToOne(() => User) @PrimaryColumn({ name: 'user_id' }) - userId: User; + userId: number; - @ManyToOne(() => Restaurant) + @ManyToOne(() => RestaurantInfoEntity) @PrimaryColumn({ name: 'restaurant_id' }) - restaurantId: Restaurant; + restaurantId: number; - @ManyToOne(() => Review) + @ManyToOne(() => ReviewInfoEntity) @JoinColumn({ name: 'review_id' }) - reviewId: Review; + reviewId: ReviewInfoEntity; @CreateDateColumn({ name: 'created_at', type: 'timestamp' }) createdAt: Date;