Skip to content

Commit

Permalink
서비스 계층에 데이터소스 라우팅 어노테이션 추가 (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
cire0304 committed Nov 6, 2023
1 parent 5e3639c commit 7387fde
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ayucoupon.coupon.service;

import com.ayucoupon.common.aop.multidatasource.DataSource;
import com.ayucoupon.coupon.domain.CouponRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.PageRequest;
Expand All @@ -19,6 +20,7 @@ public class ShowCouponsService {

private static final String COUPON_ID = "couponId";

@DataSource("secondary")
public List<CouponDto> getCouponsInProgress(LocalDateTime currentTime, Pageable pageable) {
Pageable pageRequest = PageRequest.of(
pageable.getPageNumber(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ayucoupon.usercoupon.service;

import com.ayucoupon.common.aop.multidatasource.DataSource;
import com.ayucoupon.coupon.domain.CouponRepository;
import com.ayucoupon.coupon.domain.entity.Coupon;
import com.ayucoupon.usercoupon.domain.UserCouponRepository;
Expand All @@ -26,6 +27,7 @@ public class ShowUserCouponService {

private static final String USER_COUPON_ID = "userCouponId";

@DataSource("primary")
public List<UserCouponDto> getUnexpiredUserCoupons(Long userId, LocalDateTime currentTime, Pageable pageable) {
Pageable pageRequest = PageRequest.of(
pageable.getPageNumber(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ayucoupon.usercoupon.service;

import com.ayucoupon.common.Money;
import com.ayucoupon.common.aop.multidatasource.DataSource;
import com.ayucoupon.common.exception.NotFoundUserCouponException;
import com.ayucoupon.coupon.domain.CouponRepository;
import com.ayucoupon.coupon.domain.entity.Coupon;
Expand All @@ -21,6 +22,7 @@ public class UseUserCouponService {
private final CouponRepository couponRepository;

@Transactional
@DataSource("primary")
public Money use(UseUserCouponCommand command) {
return applyUserCoupon(command);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.ayucoupon.usercoupon.service.issue;

import com.ayucoupon.common.aop.multidatasource.DataSource;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -12,6 +13,7 @@ public class IssueUserCouponService {
private final IssueUserCouponModule issueUserCouponModule;
private final IssueValidator issueValidator;

@DataSource("primary")
public Long issue(IssueUserCouponCommand command) {
issueValidator.validate(command);
return issueUserCouponModule.issue(command);
Expand Down

0 comments on commit 7387fde

Please sign in to comment.