package com.oqpo.api.web.dto.response.loanmng;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.oqpo.api.entity.loanmng.LoanMgntBaseInfoEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;


@Getter
@Setter
@Builder
@AllArgsConstructor(access = AccessLevel.PROTECTED)
@JsonInclude(JsonInclude.Include.ALWAYS)
public class LoanMngInfoResponse {

    @ApiModelProperty(value = "여신관리고유번호")
    private String loanMgntUnqNo;
    @ApiModelProperty(value = "매장아이디")
    private String storeId;
    @ApiModelProperty(value = "매장명")
    private String storeNm;
    @ApiModelProperty(value = "브랜드아이디")
    private String brandId;
    @ApiModelProperty(value = "브랜드명")
    private String brandNm;
    @ApiModelProperty(value = "계정코드")
    private String acctCd;
    @ApiModelProperty(value = "계좌번호")
    private String acctNo;
    @ApiModelProperty(value = "계좌잔액")
    private Long acctBal;
    @ApiModelProperty(value = "여신구분")
    private String loanDvsn;
    @ApiModelProperty(value = "여신구분명")
    private String loanDvsnNm;
    @ApiModelProperty(value = "신용한도금액")
    private Long credtLimitAmt;
    @ApiModelProperty(value = "충전한도금액")
    private Long chrgeLimitAmt;
    @ApiModelProperty(value = "신용한도사용여부")
    private String credtLimitUseYn;
    @ApiModelProperty(value = "사용금액합계")
    private Long useAmtTotal;
    @ApiModelProperty(value = "가수금액합계")
    private Long tmpRcvAcctTotal;
    @ApiModelProperty(value = "사용여부")
    private String useYn;
    @ApiModelProperty(value = "사용여부명")
    private String useYnNm;
    @ApiModelProperty(value = "비고")
    private String loanDesc;
    @ApiModelProperty(value = "시스템변경일시")
    private String sysChgDttm;
    @ApiModelProperty(value = "시스템변경아이디")
    private String sysChgId;
    @ApiModelProperty(value = "시스템변경자명")
    private String sysChgNm;

    public static LoanMngInfoResponse toDTO(LoanMgntBaseInfoEntity entity) {
        if (entity == null) return null;
        return LoanMngInfoResponse.builder()
                .loanMgntUnqNo(entity.getLoanMgntUnqNo())
                .storeId(entity.getStoreId() == null ? "" : entity.getStoreId())
                .storeNm(entity.getStoreNm() == null ? "" : entity.getStoreNm())
                .brandId(entity.getBrandId() == null ? "" : entity.getBrandId())
                .brandNm(entity.getBrandNm() == null ? "" : entity.getBrandNm())
                .acctCd(entity.getAcctCd() == null ? "" : entity.getAcctCd())
                .acctNo(entity.getAcctNo() == null ? "" : entity.getAcctNo())
                .acctBal(entity.getAcctBal() == null ? 0 : entity.getAcctBal())
                .loanDvsn(entity.getLoanDvsn() == null ? "" : entity.getLoanDvsn())
                .loanDvsnNm(entity.getLoanDvsnNm() == null ? "" : entity.getLoanDvsnNm())
                .credtLimitAmt(entity.getCredtLimitAmt() == null ? 0 : entity.getCredtLimitAmt())
                .chrgeLimitAmt(entity.getChrgeLimitAmt() == null ? 0 : entity.getChrgeLimitAmt())
                .credtLimitUseYn(entity.getCredtLimitUseYn() == null ? "" : entity.getCredtLimitUseYn())
                .useAmtTotal(entity.getUseAmtTotal() == null ? 0 : entity.getUseAmtTotal())
                .tmpRcvAcctTotal(entity.getTmpRcvAcctTotal() == null ? 0 : entity.getTmpRcvAcctTotal())
                .useYn(entity.getUseYn() == null ? "" : entity.getUseYn())
                .useYnNm(entity.getUseYnNm() == null ? "" : entity.getUseYnNm())
                .loanDesc(entity.getLoanDesc() == null ? "" : entity.getLoanDesc())
                .sysChgDttm(entity.getSysChgDttm() == null ? "" : entity.getSysChgDttm())
                .sysChgId(entity.getSysChgId() == null ? "" : entity.getSysChgId())
                .sysChgNm(entity.getSysChgNm() == null ? "" : entity.getSysChgNm())
                .build();
    }

}
