Skip to content

Commit 8d2b905

Browse files
authored
Merge pull request #67 from 9oormthon-univ/refactor/store
Fix : 스웨거 표기 수정 및 낙관락 재시도 트랜잭션 범위 수정
2 parents fb73044 + 1b9abb5 commit 8d2b905

File tree

4 files changed

+8
-11
lines changed

4 files changed

+8
-11
lines changed

src/main/java/com/trashheroesbe/feature/coupon/application/CouponStoreService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ public PurchaseUserCouponResponse purchaseCoupon(
7777
throw new BusinessException(COUPON_NOT_AVAILABLE);
7878
}
7979

80-
if (coupon.getIssuedCount() >= coupon.getTotalStock()) {
81-
throw new BusinessException(COUPON_OUT_OF_STOCK);
82-
}
80+
coupon.issue();
8381

8482
Integer pointCost = coupon.getPointCost();
8583
pointService.usePoint(
@@ -89,8 +87,6 @@ public PurchaseUserCouponResponse purchaseCoupon(
8987
request.couponId()
9088
);
9189

92-
coupon.issue();
93-
9490
UserCoupon userCoupon = UserCoupon.create(user, coupon);
9591
UserCoupon savedUserCoupon = userCouponRepository.save(userCoupon);
9692

src/main/java/com/trashheroesbe/feature/point/api/PointController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.trashheroesbe.global.auth.security.CustomerDetails;
88
import com.trashheroesbe.global.response.ApiResponse;
99
import lombok.RequiredArgsConstructor;
10+
import org.springframework.security.core.annotation.AuthenticationPrincipal;
1011
import org.springframework.web.bind.annotation.GetMapping;
1112
import org.springframework.web.bind.annotation.RequestMapping;
1213
import org.springframework.web.bind.annotation.RestController;
@@ -20,7 +21,9 @@ public class PointController implements PointControllerApi {
2021

2122
@Override
2223
@GetMapping
23-
public ApiResponse<UserPointResponse> getMyPoint(CustomerDetails customerDetails) {
24+
public ApiResponse<UserPointResponse> getMyPoint(
25+
@AuthenticationPrincipal CustomerDetails customerDetails
26+
) {
2427
UserPointResponse response = pointService.getMyPoint(customerDetails.getUser());
2528
return ApiResponse.success(OK, response);
2629
}

src/main/java/com/trashheroesbe/feature/point/application/PointService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.springframework.retry.annotation.Backoff;
2525
import org.springframework.retry.annotation.Retryable;
2626
import org.springframework.stereotype.Service;
27+
import org.springframework.transaction.annotation.Propagation;
2728
import org.springframework.transaction.annotation.Transactional;
2829

2930
@Slf4j
@@ -74,11 +75,6 @@ public UserPointResponse getMyPoint(User user) {
7475
}
7576

7677
@Transactional
77-
@Retryable(
78-
retryFor = ObjectOptimisticLockingFailureException.class,
79-
maxAttempts = 3,
80-
backoff = @Backoff(delay = 100)
81-
)
8278
public void usePoint(
8379
Long userId,
8480
Integer points,

src/main/java/com/trashheroesbe/feature/rank/api/TrashRankControllerApi.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import com.trashheroesbe.feature.rank.dto.response.RankResponse;
44
import com.trashheroesbe.global.response.ApiResponse;
55
import io.swagger.v3.oas.annotations.Operation;
6+
import io.swagger.v3.oas.annotations.tags.Tag;
67

8+
@Tag(name = "Rank", description = "랭킹 관련 API")
79
public interface TrashRankControllerApi {
810

911
@Operation(summary = "현재 랭킹 조회", description = "현재 누적된 쓰레기 검색 랭킹을 조회합니다.(3시간 마다 update)")

0 commit comments

Comments
 (0)