-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
106 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using DestinyCore.AspNetCore; | ||
using DestinyCore.Enums; | ||
using DestinyCore.Extensions; | ||
using DestinyCore.Filter; | ||
using DestinyCore.Helpers; | ||
using DestinyCore.Ui; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Destiny.Core.Flow.AspNetCore | ||
{ | ||
public class AjaxResult<TData> : ResultBase<TData>, IHasResultType<AjaxResultType> | ||
{ | ||
public AjaxResultType Type | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
public AjaxResult() | ||
{ | ||
} | ||
|
||
public AjaxResult(AjaxResultType type = AjaxResultType.Success) | ||
: this("", default(TData), type) | ||
{ | ||
} | ||
|
||
public AjaxResult(string message, AjaxResultType type = AjaxResultType.Success,TData data= default(TData)) | ||
: this(message, data, type) | ||
{ | ||
} | ||
|
||
public AjaxResult(AjaxResultType type = AjaxResultType.Success, TData data= default(TData)) | ||
: this("", data, type) | ||
{ | ||
} | ||
|
||
public AjaxResult(string message, TData data, AjaxResultType type) | ||
{ | ||
Message = message; | ||
Data = data; | ||
Type = type; | ||
Success = Succeeded(); | ||
} | ||
|
||
public AjaxResult(string message, bool success, TData data, AjaxResultType type) | ||
{ | ||
Message = message; | ||
Data = data; | ||
Type = type; | ||
Success = success; | ||
} | ||
|
||
public bool Succeeded() | ||
{ | ||
return Type == AjaxResultType.Success; | ||
} | ||
|
||
public bool Error() | ||
{ | ||
return Type == AjaxResultType.Error; | ||
} | ||
|
||
public object ToObject() | ||
{ | ||
return new | ||
{ | ||
Data, | ||
Message, | ||
Success, | ||
Type | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// 只得到数据 | ||
/// </summary> | ||
/// <returns></returns> | ||
public TData GetData() | ||
{ | ||
return this.Data; | ||
} | ||
|
||
public string ToJson() | ||
{ | ||
return ToObject().ToJson(); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters