package com.purui.prims.headless.api.pojo.request;

import com.purui.prims.common.pojo.DataFormat;
import com.purui.prims.headless.api.pojo.RelateDimension;
import com.purui.prims.headless.api.pojo.SchemaItem;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Map;


@Data
@ApiModel(value = "指标基础Req")
public class MetricBaseReq extends SchemaItem {

    @ApiModelProperty(value = "模型ID")
    private Long modelId;

    @ApiModelProperty(value = "别名")
    private String alias;

    @ApiModelProperty(value = "数据格式类型")
    private String dataFormatType;

    @ApiModelProperty(value = "数据格式")
    private DataFormat dataFormat;

    @ApiModelProperty(value = "分类")
    private List<String> classifications;

    @ApiModelProperty(value = "关联维度")
    private RelateDimension relateDimension;

    // 同比，环比，排名需要的内容可以存入该对象中
    @ApiModelProperty(value = "扩展信息")
    private Map<String, Object> ext;

    // 统计周期
    @ApiModelProperty(value = "统计周期")
    private Integer periodId;

    // 算子
    @ApiModelProperty(value = "算子")
    private String operations;

    // 时间维度ID
    @ApiModelProperty(value = "时间维度ID")
    private Long dateDimId;

    // 业务限定
    @ApiModelProperty(value = "业务限定")
    private Integer conditionId;

    // 业务负责人
    @ApiModelProperty(value = "业务负责人")
    private String director;

    public String getClassifications() {
        if (classifications == null) {
            return null;
        }
        if (CollectionUtils.isEmpty(classifications)) {
            return "";
        }
        return StringUtils.join(classifications, ",");
    }

}
