package com.xunhong.erp.turbo.biz.infrastructure.convert;

import com.xunhong.erp.turbo.api.biz.dto.cmd.ExpenseRecordCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.cmd.ExpenseRecordUpdateCmd;
import com.xunhong.erp.turbo.biz.domain.entity.ExpenseRecord;
import com.xunhong.erp.turbo.biz.infrastructure.entity.ExpenseRecordDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.MappingTarget;
import org.mapstruct.NullValueCheckStrategy;

/**
 * @author shenyifei
 */
@Mapper(componentModel = "spring", nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface ExpenseRecordConvert {

	@Mapping(target = "expenseProvisionList", source = "expenseProvisionDOList")
	@Mapping(target = "expenseCostList", source = "expenseCostDOList")
	ExpenseRecord toExpenseRecord(ExpenseRecordDO expenseRecordDO);

	@Mapping(target = "totalVehicleCount", ignore = true)
	@Mapping(target = "totalProvision", ignore = true)
	@Mapping(target = "totalExpense", ignore = true)
	@Mapping(target = "expenseRecordId", ignore = true)
	@Mapping(target = "expenseProvisionDOList", ignore = true)
	@Mapping(target = "expenseCostDOList", ignore = true)
	@Mapping(target = "dailyProfit", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	ExpenseRecordDO toExpenseRecordDO(ExpenseRecordCreateCmd expenseRecordCreateCmd);

	@Mapping(target = "totalVehicleCount", ignore = true)
	@Mapping(target = "totalProvision", ignore = true)
	@Mapping(target = "totalExpense", ignore = true)
	@Mapping(target = "expenseProvisionDOList", ignore = true)
	@Mapping(target = "expenseCostDOList", ignore = true)
	@Mapping(target = "dailyProfit", ignore = true)
	@Mapping(target = "version", ignore = true)
	@Mapping(target = "updatedAt", ignore = true)
	@Mapping(target = "isDelete", ignore = true)
	@Mapping(target = "createdAt", ignore = true)
	void toExpenseRecordDO(@MappingTarget ExpenseRecordDO expenseRecordDO, ExpenseRecordUpdateCmd expenseRecordUpdateCmd);
}

