jt
2021-06-10 5d0d028456874576560552f5a5c4e8b801786f11
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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; }
    }
}