package org.jeecg.common.system.query;

import org.jeecg.common.util.oConvertUtils;

/**
 * Query 规则 常量
 * @Author Scott
 * @Date 2019年02月14日
 */
public enum QueryRuleEnum {

    GT(">","gt","大于"),
    GE(">=","ge","大于等于"),
    LT("<","lt","小于"),
    LE("<=","le","小于等于"),
    EQ("=","eq","等于"),
    NE("!=","ne","不等于"),
    IN("IN","in","包含"),
    LIKE("LIKE","like","全模糊"),
    LEFT_LIKE("LEFT_LIKE","left_like","左模糊"),
    RIGHT_LIKE("RIGHT_LIKE","right_like","右模糊"),
    SQL_RULES("USE_SQL_RULES","ext","自定义SQL片段"),
	//qn补充
	EQ_NULL("EQ_NULL","eq_null","等于null"),
	NOT_NULL("NOT_NULL","not_null","不等于null"),
	EQ_EMPTY("EQ_EMPTY","eq_empty","等空串"),
	NOT_EMPTY("NOT_EMPTY","not_empty","不等于空串"),
	EQ_BLANK("EQ_BLANK","eq_blank","等于空串或null"),
	NOT_BLANK("NOT_BLANK","not_blank","不等于空串和null");


//	private static final String EQ_NULL = "!!null";
//	private static final String NOT_NULL = "!!!null";
//	private static final String EQ_EMPTY = "!!";
//	private static final String NOT_EMPTY = "!!!";
//	private static final String EQ_BLANK = "!!BLANK";
//	private static final String NOT_BLANK = "!!!BLANK";



	private String value;
    
    private String condition; 

    private String msg;

    QueryRuleEnum(String value, String condition, String msg){
        this.value = value;
        this.condition = condition;
        this.msg = msg;
    }

    public String getValue() {
        return value;
    }

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

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public static QueryRuleEnum getByValue(String value){
    	if(oConvertUtils.isEmpty(value)) {
    		return null;
    	}
        for(QueryRuleEnum val :values()){
            if (val.getValue().equals(value) || val.getCondition().equals(value)){
                return val;
            }
        }
        return  null;
    }
}
