Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Global/be] 모든 테이블 dto, entity 구현 #80

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion be/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { UserModule } from "./user/user.module";
import { TypeOrmModule } from "@nestjs/typeorm";
import { typeORMConfig } from "./configs/typeorm.config";
import { AuthModule } from "./auth/auth.module";
import { RestaurantModule } from './restaurant/restaurant.module';
import { ReviewModule } from './review/review.module';

@Module({
imports: [UserModule, TypeOrmModule.forRoot(typeORMConfig), AuthModule],
imports: [UserModule, TypeOrmModule.forRoot(typeORMConfig), AuthModule, RestaurantModule, ReviewModule],
})
export class AppModule {}
15 changes: 15 additions & 0 deletions be/src/restaurant/dto/restaurantInfo.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ApiProperty } from "@nestjs/swagger";
import {
IsNotEmpty,
IsInt,
} from "class-validator";

export class RestaurantInfoDto {
@ApiProperty({
example: "음식점 id",
description: "The id of the restaurant",
})
@IsInt()
@IsNotEmpty()
id: number;
}
39 changes: 39 additions & 0 deletions be/src/restaurant/entities/restaurant.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn } from 'typeorm';

@Entity('restaurant')
export class RestaurantInfoEntity {
@PrimaryGeneratedColumn('increment')
id: number;

@Column({ type: 'varchar', length: 100 })
name: string;

@Column({
type: 'geometry',
spatialFeatureType: 'Point',
srid: 4326,
nullable: true
})
location: string;

@Column({ type: 'text', nullable: true })
address: string | null;

@Column({ type: 'varchar', length: 20, nullable: true })
category: string | null;

@Column({ type: 'int', default: 0 })
reviewCnt: number;

@Column({ type: 'varchar', length: 20, nullable: true })
phoneNumber: string | null;

@CreateDateColumn({ name: 'created_at' })
createdAt: Date;

@Column({ name: 'deleted_at', type: 'timestamp', nullable: true })
deletedAt: Date | null;

@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date;
}
4 changes: 4 additions & 0 deletions be/src/restaurant/restaurant.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Module } from '@nestjs/common';

@Module({})
export class RestaurantModule {}
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 {}
27 changes: 27 additions & 0 deletions be/src/user/entities/user.followList.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {
Entity,
PrimaryColumn,
CreateDateColumn,
DeleteDateColumn,
ManyToOne,
JoinColumn
} from 'typeorm';
import { User } from './user.entity';

@Entity('follow')
export class FollowEntity {
@ManyToOne(() => User)
@PrimaryColumn({ name: 'following_user_id' })
followingUserId: number;

@ManyToOne(() => User)
@PrimaryColumn({ name: 'followed_user_id' })
followedUserId: number;

@CreateDateColumn({ name: 'created_at' })
createdAt: Date;

@DeleteDateColumn({ name: 'deleted_at', nullable: true, type: 'timestamp' })
deletedAt: Date | null;

}
32 changes: 32 additions & 0 deletions be/src/user/entities/user.restaurantlist.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import {
Entity,
Column,
CreateDateColumn,
ManyToOne,
JoinColumn,
PrimaryColumn,
} from 'typeorm';
import { User } from './user.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: number;

@ManyToOne(() => RestaurantInfoEntity)
@PrimaryColumn({ name: 'restaurant_id' })
restaurantId: number;

@ManyToOne(() => ReviewInfoEntity)
@JoinColumn({ name: 'review_id' })
reviewId: ReviewInfoEntity;

@CreateDateColumn({ name: 'created_at', type: 'timestamp' })
createdAt: Date;

@Column({ name: 'deleted_at', type: 'timestamp', nullable: true })
deletedAt: Date | null;
}