Skip to content
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

[feat] : 경매글 등록 API 구현 #23

Merged
merged 25 commits into from
Feb 19, 2024
Merged

Conversation

hyun2371
Copy link
Member

@hyun2371 hyun2371 commented Feb 17, 2024

close #22

📑 작업 상세 내용

  • AuctionController 추가
    • controller, service DTO 각각 사용
    • valid 관련 어노테이션 추가
  • AuctionService 추가
    • AuctionMapper 추가
  • 예외 처리 추가
    • GlobalExceptionHandler에 NotFoundException 관련 처리 함수 추가
    • AuctionErrorCode 추가
    • 엔티티 생성자 내부에 Assert() 추가
  • Enum 내 String 받고 Enum 변환하는 함수 추가
  • 엔티티 수정
    • 아래 사항은 노션 논의사항에 자세히 적어둠
    • Auction.product에 cascade 옵션 추가
    • ProductCategory.categoryValue 타입 Enum -> String으로 변경

💫 작업 요약

  • 경매글 등록 API 구현 (사진 필드는 추후 구현 예정)

🔍 중점적으로 리뷰 할 부분

  • 예외 처리 로직
  • 엔티티 수정 사항
  • AuctionMapper

@hyun2371 hyun2371 added the feat New feature or request label Feb 17, 2024
@hyun2371 hyun2371 requested a review from ParkJuhan94 February 17, 2024 13:28
@hyun2371 hyun2371 self-assigned this Feb 17, 2024
@hyun2371 hyun2371 linked an issue Feb 17, 2024 that may be closed by this pull request
2 tasks
Copy link

github-actions bot commented Feb 17, 2024

Test Results

3 tests  +2   3 ✅ +2   1s ⏱️ -1s
3 suites +2   0 💤 ±0 
3 files   +2   0 ❌ ±0 

Results for commit a8f15ae. ± Comparison against base commit e7c8c1d.

♻️ This comment has been updated with latest results.

@ParkJuhan94
Copy link
Contributor

경매글 등록 작업이 많네요 고생하셨습니다 !
리뷰 할게요~

@hyun2371
Copy link
Member Author

hyun2371 commented Feb 18, 2024

추가 작업 내용

오류 해결

api 모듈에서 testContainerSupport 및 fixture 사용 불가 문제 해결

  • java-test-fixtures 플러그인 추가
  • 위 파일들 해당 디렉토리로 넣음

@SpringBootTest에서 @SpringBootConfiguration 못찾음

  • api 모듈에 plain.jar 생성하도록 api 모듈 build.gradle 수정

테스트 추가

  • controller test 추가
    • ApiTestSupport 추가
  • service test 추가
  • testFixture 추가

통합 테스트 돌리니 403 에러 떠서 build.gradle에 security 관련 의존성 주석 처리했습니다.

@ParkJuhan94 ParkJuhan94 merged commit d7c03af into dev Feb 19, 2024
3 checks passed
@@ -12,6 +13,6 @@ dependencies {
}

tasks.named('jar') {
enabled = false
enabled = true
Copy link
Contributor

Choose a reason for hiding this comment

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

enabled = false 로 되어있으면 jar 파일이 안 생겼나요? 바꾸신 이유가 궁금합니다

Copy link
Member Author

Choose a reason for hiding this comment

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

bootJar enabled하면 jar가 생기고, jar enabled하면 plain.jar가 생깁니다. 멀티 모듈일 때는 plain.jar 필요해서 true로 설정했습니다.

.andExpect(jsonPath("$.si").isEmpty())
.andExpect(jsonPath("$.gu").isEmpty())
.andExpect(jsonPath("$.dong").isEmpty());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

경매글 등록에 실패하면 예외를 던지는 테스트는 필요없을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

추가하겠습니다~

@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "auction_id")
private Long id;

@ManyToOne(fetch = LAZY)
@JoinColumn(name = "seller_id",
nullable = false,
// nullable = false,
Copy link
Contributor

Choose a reason for hiding this comment

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

판매자가 null 이 될 수가 있나요??

Copy link
Member Author

Choose a reason for hiding this comment

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

아직 유저 쪽 구현이 안되어서 일단 null 허용하였습니다.

@@ -81,9 +90,10 @@ public class Auction extends TimeBaseEntity {
private int bookmarkCount;

@Builder
public Auction(User seller, String title, Product product, int initPrice, LocalDate endDate,
Copy link
Contributor

Choose a reason for hiding this comment

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

판매자가 null 이 될 수가 있나요?? 라는 질문과 동일한 부분입니다

this.categoryValue = categoryValue;
}

public static ProductCategory of(String categoryValue) {
Copy link
Contributor

Choose a reason for hiding this comment

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

다른 엔티티와 다르게 ProductCategory 에는 빌더를 private 로 막고
팩토리메서드를 쓰신 이유가 있을까요~?

Copy link
Member Author

@hyun2371 hyun2371 Feb 19, 2024

Choose a reason for hiding this comment

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

Auction, Product에도 팩토리 메서드 추가하겠습니다!

import lombok.Builder;

@Builder
public record RegisterAuctionRequest(
Copy link
Contributor

Choose a reason for hiding this comment

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

RegisterAuctionApiRequest 와 요청하는 필드가 똑같은데,
dto 를 분리한 이점이 있는걸까요~?

Copy link
Member Author

Choose a reason for hiding this comment

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

service가 controller에 의존하지 않게 하고자 dto를 분리하였습니다~ 예전에 슬랙에 보내드린 링크 참고해주시면 될 것 같아요

@hyun2371 hyun2371 deleted the feat/#22/auction-post-api branch February 20, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] : 경매글 등록 API 구현
2 participants