package org.example.Entity.BaseResponse;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.example.Utils.NativeExtensionUtils;
import org.example.Utils.WebConfigUtil_web;

import java.util.Hashtable;
import java.util.Map;

/**
 * ==============================================================================
 * 功能描述：BaseResponse
 * ==============================================================================
 */
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BaseResponse {
    /**
     * 是否成功
     */
    private boolean success;

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    private String sql;
    /**
     * 文字信息
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String msg;

    /**
     * 数据总数
     */
    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
    private int tot = 0;

    /**
     * 返回的主数据
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object data;

    /**
     * 如有其它数据
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Object other;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Object attc;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String token;

    private Boolean sharLogin;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Boolean getSharToken() {
        if (token != null && !token.isEmpty()) {
            return NativeExtensionUtils.toBoolean(WebConfigUtil_web.get("SharLogin", "1"));
        }
        return sharLogin;
    }

    public void setSharToken(Boolean value) {
        this.sharLogin = value;
    }

    /**
     * webversion 用于更新前端
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String webVer;

    /**
     * json编码后的字符串
     */
    @JsonIgnore
    private String encodedResult;

    /**
     * json编码后的字符串
     */
    @JsonIgnore
    private boolean writeResponse = true;

    /**
     * webversion 用于更新前端
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Map<?, ?> printInfo;

    // Getters and Setters
    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public String getMsg() {
        return msg;
    }

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

    @JsonInclude(JsonInclude.Include.NON_DEFAULT)
    public int getTot() {
        return tot;
    }

    public void setTot(int tot) {
        this.tot = tot;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Object getOther() {
        return other;
    }

    public void setOther(Object other) {
        this.other = other;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public String getWebVer() {
        return webVer;
    }

    public void setWebVer(String webVer) {
        this.webVer = webVer;
    }

    @JsonIgnore
    public String getEncodedResult() {
        return encodedResult;
    }

    public void setEncodedResult(String encodedResult) {
        this.encodedResult = encodedResult;
    }

    @JsonIgnore
    public boolean isWriteResponse() {
        return writeResponse;
    }

    public void setWriteResponse(boolean writeResponse) {
        this.writeResponse = writeResponse;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Map<?, ?> getPrintInfo() {
        return printInfo;
    }

    public void setPrintInfo(Map<?, ?> printInfo) {
        this.printInfo = printInfo;
    }

    @JsonInclude(JsonInclude.Include.NON_NULL)
    public Map<String, Object> AppCfg;
}