package com.zksy.common.utils.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Author sy
 * @Date 2022/04/11
 * @Description
 */
@Data
@ApiModel
public class ResponseBase {
    @ApiModelProperty(name = "code", value = "返回码", dataType = "int", example = "200", position = 1)
    private Integer code;
    @ApiModelProperty(name = "message", value = "返回描述", dataType = "String", example = "success", position = 2)
    private String message;
    @ApiModelProperty(name = "error", value = "返回描述", dataType = "String", example = "success", position = 3)
    private String error;
    @ApiModelProperty(name = "timestamp", value = "服务器时间戳", dataType = "Long", example = "success", position = 4)
    private Long timestamp;

    public ResponseBase() {
    }

    public ResponseBase(ResponseCode responseCode) {
        this.code = responseCode.code;
        this.message = responseCode.message;
        this.timestamp = System.currentTimeMillis();
    }

    public ResponseBase(ResponseCode responseCode, String error) {
        this.code = responseCode.code;
        this.message = responseCode.message;
        this.error = error;
        this.timestamp = System.currentTimeMillis();
    }

    public ResponseBase(Integer code, String message) {
        this.code = code;
        this.message = message;
        this.timestamp = System.currentTimeMillis();
    }

    public ResponseBase(Integer code, String message, String error) {
        this.code = code;
        this.error = error;
        this.message = message;
        this.timestamp = System.currentTimeMillis();
    }

}
