package com.clx.performance.struct.loan;

import com.clx.performance.dto.OwnerLoanAccountRunWaterRecordDTO;
import com.clx.performance.model.loan.OwnerLoanAccountRunningWaterRecord;
import com.clx.performance.vo.pc.loan.owner.OwnerLoanRunWaterRecordVO;
import com.msl.common.utils.DateStructUtil;
import org.mapstruct.IterableMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Named;

import java.util.List;
import java.util.Objects;

@Mapper(componentModel = "spring", uses = DateStructUtil.class, imports = {Objects.class})
public interface OwnerLoanAccountRunningWaterRecordStruct {

    List<OwnerLoanRunWaterRecordVO> convertList(List<OwnerLoanAccountRunningWaterRecord> list);

    @Named("toBaseVo")
    @Mapping(target = "alterationBalance", expression = "java(Objects.isNull(record.getAlterationBalance())? null : record.getAlterationBalance().movePointLeft(2))")
    @Mapping(target = "accountBalance", expression = "java(Objects.isNull(record.getAccountBalance())? null : record.getAccountBalance().movePointLeft(2))")
//    @Mapping(target = "runningWaterTypeMsg", expression = "java(OwnerLoanAccountRunWaterRecordEnum.RunWaterType.getMsgByCode(record.getRunningWaterType()))")
    OwnerLoanAccountRunWaterRecordDTO convertDTO(OwnerLoanAccountRunningWaterRecord record);

    @IterableMapping(qualifiedByName = "toBaseVo")
    List<OwnerLoanAccountRunWaterRecordDTO> convertDTOList(List<OwnerLoanAccountRunningWaterRecord> list);

}
