-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/e commerce #18
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
base: main
Are you sure you want to change the base?
Feat/e commerce #18
Conversation
- user controller swagger 명세 분리 및 데코레이터 적용
- table 생성 및 seed 생성 prisma 적용
- controller, service, repository 구현 - 기능별 테스트 코드 작성
- 상품 주문 가능 상태값 추가
- swagger 분리 - controller, service, repository 구현
- status 타입 boolean -> string
|
@gemini-code-asssis |
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.
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-transformerandclass-validatorfor 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 theprisma/seed.tsscript 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 anddb pushfor 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
-
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. ↩
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.
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" |
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.
seed:test 스크립트에서 dotenv -e .env.test --가 제거되었습니다. migrate:test 스크립트에는 남아있는데, 이로 인해 seed:test 실행 시 .env.test 파일의 환경 변수를 읽지 못할 수 있습니다. prisma/seed.ts가 DATABASE_URL 같은 환경 변수에 의존한다면, 테스트 시드 데이터 생성에 실패할 수 있습니다. 일관성을 위해 seed:test 스크립트에도 dotenv-cli를 사용하거나, Jest 설정 등 다른 방식으로 환경 변수를 주입하는 것을 고려해 보세요.
| "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") |
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.
| static of(product: Product): ProductResponseDto { | ||
| const dto = new ProductResponseDto(product); | ||
| dto.ProductQuantity = { | ||
| quantity: product.ProductQuantity?.quantity, | ||
| remainingQuantity: product.ProductQuantity?.remainingQuantity, | ||
| }; | ||
| return dto; | ||
| } |
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.
ProductResponseDto.of 메서드에서 product.ProductQuantity가 null 또는 undefined일 경우, dto.ProductQuantity의 quantity와 remainingQuantity 속성에 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;
}| //사용자 생성 | ||
| await Promise.all( | ||
| Array.from({ length: 10 }, () => | ||
| prisma.user.create({ | ||
| data: { balance: 10000 }, | ||
| }), | ||
| ), | ||
| ); |
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.
| import { Product } from '../domain/product'; | ||
|
|
||
| @Injectable() | ||
| export class ProductTypeOrmRepository implements ProductRepository { |
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.
파일명과 클래스명이 ProductTypeOrmRepository로 되어 있지만, 실제 구현은 Prisma를 사용하고 있습니다. 이는 다른 개발자에게 혼동을 줄 수 있습니다. ProductPrismaRepository와 같이 실제 사용하는 기술을 명시하는 이름으로 변경하는 것을 권장합니다.
| export class ProductTypeOrmRepository implements ProductRepository { | |
| export class ProductPrismaRepository implements ProductRepository { |
| try { | ||
| await this.getUserBalance(userId); | ||
| return await this.userRepository.updateUserBalance(userId, userChargePointRequestDto); | ||
| } catch (err) { | ||
| throw err; | ||
| } |
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.
chargeUserBalance 메서드의 try...catch 블록은 에러를 잡아서 그대로 다시 던지는 역할만 하고 있어 불필요합니다. await this.getUserBalance(userId)에서 발생하는 NotFoundException은 try...catch가 없어도 상위로 전파됩니다. 코드를 간결하게 만들기 위해 try...catch 블록을 제거하는 것이 좋습니다.
await this.getUserBalance(userId);
return await this.userRepository.updateUserBalance(userId, userChargePointRequestDto);
커밋 링크
리뷰 포인트(질문)
이번주 KPT 회고
Keep
Problem
Try