using HH.WMS.Entitys.External;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace HH.WMS.Common.Response
|
{
|
/// <summary>
|
/// 外部请求本地 返回消息
|
/// </summary>
|
public class ExternalResponse
|
{
|
public ExternalResponse()
|
{
|
this.okList = new List<OkTask>();
|
this.failList = new List<FailTask>();
|
this.tasks = new List<OutCompensateResponse>();
|
}
|
#region 失败
|
/// <summary>
|
/// 失败
|
/// </summary>
|
/// <typeparam name="T"></typeparam>
|
/// <param name="req"></param>
|
/// <param name="msg"></param>
|
/// <returns></returns>
|
public ExternalResponse Error<T>(T req, string msg, List<T> reqList = null)
|
{
|
this.success = false;
|
if (string.IsNullOrEmpty(msg))
|
{
|
if (failList.Any())
|
msg = failList[0].errMsg;
|
}
|
this.errMsg = msg;
|
this.errCode = this.failList.Any() ? failList[0].errCode : "";
|
return this;
|
}
|
public ExternalResponse ErrorList<T>(List<T> req, string msg, List<T> reqList = null)
|
{
|
this.success = false;
|
this.errMsg = msg;
|
// this.WriteInterfaceLog<T>(req, reqList);
|
return this;
|
}
|
#endregion
|
|
#region 成功
|
/// <summary>
|
/// 成功
|
/// </summary>
|
/// <typeparam name="T"></typeparam>
|
/// <param name="req"></param>
|
/// <returns></returns>
|
public ExternalResponse Ok<T>(T req, List<T> reqList = null)
|
{
|
this.success = true;
|
return this;
|
}
|
#endregion
|
public bool success { get; set; }
|
|
/// <summary>
|
/// 错误码 0 正常 1
|
/// </summary>
|
public string errCode { get; set; }
|
public string errMsg { get; set; }
|
public List<OkTask> okList { get; set; }
|
public List<FailTask> failList { get; set; }
|
public List<OutCompensateResponse> tasks { get; set; }
|
}
|
}
|