package cn.superdesk.uniorder.common.rest.response;


import cn.superdesk.uniorder.common.constants.ResponseResultConstants;

/**
 * @Description: 暂定:内部用
 * @Author: linjinyu
 * @CreateDate: 2021/3/5 下午1:31
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/3/5 下午1:31
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class ResponseResultInnerUtils<T> {

	private R<T> result;

	public ResponseResultInnerUtils() {
		result = new R<>();

		result.setCode(ResponseResultConstants.SUCCESS);
		result.setMessage("操作成功");
		result.setSuccess(true);

	}

	public R<T> setData(T t) {

		this.result.setCode(ResponseResultConstants.SUCCESS);
		this.result.setData(t);

		return this.result;
	}

	public R<T> setData(T t, String msg) {

		this.result.setCode(ResponseResultConstants.SUCCESS);
		this.result.setMessage(msg);
		this.result.setData(t);

		return this.result;
	}

	public R<T> setErrorMsg(String msg) {

		this.result.setCode(ResponseResultConstants.SERVER_ERROR);
		this.result.setMessage(msg);
		this.result.setSuccess(false);

		return this.result;
	}

	public R<T> setErrorMsg(Integer code, String msg) {

		this.result.setCode(code);
		this.result.setMessage(msg);
		this.result.setSuccess(false);

		return this.result;
	}
}
