package com.zcloud.personnel.positioning.command.convertor;

import com.zcloud.personnel.positioning.dto.clientobject.TerminalCardCO;
import com.zcloud.personnel.positioning.dto.clientobject.TerminalCardCompanyCO;
import com.zcloud.personnel.positioning.dto.clientobject.TerminalCardCompanyOptionCO;
import com.zcloud.personnel.positioning.dto.clientobject.TerminalCardPersonOptionCO;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalCardCompanyOptionDO;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalCardCompanyStatDO;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalCardDetailDO;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalCardPersonOptionDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper(componentModel = "spring")
public interface TerminalCardCoConvertor {
    List<TerminalCardCompanyCO> convertCompanyStats(List<TerminalCardCompanyStatDO> dataObjects);

    @Mapping(source = "activeIdCardNo", target = "bindIdCardNo")
    @Mapping(target = "enableName", expression = "java(enableName(dataObject.getEnable()))")
    TerminalCardCO convertCard(TerminalCardDetailDO dataObject);

    List<TerminalCardCO> convertCards(List<TerminalCardDetailDO> dataObjects);

    List<TerminalCardPersonOptionCO> convertPersonOptions(List<TerminalCardPersonOptionDO> dataObjects);

    List<TerminalCardCompanyOptionCO> convertCompanyOptions(List<TerminalCardCompanyOptionDO> dataObjects);

    default String enableName(Integer enable) {
        return Integer.valueOf(1).equals(enable) ? "启用" : "停用";
    }
}
