[4기 나영경] Springboot-jpa weekly 미션 1차 PR입니다.#323
Open
na-yk wants to merge 83 commits intoprgrms-be-devcourse:na-ykfrom
Open
[4기 나영경] Springboot-jpa weekly 미션 1차 PR입니다.#323na-yk wants to merge 83 commits intoprgrms-be-devcourse:na-ykfrom
na-yk wants to merge 83 commits intoprgrms-be-devcourse:na-ykfrom
Conversation
…1/CustomerRepositoryTest.java Co-authored-by: SR <kslbsh@gmail.com>
seung-hun-h
suggested changes
Aug 3, 2023
jpa-weekly/src/main/java/com/example/jpaweekly/domain/customer/Customer.java
Outdated
Show resolved
Hide resolved
Comment on lines
+21
to
+29
| @Builder | ||
| public Customer(String firstName, String lastName) { | ||
| this.firstName = firstName; | ||
| this.lastName = lastName; | ||
| } | ||
|
|
||
| public static CustomerResponse from(Customer customer){ | ||
| return new CustomerResponse(customer.getFirstName(), customer.getLastName()); | ||
| } |
There was a problem hiding this comment.
빌더, 기본 생성자, 정적 팩토리 메서드를 모두 열어둔 이유가 있나요?
Author
There was a problem hiding this comment.
이건 별다른 이유는 없고, 페어프로그래밍을 하면서 각각을 사용해보는 연습을 하고 남겨둔 것이었습니다. 불필요한 부분은 삭제했습니다!
jpa-weekly/src/main/java/com/example/jpaweekly/domain/customer/Customer.java
Show resolved
Hide resolved
jpa-weekly/src/main/java/com/example/jpaweekly/domain/customer/Customer.java
Outdated
Show resolved
Hide resolved
...ly/src/main/java/com/example/jpaweekly/domain/customer/controller/CustomerApiController.java
Outdated
Show resolved
Hide resolved
| .build(); | ||
| orderProducts.add(orderProduct); | ||
| }); | ||
| orderProductRepository.saveAll(orderProducts); |
There was a problem hiding this comment.
save를 한 번씩 호출하는 것보다 saveAll을 호출해주는 것이 더 좋은 것 같아요.
ID 생성 타입이 IDENTITY인 경우에는 bulk insert가 안된다고하니 참고하셔도 좋을 것 같습니다.
테스트 코드를 작성해서 쿼리가 어떻게 생성되는지 확인해보면 좋을 것 같아요
Comment on lines
+18
to
+19
|
|
||
| public Long createUser(UserCreateRequest request){ |
There was a problem hiding this comment.
Suggested change
| public Long createUser(UserCreateRequest request){ | |
| @Transactional | |
| public Long createUser(UserCreateRequest request){ |
...kly/src/test/java/com/example/jpaweekly/domain/customer/service/CustomerServiceImplTest.java
Outdated
Show resolved
Hide resolved
jpa-weekly/src/main/java/com/example/jpaweekly/domain/user/service/UserServiceImpl.java
Outdated
Show resolved
Hide resolved
refactor: name 변경 메서드 하나로 통일
dojinyou
reviewed
Aug 4, 2023
jpa-weekly/src/main/java/com/example/jpaweekly/domain/BaseEntity.java
Outdated
Show resolved
Hide resolved
jpa-weekly/src/main/java/com/example/jpaweekly/domain/customer/Customer.java
Outdated
Show resolved
Hide resolved
jpa-weekly/src/main/java/com/example/jpaweekly/domain/customer/CustomerMapper.java
Outdated
Show resolved
Hide resolved
...ly/src/main/java/com/example/jpaweekly/domain/customer/controller/CustomerApiController.java
Outdated
Show resolved
Hide resolved
...ly/src/main/java/com/example/jpaweekly/domain/customer/controller/CustomerApiController.java
Outdated
Show resolved
Hide resolved
jpa-weekly/src/main/java/com/example/jpaweekly/domain/customer/dto/CustomerResponse.java
Show resolved
Hide resolved
...eekly/src/main/java/com/example/jpaweekly/domain/customer/repository/CustomerRepository.java
Outdated
Show resolved
Hide resolved
jpa-weekly/src/main/java/com/example/jpaweekly/domain/order/OrderStatus.java
Show resolved
Hide resolved
jpa-weekly/src/main/java/com/example/jpaweekly/domain/order/service/OrderServiceImpl.java
Outdated
Show resolved
Hide resolved
...eekly/src/test/java/com/example/jpaweekly/domain/product/service/ProductServiceImplTest.java
Show resolved
Hide resolved
style: single class import로 변경
style: 불필요한 import 제거
seung-hun-h
reviewed
Aug 7, 2023
| } | ||
|
|
||
| @PostMapping | ||
| public ResponseEntity<Long> customerCreate(@RequestBody CustomerRequest request) { |
| import org.springframework.data.jpa.repository.JpaRepository; | ||
|
|
||
| public interface CustomerRepository extends JpaRepository<Customer, Long> { | ||
| String findByFirstName(String firstName); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
📌 과제 설명
👩💻 요구 사항과 구현 내용
Customer엔티티로 미션1을 수행하였고, 추후Order,Product,User엔티티로 미션3을 수행했습니다.orderId,productId,quantity로 구성된OrderProduct엔티티를 추가하여Order생성 시 주문한 제품과 그 수를 저장할 수 있도록 했습니다.✅ PR 포인트 & 궁금한 점
createOrder을 할 때 관련OrderProduct를 생성하는데,save()를 반복 호출하는 것이 좋지 않다고 생각해서saveAll()을 이용해보았습니다. 적절한 사용인지 궁금합니다!