-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #175 from CoolPeace-yanolza/develop
1.23 14시 30분 배포
- Loading branch information
Showing
27 changed files
with
329 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/coolpeace/domain/batch/tasklet/CouponStatusTasklet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.coolpeace.domain.batch.tasklet; | ||
|
||
import com.coolpeace.domain.statistics.service.DailyStatisticsService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.batch.core.StepContribution; | ||
import org.springframework.batch.core.StepExecutionListener; | ||
import org.springframework.batch.core.scope.context.ChunkContext; | ||
import org.springframework.batch.core.step.tasklet.Tasklet; | ||
import org.springframework.batch.repeat.RepeatStatus; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Component | ||
public class CouponStatusTasklet implements Tasklet, StepExecutionListener { | ||
private final DailyStatisticsService dailyStatisticsService; | ||
|
||
@Override | ||
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) | ||
throws Exception { | ||
log.info("쿠폰상태 Tasklet 시작"); | ||
dailyStatisticsService.updateCouponStatusStartExposure(); | ||
dailyStatisticsService.updateCouponStatusEndExposure(); | ||
|
||
return RepeatStatus.FINISHED; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/com/coolpeace/domain/coupon/dto/request/validator/CouponRequestValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.coolpeace.domain.coupon.dto.request.validator; | ||
|
||
import com.coolpeace.domain.coupon.entity.type.DiscountType; | ||
import org.springframework.validation.Errors; | ||
import org.springframework.validation.ValidationUtils; | ||
import org.springframework.validation.Validator; | ||
|
||
public abstract class CouponRequestValidator implements Validator { | ||
|
||
// 방 등록 유효성 검사 | ||
protected static void validateRegisterRooms(Errors errors, boolean registerAllRoom) { | ||
if (!registerAllRoom) { | ||
ValidationUtils.rejectIfEmpty(errors, | ||
"registerRooms", | ||
"registerRooms.empty", | ||
"등록할 객실을 선택해주세요."); | ||
} | ||
} | ||
|
||
// 할인 유형 유효성 검사 | ||
protected static void validateDiscountValues(Errors errors, | ||
String requestedDiscountTypeStr, | ||
Integer requestedDiscountFlatValue, | ||
Integer requestedDiscountFlatRate) { | ||
if (requestedDiscountTypeStr.equals(DiscountType.FIXED_PRICE.getValue())) { | ||
if (requestedDiscountFlatValue == null || requestedDiscountFlatValue <= 0) { | ||
errors.reject("discountFlatValue.empty", "정액 할인의 경우 할인 금액를 입력해야 합니다."); | ||
} | ||
} else { | ||
if (requestedDiscountFlatRate == null || requestedDiscountFlatRate <= 0) { | ||
errors.reject("discountFlatValue.empty", "정률 할인의 경우 할인 비율을 입력해야 합니다."); | ||
} | ||
} | ||
} | ||
} |
31 changes: 4 additions & 27 deletions
31
.../java/com/coolpeace/domain/coupon/dto/request/validator/CouponUpdateRequestValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,21 @@ | ||
package com.coolpeace.domain.coupon.dto.request.validator; | ||
|
||
import com.coolpeace.domain.coupon.dto.request.CouponRegisterRequest; | ||
import com.coolpeace.domain.coupon.dto.request.CouponUpdateRequest; | ||
import com.coolpeace.domain.coupon.entity.type.DiscountType; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.util.CollectionUtils; | ||
import org.springframework.validation.Errors; | ||
import org.springframework.validation.Validator; | ||
|
||
@Component | ||
public class CouponUpdateRequestValidator implements Validator { | ||
public class CouponUpdateRequestValidator extends CouponRequestValidator { | ||
@Override | ||
public boolean supports(Class<?> clazz) { | ||
return CouponUpdateRequest.class.equals(clazz); | ||
} | ||
|
||
@Override | ||
public void validate(Object target, Errors errors) { | ||
CouponRegisterRequest request = (CouponRegisterRequest) target; | ||
|
||
// 할인 유형 | ||
if (request.discountType().equals(DiscountType.FIXED_PRICE.getValue())) { | ||
if (request.discountValue() < 100) { | ||
errors.reject("discountValue", | ||
"정액 할인일 경우 값을 100 이상으로 설정해야 합니다."); | ||
} | ||
} else { | ||
if (request.discountValue() > 100) { | ||
errors.reject("discountValue", | ||
"정률 할인일 경우 값을 100 이하로 설정해야 합니다."); | ||
} | ||
} | ||
|
||
// 특정 객실 등록 | ||
if (!request.registerAllRoom()) { | ||
if (CollectionUtils.isEmpty(request.registerRooms())) { | ||
errors.reject("registerRooms.empty", | ||
"등록할 객실 리스트가 비어 있습니다."); | ||
} | ||
} | ||
CouponUpdateRequest request = (CouponUpdateRequest) target; | ||
|
||
validateRegisterRooms(errors, request.registerAllRoom()); | ||
validateDiscountValues(errors, request.discountType(), request.discountFlatValue(), request.discountFlatRate()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.