Skip to content

Commit

Permalink
feat: 만기상환평가일 및 타입 조회를 위한 서비스 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kjungw1025 committed Jul 31, 2024
1 parent b129105 commit 71f7ff6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.wl2c.elswhereproductservice.domain.product.model.dto.response;

import com.wl2c.elswhereproductservice.domain.product.model.MaturityEvaluationDateType;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;

import java.time.LocalDate;

@Getter
public class ResponseMaturityRepaymentEvaluationDateDto {

@Schema(description = "만기상환평가일", example = "2027-07-13")
private final LocalDate maturityRepaymentEvaluationDate;

@Schema(description = "만기상환평가일 개수", example = "SINGLE or MULTIPLE or UNKNOWN")
private final MaturityEvaluationDateType maturityRepaymentEvaluationDateType;

public ResponseMaturityRepaymentEvaluationDateDto(LocalDate maturityRepaymentEvaluationDate,
MaturityEvaluationDateType maturityRepaymentEvaluationDateType) {
this.maturityRepaymentEvaluationDate = maturityRepaymentEvaluationDate;
this.maturityRepaymentEvaluationDateType = maturityRepaymentEvaluationDateType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import com.wl2c.elswhereproductservice.domain.product.exception.ProductEarlyRepaymentEvaluationDateFoundException;
import com.wl2c.elswhereproductservice.domain.product.exception.ProductMaturityEvaluationDateNotFoundException;
import com.wl2c.elswhereproductservice.domain.product.exception.ProductNotFoundException;
import com.wl2c.elswhereproductservice.domain.product.model.dto.response.ResponseMaturityRepaymentEvaluationDateDto;
import com.wl2c.elswhereproductservice.domain.product.model.dto.response.ResponseNextRepaymentEvaluationDateDto;
import com.wl2c.elswhereproductservice.domain.product.model.entity.EarlyRepaymentEvaluationDates;
import com.wl2c.elswhereproductservice.domain.product.model.entity.Product;
import com.wl2c.elswhereproductservice.domain.product.repository.EarlyRepaymentEvaluationDatesRepository;
import com.wl2c.elswhereproductservice.domain.product.repository.ProductRepository;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -42,4 +44,17 @@ public ResponseNextRepaymentEvaluationDateDto findNextRepaymentEvaluationDate(Lo
}
return new ResponseNextRepaymentEvaluationDateDto(nextDate);
}

public ResponseMaturityRepaymentEvaluationDateDto findMaturityRepaymentEvaluationDate(Long productId) {

Product product = productRepository.findOne(productId).orElseThrow(ProductNotFoundException::new);
if (product.getMaturityEvaluationDate() == null) {
throw new ProductMaturityEvaluationDateNotFoundException();
}

return new ResponseMaturityRepaymentEvaluationDateDto(
product.getMaturityEvaluationDate(),
product.getMaturityEvaluationDateType()
);
}
}

0 comments on commit 71f7ff6

Please sign in to comment.