package com.uas.eis.sdk.entity;

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

@Data
@NoArgsConstructor
public class StepWorkApiResult<T> {

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

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


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

    private Boolean success;

    public int getCode() {
        return code;
    }

    public StepWorkApiResult<T> setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public StepWorkApiResult<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }
    public T getData() {
        return data;
    }

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

    public Boolean getSuccess() {
        return success;
    }

    public StepWorkApiResult<T> setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    @Override
    public String toString() {
        return "Result{" +
                ", code=" + code +
                ", msg=" + msg +
                ", data=" + data +
                ", success=" + success +
                '}';
    }

    public StepWorkApiResult(Boolean success,int code, String message, T data){
        this.success = success;
        this.code = code;
        this.msg = message;
        this.data = data;
    }

    public StepWorkApiResult(Boolean success,int code, String message){
        this.success = success;
        this.code = code;
        this.msg = message;
    }

    public StepWorkApiResult(ErrorMessage errorMessage){
        this.success = false;
        this.code = 400;
        this.msg = errorMessage.getMessage();
    }

}
