package com.lanyuanxiaoyao.service.configuration.entity;

import java.util.Map;

/**
 * Amis 组件结构化返回值
 *
 * @author lanyuanxiaoyao
 * @date 2022-09-21
 */
public class AmisResponse {
    private Integer status;
    private String message;
    private Map<String, Object> data;

    public AmisResponse(Builder builder) {
        this.status = builder.status;
        this.message = builder.message;
        this.data = builder.data;
    }

    public static Builder builder() {
        return new Builder();
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public AmisResponse withData(String key, Object value) {
        data.put(key, value);
        return this;
    }

    @Override
    public String toString() {
        return "AmisResponse{" +
                "status=" + status +
                ", message='" + message + '\'' +
                ", data=" + data +
                '}';
    }

    public static final class Builder {
        private Integer status = 0;
        private String message = "";
        private Map<String, Object> data;

        private Builder() {
        }

        public Builder status(Integer status) {
            this.status = status;
            return this;
        }

        public Builder message(String message) {
            this.message = message;
            return this;
        }

        public Builder data(Map<String, Object> data) {
            this.data = data;
            return this;
        }

        public AmisResponse build() {
            return new AmisResponse(this);
        }
    }
}
