-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat/#17] 카테고리 관련 entitiy 구현 #19
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
Open
seungyeon-choi04
wants to merge
1
commit into
develop
Choose a base branch
from
feat#17]카테고리-api구현
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
The head ref may contain hidden characters: "feat#17]\uCE74\uD14C\uACE0\uB9AC-api\uAD6C\uD604"
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { Module } from '@nestjs/common'; | ||
| import { TypeOrmModule } from '@nestjs/typeorm'; | ||
| import { CategoryEntity } from './entities/category.entity'; | ||
|
|
||
| @Module({ | ||
| imports: [TypeOrmModule.forFeature([CategoryEntity])], | ||
| exports: [TypeOrmModule], | ||
| }) | ||
| export class CategoryModule {} |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { | ||
| BaseEntity, | ||
| Column, | ||
| CreateDateColumn, | ||
| DeleteDateColumn, | ||
| Entity, | ||
| PrimaryGeneratedColumn, | ||
| UpdateDateColumn, | ||
| } from 'typeorm'; | ||
|
|
||
| export enum CategoryColor { | ||
| BLUE = 'BLUE', | ||
| BROWN = 'BROWN', | ||
| GREEN = 'GREEN', | ||
| PURPLE = 'PURPLE', | ||
| PINK = 'PINK', | ||
| } | ||
|
|
||
| @Entity('Category') | ||
| export class CategoryEntity extends BaseEntity { | ||
| @PrimaryGeneratedColumn({ name: 'category_id', type: 'int' }) | ||
| categoryId: number; | ||
|
|
||
| @Column({ | ||
| name: 'category_name', | ||
| type: 'varchar', | ||
| length: 30, | ||
| nullable: false, | ||
| comment: '카테고리명', | ||
| }) | ||
| categoryName: string; | ||
|
|
||
| @Column({ | ||
| name: 'category_color', | ||
| type: 'enum', | ||
| enum: CategoryColor, | ||
| enumName: 'category_color_enum', | ||
| nullable: false, | ||
| comment: '카테고리 색', | ||
| }) | ||
| categoryColor: CategoryColor; | ||
|
|
||
| @Column({ | ||
| name: 'user_id', | ||
| type: 'int', | ||
| nullable: false, | ||
| comment: '사용자 아이디', | ||
| }) | ||
| userId: number; | ||
|
|
||
| @CreateDateColumn({ | ||
| name: 'created_at', | ||
| type: 'timestamp', | ||
| nullable: false, | ||
| comment: '생성일', | ||
| }) | ||
| createdAt: Date; | ||
|
|
||
| @UpdateDateColumn({ | ||
| name: 'updated_at', | ||
| type: 'timestamp', | ||
| nullable: true, | ||
| comment: '수정일', | ||
| }) | ||
| updatedAt: Date | null; | ||
|
|
||
| @DeleteDateColumn({ | ||
| name: 'deleted_at', | ||
| type: 'timestamp', | ||
| nullable: true, | ||
| comment: '삭제일', | ||
| }) | ||
| deletedAt: Date | null; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
userId에 관계 매핑과 인덱스가 없습니다.userId가 순수 컬럼으로만 정의되어 있어 User 엔티티와의 관계 매핑(@ManyToOne등)이 없고, FK 참조 무결성이 DB 레벨에서 보장되지 않습니다. 또한 카테고리 목록 조회가 사용자 기준으로 자주 수행될 것으로 예상되는데userId에 인덱스가 없어 조회 성능에 영향을 줄 수 있습니다.As per path instructions, "관계 매핑과 cascade 설정이 안전한지" 및 "필요한 인덱스/유니크 제약이 누락되지 않았는지"를 확인해야 합니다.
🔧 관계 매핑 및 인덱스 추가 예시
📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Path instructions