Skip to content

Conversation

@wooo73
Copy link
Owner

@wooo73 wooo73 commented Sep 4, 2025

커밋 링크


리뷰 포인트(질문)

  • 리뷰 포인트 1
  • 리뷰 포인트 2

이번주 KPT 회고

Keep

Problem

Try

wooo73 added 8 commits January 6, 2025 00:11
- user controller swagger 명세 분리 및 데코레이터 적용
- table 생성 및 seed 생성 prisma 적용
- controller, service, repository 구현
- 기능별 테스트 코드 작성
- 상품 주문 가능 상태값 추가
- swagger 분리
- controller, service, repository 구현
- status 타입 boolean -> string
@wooo73
Copy link
Owner Author

wooo73 commented Sep 4, 2025

@gemini-code-asssis

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @wooo73, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request lays the groundwork for an e-commerce application by implementing core product and user management features. It introduces a clean, maintainable architecture using the repository pattern, enhances data integrity through validation, and improves the development experience with better API documentation and a more robust testing environment.

Highlights

  • Core E-commerce Functionality Implementation: Introduced foundational features for an e-commerce system, including product listing with pagination and user balance management (lookup and charging).
  • Architectural Refactoring to Repository Pattern: Implemented the repository pattern for both Product and User modules, abstracting data access logic behind interfaces (ProductRepository, UserRepository) and providing Prisma-based implementations.
  • Enhanced Data Validation and API Documentation: Integrated class-transformer and class-validator for robust DTO validation and refactored Swagger API documentation using dedicated helper functions for cleaner controller code.
  • Database Schema and Seeding Improvements: Adjusted several Prisma schemas (e.g., Coupon, OrderItem, Product) to better reflect e-commerce needs, and significantly expanded the prisma/seed.ts script to generate more comprehensive mock data for development and testing.
  • Migration of Integration Test Infrastructure: Transitioned the integration test setup from TypeORM to Prisma, updating test utilities (test/it/down.ts, test/it/setup.ts, test/it/util.ts) to use Prisma Client and db push for schema management.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

이번 PR은 상품 및 사용자 관련 기능을 추가하고, 레포지토리 패턴을 도입하여 아키텍처를 개선하는 등 많은 변경사항을 포함하고 있습니다. 전반적으로 코드 분리와 가독성을 높이는 좋은 시도들이 보입니다. 다만, 몇 가지 잠재적인 문제점과 개선점을 발견하여 리뷰 코멘트를 남겼습니다. 스크립트 명령어의 일관성, 데이터베이스 제약 조건, 중복 코드, 네이밍 컨벤션, DTO 매핑 로직 등을 확인해 주시면 좋겠습니다.

"docker:down": "docker-compose -f docker-compose.yaml down -v",
"migrate:test": "dotenv -e .env.test -- npx prisma migrate deploy",
"seed:test": "dotenv -e .env.test -- npx prisma db seed"
"seed:test": "npx prisma db seed"

Choose a reason for hiding this comment

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

high

seed:test 스크립트에서 dotenv -e .env.test --가 제거되었습니다. migrate:test 스크립트에는 남아있는데, 이로 인해 seed:test 실행 시 .env.test 파일의 환경 변수를 읽지 못할 수 있습니다. prisma/seed.tsDATABASE_URL 같은 환경 변수에 의존한다면, 테스트 시드 데이터 생성에 실패할 수 있습니다. 일관성을 위해 seed:test 스크립트에도 dotenv-cli를 사용하거나, Jest 설정 등 다른 방식으로 환경 변수를 주입하는 것을 고려해 보세요.

Suggested change
"seed:test": "npx prisma db seed"
"seed:test": "dotenv -e .env.test -- npx prisma db seed"

orderId Int @map("order_id")
product Product @relation(fields: [productId], references: [id])
productId Int @unique @map("product_id")
productId Int @map("product_id")

Choose a reason for hiding this comment

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

high

productId 필드에서 @unique 제약조건을 제거한 것은 올바른 수정입니다. 하지만 일반적으로 하나의 주문에 동일한 상품이 여러 항목으로 들어가는 것을 방지하기 위해 orderIdproductId에 대한 복합 고유 키(composite unique key)를 설정하는 것이 좋습니다. 모델 하단에 @@unique([orderId, productId])를 추가하는 것을 고려해 보세요.

Comment on lines +19 to +26
static of(product: Product): ProductResponseDto {
const dto = new ProductResponseDto(product);
dto.ProductQuantity = {
quantity: product.ProductQuantity?.quantity,
remainingQuantity: product.ProductQuantity?.remainingQuantity,
};
return dto;
}

Choose a reason for hiding this comment

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

high

ProductResponseDto.of 메서드에서 product.ProductQuantitynull 또는 undefined일 경우, dto.ProductQuantityquantityremainingQuantity 속성에 undefined가 할당될 수 있습니다. ProductQuantityDto의 타입 정의와 맞지 않아 런타임 오류를 유발할 수 있습니다. ProductQuantity가 없는 경우를 명확하게 처리하는 것이 좋습니다. 예를 들어, null을 할당하거나 기본값을 설정할 수 있습니다.

    static of(product: Product): ProductResponseDto {
        const dto = new ProductResponseDto(product);
        dto.ProductQuantity = product.ProductQuantity
            ? {
                  quantity: product.ProductQuantity.quantity,
                  remainingQuantity: product.ProductQuantity.remainingQuantity,
              }
            : null;
        return dto;
    }

Comment on lines +30 to +37
//사용자 생성
await Promise.all(
Array.from({ length: 10 }, () =>
prisma.user.create({
data: { balance: 10000 },
}),
),
);

Choose a reason for hiding this comment

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

medium

사용자 생성 코드가 중복되어 있습니다. 22-28 라인과 31-37 라인에서 동일한 로직으로 사용자를 생성하고 있습니다. 중복된 코드를 제거하여 스크립트를 간결하게 유지하는 것이 좋습니다.

import { Product } from '../domain/product';

@Injectable()
export class ProductTypeOrmRepository implements ProductRepository {

Choose a reason for hiding this comment

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

medium

파일명과 클래스명이 ProductTypeOrmRepository로 되어 있지만, 실제 구현은 Prisma를 사용하고 있습니다. 이는 다른 개발자에게 혼동을 줄 수 있습니다. ProductPrismaRepository와 같이 실제 사용하는 기술을 명시하는 이름으로 변경하는 것을 권장합니다.

Suggested change
export class ProductTypeOrmRepository implements ProductRepository {
export class ProductPrismaRepository implements ProductRepository {

Comment on lines +22 to +27
try {
await this.getUserBalance(userId);
return await this.userRepository.updateUserBalance(userId, userChargePointRequestDto);
} catch (err) {
throw err;
}

Choose a reason for hiding this comment

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

medium

chargeUserBalance 메서드의 try...catch 블록은 에러를 잡아서 그대로 다시 던지는 역할만 하고 있어 불필요합니다. await this.getUserBalance(userId)에서 발생하는 NotFoundExceptiontry...catch가 없어도 상위로 전파됩니다. 코드를 간결하게 만들기 위해 try...catch 블록을 제거하는 것이 좋습니다.

        await this.getUserBalance(userId);
        return await this.userRepository.updateUserBalance(userId, userChargePointRequestDto);

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.

2 participants