112 lines
2.9 KiB
C#
112 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MyCode.Project.Infrastructure.JackYun
|
|
{
|
|
/// <summary>
|
|
/// API调用返回结果。
|
|
/// </summary>
|
|
public class JackyunResponse
|
|
{
|
|
/// <summary>
|
|
/// 构造器
|
|
/// </summary>
|
|
/// <param name="result">业务信息结果</param>
|
|
/// <param name="subCode">子级错误码</param>
|
|
/// <param name="msg">错误消息</param>
|
|
/// <param name="contextId"></param>
|
|
public JackyunResponse(Object result, string subCode, string msg, string contextId)
|
|
{
|
|
|
|
Dictionary<string, Object> dictionary = new Dictionary<string, Object>();
|
|
dictionary.Add("data", result);
|
|
dictionary.Add("contextId", contextId);
|
|
this.result = dictionary;
|
|
this.subCode = subCode;
|
|
this.msg = msg;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 构造器。
|
|
/// </summary>
|
|
/// <param name="result">业务信息结果</param>
|
|
/// <param name="subCode">子级错误码</param>
|
|
/// <param name="msg">错误消息</param>
|
|
public JackyunResponse(Object result, string subCode, string msg) : this(result, subCode, msg, null)
|
|
{
|
|
;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 构造器。
|
|
/// </summary>
|
|
/// <param name="subCode">子级错误码</param>
|
|
/// <param name="msg">错误消息</param>
|
|
public JackyunResponse(string subCode, string msg) : this(null, subCode, msg, null)
|
|
{
|
|
;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 构造器 无参
|
|
/// </summary>
|
|
public JackyunResponse()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// 返回码
|
|
/// </summary>
|
|
public string code { get; set; }
|
|
|
|
/// <summary>
|
|
/// 子级错误码
|
|
/// </summary>
|
|
public string subCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 错误消息
|
|
/// </summary>
|
|
public string msg { get; set; }
|
|
|
|
/// <summary>
|
|
/// 错误结果
|
|
/// </summary>
|
|
public Object result { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// 当请求失败
|
|
/// </summary>
|
|
/// <param name="msg">返回消息</param>
|
|
/// <param name="subCode">子级返回码</param>
|
|
public void onFail(string msg, string subCode)
|
|
{
|
|
this.code = "0";
|
|
this.msg = msg;
|
|
this.subCode = subCode;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 当请求成功
|
|
/// </summary>
|
|
public void onSuccess()
|
|
{
|
|
this.code = "200";
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否成功
|
|
/// </summary>
|
|
/// <returns>是否成功</returns>
|
|
public bool isSuccess()
|
|
{
|
|
return "200".Equals(this.code);
|
|
}
|
|
}
|
|
}
|