Skip to content

Commit cddcf4f

Browse files
committed
πŸ› fix: createTeam λ©”μ„œλ“œμ— orderId λ§€κ°œλ³€μˆ˜ μΆ”κ°€ 및 Order 쑰회 둜직 κ΅¬ν˜„
1 parent 5f07acb commit cddcf4f

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

β€Žsrc/main/java/com/jajaja/domain/team/controller/TeamController.javaβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ public class TeamController {
2525
summary = "νŒ€ 생성 API | by μ§€μ§€/이지희",
2626
description = "β€˜νŒ€ μƒμ„±ν•˜κΈ° λ²„νŠΌβ€™μ„ 톡해 ν•΄λ‹Ή μƒν’ˆμ˜ νŒ€μ„ μƒμ„±ν•©λ‹ˆλ‹€. ν•΄λ‹Ή μœ μ €λŠ” λ§Œλ“€μ–΄μ§„ νŒ€μ˜ 리더가 λ©λ‹ˆλ‹€."
2727
)
28-
@PostMapping("/{productId}")
29-
public ApiResponse<TeamCreateResponseDto> createTeam(@Auth Long memberId, @PathVariable Long productId) {
30-
TeamCreateResponseDto responseDto = teamCommandService.createTeam(memberId, productId);
28+
@PostMapping
29+
public ApiResponse<TeamCreateResponseDto> createTeam(@Auth Long memberId, @RequestParam Long productId, @RequestParam String orderId) {
30+
TeamCreateResponseDto responseDto = teamCommandService.createTeam(memberId, productId, orderId);
3131
return ApiResponse.onSuccess(responseDto);
3232
}
3333

β€Žsrc/main/java/com/jajaja/domain/team/service/TeamCommandService.javaβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import com.jajaja.domain.team.dto.response.TeamCreateResponseDto;
44

55
public interface TeamCommandService {
6-
TeamCreateResponseDto createTeam(Long memberId, Long orderId);
6+
TeamCreateResponseDto createTeam(Long memberId, Long productId, String orderId);
77
void joinTeam(Long memberId, Long teamId);
88
void joinTeamInCarts(Long memberId, Long productId);
99
}

β€Žsrc/main/java/com/jajaja/domain/team/service/TeamCommandServiceImpl.javaβ€Ž

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.jajaja.domain.team.service;
22

33
import com.jajaja.domain.cart.entity.Cart;
4+
import com.jajaja.domain.order.entity.Order;
5+
import com.jajaja.domain.order.repository.OrderRepository;
46
import com.jajaja.domain.product.entity.Product;
57
import com.jajaja.domain.product.repository.ProductRepository;
68
import com.jajaja.domain.team.dto.response.TeamCreateResponseDto;
@@ -27,18 +29,21 @@ public class TeamCommandServiceImpl implements TeamCommandService {
2729
private final ProductRepository productRepository;
2830
private final TeamRepository teamRepository;
2931
private final TeamCommonServiceImpl teamCommonService;
32+
private final OrderRepository orderRepository;
3033

3134
@Override
32-
public TeamCreateResponseDto createTeam(Long memberId, Long productId) {
35+
public TeamCreateResponseDto createTeam(Long memberId, Long productId, String orderId) {
3336
Member member = memberRepository.findById(memberId)
3437
.orElseThrow(() -> new BadRequestException(ErrorStatus.MEMBER_NOT_FOUND));
35-
3638
Product product = productRepository.findById(productId)
3739
.orElseThrow(() -> new BadRequestException(ErrorStatus.PRODUCT_NOT_FOUND));
40+
Order order = orderRepository.findByOrderId(orderId)
41+
.orElseThrow(() -> new BadRequestException(ErrorStatus.ORDER_NOT_FOUND));
3842

3943
Team team = Team.builder()
4044
.leader(member)
4145
.product(product)
46+
.order(order)
4247
.status(TeamStatus.MATCHING)
4348
.expireAt(LocalDateTime.now().plusMinutes(30))
4449
.build();

0 commit comments

Comments
Β (0)