Skip to content

Commit

Permalink
♻️ 코드 수정 : 쿠폰 수정, 삭제 시 에러 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJeHuni committed Dec 10, 2024
1 parent 7b33ad8 commit 4ee6120
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import intbyte4.learnsmate.coupon.domain.dto.ClientFindCouponDTO;
import intbyte4.learnsmate.coupon.domain.dto.CouponDTO;
import intbyte4.learnsmate.coupon.domain.dto.CouponFilterDTO;
import intbyte4.learnsmate.coupon.domain.entity.CouponEntity;
import intbyte4.learnsmate.coupon.domain.pagination.CouponPageResponse;
import intbyte4.learnsmate.coupon.domain.vo.request.*;
import intbyte4.learnsmate.coupon.domain.vo.response.*;
Expand Down Expand Up @@ -139,6 +140,8 @@ public ResponseEntity<?> editCoupon(@PathVariable("couponCode") Long couponCode,
log.info("직원 쿠폰 수정 요청 : {}", request);
try {
if (!couponService.findAdminCouponByCouponCode(couponCode)) {
CouponEntity couponEntity = couponService.findByCouponCode(couponCode);
if (!couponEntity.getCouponFlag()) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("이미 삭제된 직원 쿠폰입니다.");
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("직원 쿠폰이 아닙니다.");
}

Expand All @@ -165,6 +168,8 @@ public ResponseEntity<?> editCoupon(@PathVariable("couponCode") Long couponCode,
public ResponseEntity<?> deleteCoupon(@PathVariable("couponCode") Long couponCode) {
try {
if (!couponService.findAdminCouponByCouponCode(couponCode)) {
CouponEntity couponEntity = couponService.findByCouponCode(couponCode);
if (!couponEntity.getCouponFlag()) return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("이미 삭제된 직원 쿠폰입니다.");
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("직원 쿠폰이 아닙니다.");
}

Expand Down

0 comments on commit 4ee6120

Please sign in to comment.