package org.example.Entity.Control.Data;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.example.Entity.Control.Base.Base;

import java.util.Objects;

/**
 * ==============================================================================
 * 功能描述：DataStore
 * ==============================================================================
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DataStore extends Base {
    public DataStore() {
        super();
        this.defaultXtype = "datastore";
    }

    /**
     * 此参数可以用来代替model参数. fields值应该是一个Ext.data.Field属性对象的集合
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public String url;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Boolean getIsApi() {
        if (url != null && !url.isEmpty()) {
            return true;
        }
        return null;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Object getApi() {
        if ((ApiDataNode != null && !ApiDataNode.isEmpty()) || (ApiSuccNode != null && !ApiSuccNode.isEmpty()) || (ApiSuccVal != null && !ApiSuccVal.isEmpty())) {
            return new Object() {
                public final Object reader = new Object() {
                    public final String success = ApiSuccNode;
                    public final String data = ApiDataNode;
                    public final String successVal = ApiSuccVal;
                };
            };
        }
        return null;
    }

    @JsonIgnore
    public String ApiDataNode;

    @JsonIgnore
    public String ApiSuccNode;

    @JsonIgnore
    public String ApiSuccVal;

    /**
     * 此参数可以用来代替model参数. fields值应该是一个Ext.data.Field属性对象的集合
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Object[] fields;

    /**
     * 数据
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Object data;

    /**
     * 存在的参数
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Object extraParams;

}