package org.jeecg.modules.adweb.marketing.googleads.vo;

import lombok.Data;

import org.jeecg.modules.adweb.common.enums.CountryCode;
import org.jeecg.modules.adweb.marketing.googleads.dto.MetricsDTO;

import java.util.Map;

/**
 * @author wfansh
 */
@Data
public class CountryStatsVO {

    private String country;

    private String countryName;

    private String countryCode;

    private long impressions; // 展示数

    private long clicks; // 点击数

    public static CountryStatsVO fromMetricsDTO(Map.Entry<String, MetricsDTO> metricsDTOEntry) {
        CountryStatsVO countryStatsVO = new CountryStatsVO();

        CountryCode countryCode = CountryCode.valueOfCode(metricsDTOEntry.getKey());
        countryStatsVO.setCountry(countryCode.getName());
        countryStatsVO.setCountryName(countryCode.getCnName());
        countryStatsVO.setCountryCode(countryCode.getCode());

        MetricsDTO metricsDTO = metricsDTOEntry.getValue();
        countryStatsVO.setImpressions(metricsDTO.getImpressions());
        countryStatsVO.setClicks(metricsDTO.getClicks());

        return countryStatsVO;
    }
}
