package com.palmnest.application.core.util;

import com.palmnest.application.AppConstants;
import com.palmnest.application.bean.AppCommonResultDto;
import com.palmnest.application.bean.AppResultDto;
import com.palmnest.application.bean.AppTokResultDto;

/**
 * 通用返回创建类
 *
 * @author wangxz
 * <p>
 * 2018年4月24日
 */
public class AppResultUtil {

	public static AppResultDto createSuccesDto() {
		return new AppCommonResultDto(AppConstants.SUCCESS_CODE, "成功", "");
	}

	public static AppResultDto createSuccesDto(Object data) {
		return new AppCommonResultDto(AppConstants.SUCCESS_CODE, "成功", data);
	}

	public static AppResultDto createSuccesDto(String msg, Object data) {
		return new AppCommonResultDto(AppConstants.SUCCESS_CODE, msg, data);
	}

	public static AppResultDto createErrorDto(String code, String msg) {
		return new AppResultDto(code, msg);
	}

	public static AppResultDto createCommonDto(String code, String msg, Object data) {
		return new AppCommonResultDto(code, msg, data);
	}

	public static AppTokResultDto createTokSuccessDto(String token) {
		return new AppTokResultDto(token, AppConstants.TOK_SUCCESS_CODE, "交易成功!");
	}

	public static AppTokResultDto createTokErrorDto(String token) {
		return new AppTokResultDto(token, AppConstants.TOK_FAIL_CODE, "获取AccessToken失败!");
	}

	public static AppTokResultDto createTokErrorDto(String token, String msg) {
		return new AppTokResultDto(token, AppConstants.TOK_FAIL_CODE, msg);
	}
}
