package com.malk.aiwei.server;

import lombok.Data;

@Data
public class YDSearch {

    // YidaSearch yidaSearch=new YidaSearch("textField_lk7v5k5f",contract.getContractNo(),"同步合同档案台账", YidaSearch.Type.TEXT_FIELD,YidaSearch.Operator.EQ);


    private String key;
    private Object value;
    // 组件值类型
    private String type;
    // 操作符
    private String operator;
    // 组件名称
    private String componentName;
    // 查询子表使用
    private String parentId;

    public YDSearch(String key, Object value, String type, String operator, String componentName){
        this.key=key;
        this.value=value;
        this.type=type;
        this.operator=operator;
        this.componentName=componentName;
    }

    public YDSearch(String key, Object value, Type type, Operator operator, String componentName, String parentId) {
        this.key = key;
        this.value = value;
        this.type = type.type;
        this.operator = operator.operator;
        this.componentName = componentName;
        this.parentId = parentId;
    }

    public YDSearch(String key, Object value, String componentName, Type type, Operator operator){
        this.key=key;
        this.value=value;
        this.type=type.type;
        this.operator=operator.operator;
        this.componentName=componentName;
    }

    // 缺少来这里找 https://open.dingtalk.com/document/orgapp-server/use-the-filter-conditions-in-the-form-data-management-for
    public enum Type{
        TEXT_FIELD("TEXT"),
        TEXTAREA_FIELD("TEXT"),
        NUMBER_FIELD("DOUBLE"),
        RATE_FIELD("DOUBLE"),
        RADIO_FIELD("ARRAY"),
        CHECKBOX_FIELD("ARRAY"),
        MULTISELECT_FIELD("ARRAY"),
        CASCADESELECT_FIELD("STRING"),
        DATE_FIELD("DOUBLE"),
        CASCADEDATE_FIELD("DOUBLE"),
        IMAGE_FIELD("TEXT"),
        ATTACHMENT_FIELD("TEXT"),
        EMPLOYEE_FIELD("STRING"),
        DEPARTMENTSELECT_FIELD("ARRAY");

        public final String type;

        Type(String type){
            this.type=type;
        }
    }

    public enum Operator{
        EQ("eq"),
        LIKE("like"),
        GT("gt"),
        GE("ge"),
        LT("lt"),
        LE("le"),
        BETWEEN("between"),
        CONTAINS("contains");

        public final String operator;

        Operator(String operator){
            this.operator=operator;
        }
    }

}
