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

import com.zcloud.personnel.positioning.dto.clientobject.TerminalAppCO;
import com.zcloud.personnel.positioning.dto.clientobject.TerminalAppCompanyCO;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalAppCompanyStatDO;
import com.zcloud.personnel.positioning.persistence.dataobject.TerminalAppDetailDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

import java.util.List;

@Mapper(componentModel = "spring")
public interface TerminalAppCoConvertor {
    List<TerminalAppCompanyCO> convertCompanyStats(List<TerminalAppCompanyStatDO> dataObjects);

    @Mapping(source = "activeIdCardNo", target = "bindIdCardNo")
    @Mapping(target = "enableName", expression = "java(enableName(dataObject.getEnable()))")
    TerminalAppCO convertApp(TerminalAppDetailDO dataObject);

    List<TerminalAppCO> convertApps(List<TerminalAppDetailDO> dataObjects);

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