Skip to content

Commit

Permalink
style: 중복 메서드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
kmebin committed Nov 26, 2023
1 parent ec2043d commit 92bb3db
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void delete(AuthMember admin, Long couponId) {

@Transactional
public void use(Long memberId, Long couponWalletId) {
Coupon coupon = getByWallet(memberId, couponWalletId);
Coupon coupon = getByWalletIdAndMemberId(couponWalletId, memberId);
couponRepository.delete(coupon);
}

Expand All @@ -71,12 +71,6 @@ public CouponResponse getById(Long couponId) {
return CouponMapper.toResponse(coupon);
}

public Coupon getByWallet(Long memberId, Long couponWalletId) {
return couponWalletRepository.findByIdAndMemberId(couponWalletId, memberId)
.orElseThrow(() -> new NotFoundException(ErrorMessage.NOT_FOUND_COUPON_WALLET))
.getCoupon();
}

public List<CouponResponse> getAllByStatus(CouponStatusRequest request) {
LocalDate now = clockHolder.date();
List<Coupon> coupons = couponSearchRepository.findAllByStatus(now, request);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.moabam.api.domain.coupon.repository;

import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;

import com.moabam.api.domain.coupon.CouponWallet;

public interface CouponWalletRepository extends JpaRepository<CouponWallet, Long> {

Optional<CouponWallet> findByIdAndMemberId(Long id, Long memberId);
}

0 comments on commit 92bb3db

Please sign in to comment.