-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
LAPTOP-EIABQG0H\tulip
committed
Oct 4, 2023
1 parent
9da0331
commit 50cf09c
Showing
4 changed files
with
99 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,21 @@ | ||
import { ProductEntity } from '../entities/product.entity'; | ||
import { IsInt, IsString, IsOptional, Min, IsNumber } from 'class-validator'; | ||
|
||
export class CreateProductDto extends ProductEntity {} | ||
export class CreateProductDto { | ||
|
||
@IsInt() | ||
sellerId: number; // 사용자는 판매자의 ID만 제공합니다. 연관된 엔터티는 서비스 레벨에서 처리됩니다. | ||
|
||
@IsString() | ||
name: string; | ||
|
||
@IsString() | ||
price: string; | ||
|
||
@IsNumber() | ||
@Min(0) | ||
quantity: number; | ||
|
||
@IsString() | ||
@IsOptional() // 선택적 필드입니다. | ||
description?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
import { CommonColumns } from '@/common/entities/common-columns'; | ||
import { Column, Entity } from 'typeorm'; | ||
import { UserEntity } from '@/modules/users/entities/user.entity'; | ||
import { Column, PrimaryGeneratedColumn, ManyToMany, JoinTable, ManyToOne, JoinColumn, Entity } from 'typeorm'; | ||
|
||
@Entity({ name: 'products' }) | ||
export class ProductEntity extends CommonColumns { | ||
|
||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@ManyToOne(() => UserEntity, seller => seller.products) | ||
@JoinColumn({ name: 'seller_id' }) // This sets up the foreign key | ||
seller: UserEntity; | ||
|
||
@Column() | ||
name: string; | ||
|
||
@Column() | ||
price: string; | ||
|
||
@Column() | ||
quantity: number; | ||
|
||
@Column({ nullable: true }) | ||
description?: string; | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters