package org.jeecg.module.custom.ocr.utils.requestFormat;


import java.io.Serializable;

/**
 * Created by zhangyong on 2018/2/9.
 */
public class SearchQueryForm implements Serializable {
    private static final long serialVersionUID = 1L;
    private String field;// 字段名称 username and  t1.username = %111%(vachar)
    private String op;// 比对条件  =
    private Object value;// 比对内容 111
    private String type;// 类型 ()
    private String rulesOp;// 搜索条件的关联方式，或/与（and/or）
    private String tablenameother = "";// 数据表别名
    private String dataOp;// 数据库中的比较条件,根据op属性获取
    private String likestar = "";//针对like需要特殊修改
    private String likeend = "";//针对like需要特殊修改

    public String getField() {
        return field;
    }

    public void setField(String field) {
        this.field = field;
    }

    public String getOp() {
        return op;
    }

    public void setOp(String op) {
        this.op = op;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getRulesOp() {
        return rulesOp;
    }

    public void setRulesOp(String rulesOp) {
        this.rulesOp = rulesOp;
    }

    public String getTablenameother() {
        return tablenameother;
    }

    public void setTablenameother(String tablenameother) {
        this.tablenameother = tablenameother;
    }

    public String getDataOp() {
        this.setDataOp(SearchQueryUtil.filterMap.get(this.getOp()));
        return dataOp;
    }

    public void setDataOp(String dataOp) {
        this.dataOp = dataOp;
    }

    public String getLikestar() {
        if(SearchQueryUtil.filterMap.get(this.getOp()).equals(SearchQueryConstant.SEARCH_LIKE)){
            this.setLikestar("CONCAT('%',");
        }else  if(SearchQueryUtil.filterMap.get(this.getOp()).equals(SearchQueryConstant.SEARCH_IN)){
            this.setLikestar("(");
        }

        return likestar;
    }

    public void setLikestar(String likestar) {
        this.likestar = likestar;
    }

    public String getLikeend() {
        if(SearchQueryUtil.filterMap.get(this.getOp()).equals(SearchQueryConstant.SEARCH_LIKE)){
            this.setLikeend(",'%')");
        }else  if(SearchQueryUtil.filterMap.get(this.getOp()).equals(SearchQueryConstant.SEARCH_IN)){
            this.setLikeend(")");
        }
        return likeend;
    }

    public void setLikeend(String likeend) {
        this.likeend = likeend;
    }
}
