package com.hzya.frame.basedao.entity;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @Author lvleigang
 * @Description  连接条件
 * @Date 10:40 上午 2022/12/9
 * @return
 **/
public enum ConditionTypeBack {
    //数据库类型
    等于("等于", "="),
    不等于("不等于", "!="),
    小于("小于", "<"),
    小于等于("小于等于", "<="),
    大于("大于", ">"),
    大于等于("大于等于", ">="),
    包含("包含", "like"),
    不包含("不包含", "not like"),
    开始以("开始以", "like"),
    开始不是以("开始不是以", "not like"),
    结束以("结束以", "like"),
    结束不是以("结束不是以", "not like"),
    是null("是null", "is null"),
    不是null("不是null", "is not null"),
    是空的("是空的", "is ''"),
    不是空的("不是空的", "is not ''"),
    介于("介于", "between"),
    不介于("不介于", "not between"),
    在列表("在列表", "in"),
    不在列表("不在列表", "not in");

    @JsonValue
    private String name;
    private String value;

    private ConditionTypeBack(String name, String value) {
        this.name = name;
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

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


    /**
     * 增加映射方法，并为方法添加@JsonCreator
     */
    @JsonCreator
    public static ConditionTypeBack getConditionTypeFromCodeValue(String value) {
        for (ConditionTypeBack dep : ConditionTypeBack.values()) {
            if (dep.getValue().equals(value)) {
                return dep;
            }
        }
        return null;
    }
    /**
     * 增加映射方法，并为方法添加@JsonCreator
     */
    @JsonCreator
    public static ConditionTypeBack getConditionTypeFromCodeName(String value) {
        for (ConditionTypeBack dep : ConditionTypeBack.values()) {
            if (dep.getName().equals(value)) {
                return dep;
            }
        }
        return null;
    }
    @Override
    public String toString() {
        return "ConditionType{" +
                "name='" + name + '\'' +
                ", value='" + value + '\'' +
                '}';
    }
}
