mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-20 02:29:24 +08:00
转移.net core 3.1,为.NET 5做准备
This commit is contained in:
81
Infrastructure/Utilities/WebResponseContent.cs
Normal file
81
Infrastructure/Utilities/WebResponseContent.cs
Normal file
@@ -0,0 +1,81 @@
|
||||
using Infrastructure.Const;
|
||||
|
||||
namespace Infrastructure.Utilities
|
||||
{
|
||||
public class WebResponseContent : Response
|
||||
{
|
||||
public WebResponseContent()
|
||||
{
|
||||
Code = 200;
|
||||
Message = "操作成功";
|
||||
}
|
||||
public WebResponseContent(bool status)
|
||||
{
|
||||
this.Status = status;
|
||||
}
|
||||
public bool Status { get; set; }
|
||||
public object Result { get; set; }
|
||||
|
||||
public WebResponseContent OK()
|
||||
{
|
||||
this.Status = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static WebResponseContent Instance
|
||||
{
|
||||
get { return new WebResponseContent(); }
|
||||
}
|
||||
public WebResponseContent OK(string message = null,object data=null)
|
||||
{
|
||||
this.Status = true;
|
||||
this.Message = message;
|
||||
this.Result = data;
|
||||
return this;
|
||||
}
|
||||
public WebResponseContent OK(ResponseType responseType)
|
||||
{
|
||||
return Set(responseType, true);
|
||||
}
|
||||
public WebResponseContent Error(string message = null)
|
||||
{
|
||||
this.Status = false;
|
||||
this.Message = message;
|
||||
return this;
|
||||
}
|
||||
public WebResponseContent Error(ResponseType responseType)
|
||||
{
|
||||
return Set(responseType, false);
|
||||
}
|
||||
public WebResponseContent Set(ResponseType responseType)
|
||||
{
|
||||
bool? b = null;
|
||||
return this.Set(responseType, b);
|
||||
}
|
||||
public WebResponseContent Set(ResponseType responseType, bool? status)
|
||||
{
|
||||
return this.Set(responseType, null, status);
|
||||
}
|
||||
public WebResponseContent Set(ResponseType responseType, string msg)
|
||||
{
|
||||
bool? b = null;
|
||||
return this.Set(responseType, msg, b);
|
||||
}
|
||||
public WebResponseContent Set(ResponseType responseType, string msg, bool? status)
|
||||
{
|
||||
if (status != null)
|
||||
{
|
||||
this.Status = (bool)status;
|
||||
}
|
||||
this.Code = (int)responseType;
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
Message = msg;
|
||||
return this;
|
||||
}
|
||||
Message = responseType.GetMsg();
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user