Browse Source

Fixed-error-null-expire-date

new-feature
Viet.LeQ2 1 year ago
parent
commit
59986b0053
2 changed files with 8 additions and 3 deletions
  1. BIN
      build/libs/smart-farm-0.0.1-SNAPSHOT.war
  2. +8
    -3
      src/main/java/vn/azteam/tpf/web/rest/TBCodeResource.java

BIN
build/libs/smart-farm-0.0.1-SNAPSHOT.war View File


+ 8
- 3
src/main/java/vn/azteam/tpf/web/rest/TBCodeResource.java View File

throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); throw new BadRequestAlertException("1047", ENTITY_NAME, "1047");
} }


if (tBCodeCreationDTO.getExpiredDate() == null) {
throw new BadRequestAlertException("1047", ENTITY_NAME, "1047");
}

Optional<TBCropDTO> tbCropDTO = tBCropService.findOne(tBCodeCreationDTO.gettBCropId()); Optional<TBCropDTO> tbCropDTO = tBCropService.findOne(tBCodeCreationDTO.gettBCropId());
if (!tbCropDTO.isPresent()) { if (!tbCropDTO.isPresent()) {
throw new BadRequestAlertException("1019", ENTITY_NAME, "1019"); throw new BadRequestAlertException("1019", ENTITY_NAME, "1019");
tBCodeDTO.setCreatedDate(Instant.now()); tBCodeDTO.setCreatedDate(Instant.now());
tBCodeDTO.setCreatedById(currentUser.getUserId()); tBCodeDTO.setCreatedById(currentUser.getUserId());
tBCodeDTO.setStatus(TBCodeStatusEnum.NEW); tBCodeDTO.setStatus(TBCodeStatusEnum.NEW);
tBCodeDTO.setExpiredDate(tBCodeCreationDTO.getExpiredDate());
if (tBCodeCreationDTO.getTbExampleStampId() != null) { if (tBCodeCreationDTO.getTbExampleStampId() != null) {
tBCodeDTO.setTbExampleStampId(tBCodeCreationDTO.getTbExampleStampId()); tBCodeDTO.setTbExampleStampId(tBCodeCreationDTO.getTbExampleStampId());
} }


Optional<TBCode> tbCode = tBCodeService.findByCode(activityCodeCreationDTO.getCode()); Optional<TBCode> tbCode = tBCodeService.findByCode(activityCodeCreationDTO.getCode());


if(!tbCode.isPresent()) {
if (!tbCode.isPresent()) {
throw new BadRequestAlertException("1047", ENTITY_NAME, "1047"); throw new BadRequestAlertException("1047", ENTITY_NAME, "1047");
} else { } else {
if(tbCode.get().getStatus().equals(TBCodeStatusEnum.EXPIRED)
|| tbCode.get().getStatus().equals(TBCodeStatusEnum.CANCELED)) {
if (tbCode.get().getStatus().equals(TBCodeStatusEnum.EXPIRED)
|| tbCode.get().getStatus().equals(TBCodeStatusEnum.CANCELED)) {
throw new BadRequestAlertException("1047", "TB Code is not active", "1047"); throw new BadRequestAlertException("1047", "TB Code is not active", "1047");
} }
} }

Loading…
Cancel
Save