Response.cs
3.88 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
namespace Hh.Mes.POJO.Response
{
public class Response
{
/// <summary>
/// 默认返回操作成功
/// </summary>
public Response(bool status = true, string msg = "业务数据操作成功!")
{
Code = status ? (int)RetCode.SUCCESS : (int)RetCode.INTERNAL_SERVER_ERROR;
Status = status;
Message = msg;
}
public int Code { get; set; }
public string Message { get; set; }
public bool Status { get; set; }
public int Count { get; set; }
/// <summary>
/// 登陆标识
/// </summary>
public string Token { get; set; }
public dynamic Result { get; set; }
/// <summary>
/// 统一返回前端失败
/// </summary>
/// <param name="msg">失败消息</param>
public virtual void ResponseErr(string msg)
{
Code = (int)RetCode.FAIL;
Message = msg;
Status = false;
}
/// <summary>
/// 统一返回前端失败
/// </summary>
/// <param name="msg">失败消息</param>
public virtual Response ResponseError(string msg = "业务数据操作失败")
{
Code = (int)RetCode.INTERNAL_SERVER_ERROR;
Message = msg;
Status = false;
return this;
}
/// <summary>
/// 统一返回前端成功
/// </summary>
public virtual Response ResponseSuccess(string msg = "业务数据操作成功!")
{
Code = (int)RetCode.SUCCESS;
Message = msg;
Status = true;
return this;
}
}
public class Response<T> : Response
{
/// <summary>
/// 回传的结果
/// </summary>
public new T Result { get; set; }
public Response(bool status, string msg) : base(status, msg)
{
}
public Response()
{
}
}
public class ResponseUpstream<T> : Response<T>
{
public string plmeid { get; set; }
//public string flag { get { return Code == (int)RetCode.SUCCESS ? "1" : "0"; } }
//public string msg { get { return Message; } }
public ResponseUpstream(string plmeid, bool status = true, string msg = "业务数据操作成功!") : base(status, msg)
{
this.plmeid = plmeid;
}
}
public class MOMResult
{
public string PLMEID { get; set; }
public string MSG { get; set; }
/// <summary>
///
/// </summary>
public string STATUS { get; set; }
/// <summary>
///
/// </summary>
public string TEMPCODE { get; set; }
/// <summary>
///
/// </summary>
public string FLAG { get; set; }
/// <summary>
///
/// </summary>
public string HEAD { get; set; }
/// <summary>
///
/// </summary>
public string DATAS { get; set; }
}
public enum RetCode
{
OK = 0,
/// <summary>
/// 成功
/// </summary>
SUCCESS = 200,
/// <summary>
/// 失败
/// </summary>
FAIL = 400,
/// <summary>
/// 未认证(签名错误)
/// </summary>
UNAUTHORIZED = 401,
/// <summary>
/// 找不到请求文件
/// </summary>
NoHandlerFoundException = 404,
/// <summary>
/// 未登录
/// </summary>
UNAUTHEN = 401,
/// <summary>
/// 未授权,拒绝访问
/// </summary>
UNAUTHZ = 403,
/// <summary>
/// 服务器内部错误
/// </summary>
INTERNAL_SERVER_ERROR = 500,
/// <summary>
/// 业务处理错误
/// </summary>
Business_ERROR = 600,
}
}