package net.yyc.common.taxhelper.entity.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
import org.springframework.context.annotation.Scope;

import java.io.Serializable;

/**
 * {@code TaxHelperResponse} class is taxhelper base response
 *
 * @author Hengchen.Sun
 * @version 1.0.0
 * @date 2021-02-22
 * @since ver.1.0.0
 */
@ToString
@Data
public class TaxHelperResponse implements Serializable {
	private static final long serialVersionUID = -5886366067119826805L;

	/**
	 * 业务码
	 */
	private String code;

	/**
	 * 信息
	 */
	private String message;

	/**
	 * 额外数据
	 */
	@JsonInclude(JsonInclude.Include.NON_NULL)
	private String data;

	/**
	 * 记录token
	 */
	@JsonInclude(JsonInclude.Include.NON_NULL)
	private String token;

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

	public TaxHelperResponse(String code, String message, String data) {
		this(code, message);
		this.data = data;
	}

	public TaxHelperResponse(String code, String message, String data, String token) {
		this(code, message, data);
		this.token = token;
	}

	/**
	 * 是否成功
	 */
	public boolean success() {
		return "2000".equals(this.code);
	}
}
