Skip to content

[Feat/#17] 카테고리 관련 entitiy 구현#19

Open
seungyeon-choi04 wants to merge 1 commit into
developfrom
feat#17]카테고리-api구현

Hidden character warning

The head ref may contain hidden characters: "feat#17]\uce74\ud14c\uace0\ub9ac-api\uad6c\ud604"
Open

[Feat/#17] 카테고리 관련 entitiy 구현#19
seungyeon-choi04 wants to merge 1 commit into
developfrom
feat#17]카테고리-api구현

Conversation

@seungyeon-choi04

Copy link
Copy Markdown

📌 관련 이슈번호

(Closes 키워드가 있어야 PR이 머지되었을 때 이슈가 자동으로 닫힌다)

📌 PR 유형

어떤 변경 사항이 있나요?

  • [ x ] 새 기능 추가
  • 버그 수정
  • 리팩토링

📌 PR 요약

카테고리 관련 entitiy 구현

📌 작업 세부 내용

  1. 카테고리 관련 entity 구현
  2. 카테고리 관련 app module에 등록

📸 스크린샷 (선택)

🔗 참고 자료

@seungyeon-choi04 seungyeon-choi04 linked an issue Jul 9, 2026 that may be closed by this pull request
@seungyeon-choi04 seungyeon-choi04 self-assigned this Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

카테고리 도메인을 위한 CategoryEntity(TypeORM 엔티티)와 CategoryColor enum이 신규 추가되었습니다. CategoryEntity를 기반으로 TypeOrmModule.forFeature를 구성하는 CategoryModule이 생성되었고, AppModule의 imports 배열에 CategoryModule이 등록되었습니다.

Changes

카테고리 모듈 초기 구성

Layer / File(s) Summary
CategoryEntity 정의
src/categories/entities/category.entity.ts
CategoryColor enum(BLUE/BROWN/GREEN/PURPLE/PINK)과 categoryId, categoryName, categoryColor, userId, createdAt, updatedAt, deletedAt(소프트 삭제)을 포함하는 CategoryEntity가 정의됩니다.
CategoryModule 선언 및 앱 등록
src/categories/category.module.ts, src/app.module.ts
CategoryEntity에 대한 TypeOrmModule.forFeature 등록과 TypeOrmModule export를 포함하는 CategoryModule이 생성되고, AppModule의 import 및 imports 배열에 추가됩니다.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning 이슈 #17의 카테고리 목록·생성·삭제·순서변경·수정 API 요구를 충족하는 기능이 아직 보이지 않습니다. 카테고리 조회·생성·삭제·순서 변경·수정 API와 이를 지원하는 서비스/컨트롤러 로직을 추가하세요.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 제목이 카테고리 엔티티 구현이라는 핵심 변경을 요약하고 있어 변경 내용과 관련이 있습니다.
Description check ✅ Passed 설명은 카테고리 엔티티 구현과 app module 등록을 언급해 변경 사항과 관련이 있습니다.
Out of Scope Changes check ✅ Passed 추가된 모듈, 엔티티, app module 등록은 카테고리 기능 구현 범위와 일치하며 불필요한 변경은 보이지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat#17]카테고리-api구현

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/categories/entities/category.entity.ts (1)

20-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

BaseEntity 확장(Active Record 패턴) 사용 여부 검토.

BaseEntity를 extends하면 엔티티에 save(), remove() 등의 메서드가 포함되어 Active Record 패턴이 됩니다. 리포지토리 패턴을 사용할 경우 서비스 레이어에서 DB 접근을 전담하도록 하는 것이 일관성 있는 접근입니다.

As per coding guidelines, "services should own business logic, validation beyond DTO checks, database access, and external API calls."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/categories/entities/category.entity.ts` at line 20, CategoryEntity is
currently extending BaseEntity, which introduces Active Record methods like
save() and remove(); update CategoryEntity to be a plain entity without
BaseEntity and use the repository-based flow in the relevant service/repository
layer instead. Locate the change in CategoryEntity and adjust any related code
paths that may rely on BaseEntity methods so database access stays owned by the
service layer.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/categories/entities/category.entity.ts`:
- Around line 43-49: Category entity의 userId가 단순 컬럼으로만 선언되어 있어 User와의 관계 및 DB 레벨
FK 보장이 빠져 있습니다. Category 엔티티에서 userId를 User 엔티티와 연결하는 관계 매핑(`@ManyToOne` 등)을 추가하고,
필요한 경우 연결 컬럼 설정도 함께 정리하세요. 또한 카테고리 조회 성능을 위해 userId에 인덱스를 추가하고, 중복 방지가 필요하다면
Category 엔티티의 유니크 제약도 함께 검토해 반영하세요.

---

Nitpick comments:
In `@src/categories/entities/category.entity.ts`:
- Line 20: CategoryEntity is currently extending BaseEntity, which introduces
Active Record methods like save() and remove(); update CategoryEntity to be a
plain entity without BaseEntity and use the repository-based flow in the
relevant service/repository layer instead. Locate the change in CategoryEntity
and adjust any related code paths that may rely on BaseEntity methods so
database access stays owned by the service layer.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e89f668d-bcfb-4a22-9077-1fd3f3fb4629

📥 Commits

Reviewing files that changed from the base of the PR and between becaba6 and ef4fbad.

📒 Files selected for processing (3)
  • src/app.module.ts
  • src/categories/category.module.ts
  • src/categories/entities/category.entity.ts

Comment on lines +43 to +49
@Column({
name: 'user_id',
type: 'int',
nullable: false,
comment: '사용자 아이디',
})
userId: number;

Copy link
Copy Markdown

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 설정이 안전한지" 및 "필요한 인덱스/유니크 제약이 누락되지 않았는지"를 확인해야 합니다.

🔧 관계 매핑 및 인덱스 추가 예시
-  `@Column`({
-    name: 'user_id',
-    type: 'int',
-    nullable: false,
-    comment: '사용자 아이디',
-  })
-  userId: number;
+  `@Index`()
+  `@Column`({
+    name: 'user_id',
+    type: 'int',
+    nullable: false,
+    comment: '사용자 아이디',
+  })
+  userId: number;
+
+  `@ManyToOne`(() => UserEntity)
+  `@JoinColumn`({ name: 'user_id' })
+  user: UserEntity;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Column({
name: 'user_id',
type: 'int',
nullable: false,
comment: '사용자 아이디',
})
userId: number;
`@Index`()
`@Column`({
name: 'user_id',
type: 'int',
nullable: false,
comment: '사용자 아이디',
})
userId: number;
`@ManyToOne`(() => UserEntity)
`@JoinColumn`({ name: 'user_id' })
user: UserEntity;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/categories/entities/category.entity.ts` around lines 43 - 49, Category
entity의 userId가 단순 컬럼으로만 선언되어 있어 User와의 관계 및 DB 레벨 FK 보장이 빠져 있습니다. Category
엔티티에서 userId를 User 엔티티와 연결하는 관계 매핑(`@ManyToOne` 등)을 추가하고, 필요한 경우 연결 컬럼 설정도 함께
정리하세요. 또한 카테고리 조회 성능을 위해 userId에 인덱스를 추가하고, 중복 방지가 필요하다면 Category 엔티티의 유니크 제약도
함께 검토해 반영하세요.

Source: Path instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] 카테고리 API 구현

1 participant