Skip to content

Commit

Permalink
feat : review Info dto 및 entity 구현 #33
Browse files Browse the repository at this point in the history
  • Loading branch information
GeunH committed Nov 20, 2023
1 parent d43f31c commit 6237f99
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 8 deletions.
2 changes: 1 addition & 1 deletion be/src/restaurant/entities/restaurant.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class RestaurantInfoEntity {
srid: 4326,
nullable: true
})
location: string | null;
location: string;

@Column({ type: 'text', nullable: true })
address: string | null;
Expand Down
56 changes: 56 additions & 0 deletions be/src/review/dto/reviewInfo.dto.ts
Original file line number Diff line number Diff line change
@@ -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;
}
41 changes: 41 additions & 0 deletions be/src/review/entities/review.entity.ts
Original file line number Diff line number Diff line change
@@ -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;
}
4 changes: 4 additions & 0 deletions be/src/review/review.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Module } from '@nestjs/common';

@Module({})
export class ReviewModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6237f99

Please sign in to comment.