package com.persagy.bdtp.adm.common;

import com.persagy.dmp.common.constant.ResponseCode;
import com.persagy.dmp.common.model.response.CommonResult;
import lombok.Data;

@Data
public class AdmResult<T> {

	private String code;

	private String message;

	private T data;

	public AdmResult(String code, String message) {
		this(code, message, null);
	}

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

	public AdmResult(CommonResult<T> commonResult) {
		this.code = commonResult.getResult();
		this.message = commonResult.getMessage();
		this.data = commonResult.getData();
	}

	public static <T> AdmResult<T> success(T data){
		return new AdmResult<>(ResponseCode.A00000.getCode(), null, data);
	}

}
