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

import com.purui.prims.common.pojo.Constants;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "维度")
@Builder
public class Dim {

    @ApiModelProperty(value = "维度名称")
    private String name;
    // 维度类型
    @ApiModelProperty(value = "维度类型")
    private String type;

    @ApiModelProperty(value = "表达式")
    private String expr;

    @ApiModelProperty(value = "日期格式")
    private String dateFormat = Constants.DAY_FORMAT;

    @ApiModelProperty(value = "时间类型参数")
    private DimensionTimeTypeParams typeParams;

    @ApiModelProperty(value = "是否创建维度")
    private Integer isCreateDimension = 0;

    @ApiModelProperty(value = "业务名称")
    private String bizName;

    @ApiModelProperty(value = "描述")
    private String description;

    public Dim(String name, String bizName, String type, Integer isCreateDimension) {
        this.name = name;
        this.type = type;
        this.isCreateDimension = isCreateDimension;
        this.bizName = bizName;
    }

    public Dim(String name, String type, String expr, String dateFormat, DimensionTimeTypeParams typeParams,
               Integer isCreateDimension, String bizName) {
        this.name = name;
        this.type = type;
        this.expr = expr;
        this.dateFormat = dateFormat;
        this.typeParams = typeParams;
        this.isCreateDimension = isCreateDimension;
        this.bizName = bizName;
    }

    public static Dim getDefault() {
        return new Dim("日期", "time", "2023-05-28",
                Constants.DAY_FORMAT,
                new DimensionTimeTypeParams(true, "day"),
                0, "sys_imp_date"
        );
    }

    public String getFieldName() {
        return name;
    }

}
