package com.wms_main.model.dto.response.ycwms;


import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor
public class YcwmsResponse<T> {

    @JsonProperty("code")
    private Integer code;

    @JsonProperty("message")
    private String message;

    @JsonProperty("returnData")
    private T returnData;


    public YcwmsResponse(Integer code, String message, T returnData) {
        this.code = code;
        this.message = message;
        this.returnData = returnData;
    }

    public YcwmsResponse(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static <T> YcwmsResponse<T> success(String message, T returnData) {
        return new YcwmsResponse<>(0, message, returnData);
    }

    public static <T> YcwmsResponse<T> success(T returnData) {
        return new YcwmsResponse<>(0, "success", returnData);
    }

    public static <T> YcwmsResponse<T> error(String message, T returnData) {
        return new YcwmsResponse<>(1, message, returnData);
    }

    public static <T> YcwmsResponse<T> success() {
        return new YcwmsResponse<>(0, "success", null);
    }

}
