package cn.cecep.talroad.vo.query.analysis;

import cn.cecep.talroad.common.core.domain.query.PageQuery;
import cn.cecep.talroad.domain.analysis.BasThresholdConfig;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class BasThresholdConfigQuery extends PageQuery {

    @ApiModelProperty(value = "主键")
    private Long dataId;
    @ApiModelProperty(value = "分析任务名称")
    private String taskName;
    @ApiModelProperty(value = "参数编码")
    private String paramCode;
    @ApiModelProperty(value = "参数名称")
    private String paramName;
    @ApiModelProperty(value = "阈值频次：D:日 H：小时")
    private String frequency;
    @ApiModelProperty(value = "阈值")
    private String thresholdValue;
    @ApiModelProperty(value = "单位")
    private String unit;
    @ApiModelProperty(value = "备注")
    private String remark;
    @ApiModelProperty(value = "创建人")
    private String createBy;
    @ApiModelProperty(value = "创建时间")
    private String createTime;
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    @ApiModelProperty(value = "更新时间")
    private String updateTime;
    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BasThresholdConfig> createLambdaQueryWrapper(BasThresholdConfigQuery query) {
        QueryWrapper<BasThresholdConfig> wrapper = new QueryWrapper<>();
        wrapper.eq(ObjectUtil.isNotEmpty(query.getDataId()), "data_id", query.getDataId());
        wrapper.like(ObjectUtil.isNotEmpty(query.getTaskName()), "task_name", query.getTaskName());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getParamCode()), "param_code", query.getParamCode());
        wrapper.like(ObjectUtil.isNotEmpty(query.getParamName()), "param_name", query.getParamName());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getFrequency()), "frequency", query.getFrequency());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getThresholdValue()), "threshold_value", query.getThresholdValue());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getUnit()), "unit", query.getUnit());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getRemark()), "remark", query.getRemark());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getCreateBy()), "create_by", query.getCreateBy());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getCreateTime()), "create_time", query.getCreateTime());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getUpdateBy()), "update_by", query.getUpdateBy());
        wrapper.eq(ObjectUtil.isNotEmpty(query.getUpdateTime()), "update_time", query.getUpdateTime());
        wrapper.orderBy(true,true,"update_time DESC NULLS LAST,create_time DESC NULLS LAST,data_id");
        return wrapper;
    }
}
