package com.uas.eis.sdk.entity;

import com.uas.eis.entity.ErrorMessage;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class ApiResult<T> {

    /**
     * 自定义业务码
     */
    private String code;

    /**
     * 自定义业务提示说明
     */
    private String message;


    private String requestId;

    /**
     * 自定义返回 数据结果集
     */
    private T data;

    public String getCode() {
        return code;
    }

    public ApiResult<T> setCode(String code) {
        this.code = code;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public ApiResult<T> setMessage(String message) {
        this.message = message;
        return this;
    }

    public String getRequestId() {
        return requestId;
    }

    public ApiResult<T> setRequestId(String requestId) {
        this.requestId = requestId;
        return this;
    }

    public T getData() {
        return data;
    }

    public ApiResult<T> setData(T data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return "Result{" +
                ", code=" + code +
                ", message=" + message +
                ", requestId='" + requestId + '\'' +
                ", data=" + data +
                '}';
    }

    public ApiResult(String code, String message,String requestId,T data){
        this.code = code;
        this.message = message;
        this.requestId = requestId;
        this.data = data;
    }

    public ApiResult(String code, String message,String requestId){
        this.code = code;
        this.message = message;
        this.requestId = requestId;
    }

    public ApiResult(ErrorMessage errorMessage, String requestId){
        this.code = errorMessage.getCode();
        this.message = errorMessage.getMessage();
        this.requestId = requestId;
    }
}
