Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit82d9a49

Browse files
committed
1.统一返回消息
1 parentf1aba50 commit82d9a49

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
usingDestinyCore.Enums;
2+
usingDestinyCore.Ui;
3+
usingMicrosoft.AspNetCore.Mvc;
4+
usingSystem;
5+
usingSystem.Collections.Generic;
6+
usingSystem.ComponentModel;
7+
usingSystem.Linq;
8+
usingSystem.Text;
9+
usingSystem.Threading.Tasks;
10+
11+
namespaceDestiny.Core.Flow.AspNetCore
12+
{
13+
/// <summary>
14+
/// 返回结果用来统一
15+
/// </summary>
16+
publicclassApiResult:JsonResult
17+
{
18+
publicApiResult():base(null)
19+
{
20+
21+
22+
}
23+
24+
publicApiResult(OperationResponseoperationResponse):base(null)
25+
{
26+
27+
this.Message=operationResponse.Message;
28+
this.Data=operationResponse.Data;
29+
this.Success=operationResponse.Success;
30+
this.Type=ToAjaxResultType(operationResponse.Type);
31+
}
32+
33+
34+
publicApiResult(stringmessage,boolsuccess,objectdata,StatusTypetype):base(null)
35+
{
36+
this.Message=message;
37+
this.Success=success;
38+
this.Data=data;
39+
this.Type=type;
40+
}
41+
42+
43+
publicstringMessage{get;set;}
44+
45+
publicobjectData{get;set;}
46+
47+
publicboolSuccess{get;set;}
48+
49+
publicStatusTypeType{get;set;}
50+
51+
52+
publicoverrideTaskExecuteResultAsync(ActionContextcontext)
53+
{
54+
base.Value=new
55+
{
56+
this.Message,
57+
this.Data,
58+
this.Success,
59+
this.Type
60+
61+
};
62+
returnbase.ExecuteResultAsync(context);
63+
}
64+
65+
66+
privateStatusTypeToAjaxResultType(OperationResponseTyperesponseType)
67+
{
68+
returnresponseTypeswitch
69+
{
70+
OperationResponseType.Success=>StatusType.Success,
71+
OperationResponseType.NoChanged=>StatusType.Info,
72+
_=>StatusType.Error,
73+
};
74+
}
75+
76+
}
77+
78+
79+
80+
}
81+
82+
publicenumStatusType
83+
{
84+
85+
/// <summary>
86+
/// 消息结果
87+
/// </summary>
88+
[Description("消息结果")]
89+
90+
Info=203,
91+
92+
/// <summary>
93+
/// 成功
94+
/// </summary>
95+
[Description("成功")]
96+
Success=200,
97+
98+
/// <summary>
99+
/// 错误
100+
/// </summary>
101+
[Description("错误")]
102+
Error=500,
103+
104+
/// <summary>
105+
/// 未经授权
106+
/// </summary>
107+
[Description("未经授权")]
108+
Unauthorized=401,
109+
110+
/// <summary>
111+
/// 已登录但权限不足
112+
/// </summary>
113+
[Description("当前用户权限不足")]
114+
Uncertified=403,
115+
116+
/// <summary>
117+
/// 功能资源找不到
118+
/// </summary>
119+
[Description("当前功能资源找不到")]
120+
NoFound=404
121+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp