package com.jwipc.tender.model.query;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.enums.SqlLike;
import com.baomidou.mybatisplus.core.toolkit.sql.SqlUtils;
import com.google.common.base.Strings;
import com.jwipc.query.BasePageQuery;
import lombok.Data;

import java.util.Collections;
import java.util.List;

/**
 * @author Al
 * @create 2024-03-02 12:09
 */
@Data
public class BidQuotaQuery extends BasePageQuery {
    private Integer year;
    private String material;
    private String supplier;
    private String accelinkType;
    private String group;
    private Integer quotaDateType;
    private String type;
    private String mat;
    private String supplierCodeOrName;

    public String getTypeLike() {
        if (!Strings.isNullOrEmpty(this.type)) {
            return SqlUtils.concatLike(this.type, SqlLike.DEFAULT);
        }
        return this.type;
    }

    public String getMatLike() {
        if (!Strings.isNullOrEmpty(this.mat)) {
            return SqlUtils.concatLike(this.mat, SqlLike.DEFAULT);
        }
        return this.mat;
    }

    public String getSupplierCodeOrNameLike() {
        if (!Strings.isNullOrEmpty(this.supplierCodeOrName)) {
            return SqlUtils.concatLike(this.supplierCodeOrName, SqlLike.DEFAULT);
        }
        return this.supplierCodeOrName;
    }

    public List<String> getSupplierList() {
        if (!Strings.isNullOrEmpty(this.supplier)) {
            return StrUtil.split(this.supplier, ',');
        }
        return Collections.emptyList();
    }

    public List<String> getMaterialList() {
        if (!Strings.isNullOrEmpty(this.material)) {
            return StrUtil.split(this.material, ',');
        }
        return Collections.emptyList();
    }
    public List<String> getAccelinkTypeList() {
        if (!Strings.isNullOrEmpty(this.accelinkType)) {
            return StrUtil.split(this.accelinkType, ',');
        }
        return Collections.emptyList();
    }
}
