You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
|
|
|
|
|
using Admin.Core.Common;
|
|
|
|
|
|
|
|
|
|
namespace Admin.Core.Model
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ApiResponse
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ApiResponse
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Status
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Status { get; set; } = 200;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Value
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Value { get; set; } = "";
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MessageModel
|
|
|
|
|
/// </summary>
|
|
|
|
|
public MessageModel<string> MessageModel = new MessageModel<string>() { };
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ApiResponse
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="apiCode"></param>
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
public ApiResponse(StatusCode apiCode, string msg = null)
|
|
|
|
|
{
|
|
|
|
|
switch (apiCode)
|
|
|
|
|
{
|
|
|
|
|
case StatusCode.CODE401:
|
|
|
|
|
{
|
|
|
|
|
Status = 401;
|
|
|
|
|
Value = "很抱歉,您无权访问该接口,请确保已经登录!";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case StatusCode.CODE403:
|
|
|
|
|
{
|
|
|
|
|
Status = 403;
|
|
|
|
|
Value = "很抱歉,您的访问权限等级不够,联系管理员!";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case StatusCode.CODE404:
|
|
|
|
|
{
|
|
|
|
|
Status = 404;
|
|
|
|
|
Value = "资源不存在!";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case StatusCode.CODE500:
|
|
|
|
|
{
|
|
|
|
|
Status = 500;
|
|
|
|
|
Value = msg;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageModel = new MessageModel<string>()
|
|
|
|
|
{
|
|
|
|
|
status = Status,
|
|
|
|
|
msg = Value,
|
|
|
|
|
success = apiCode != StatusCode.CODE200
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// StatusCode
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum StatusCode
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CODE200
|
|
|
|
|
/// </summary>
|
|
|
|
|
CODE200,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CODE401
|
|
|
|
|
/// </summary>
|
|
|
|
|
CODE401,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CODE403
|
|
|
|
|
/// </summary>
|
|
|
|
|
CODE403,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CODE404
|
|
|
|
|
/// </summary>
|
|
|
|
|
CODE404,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// CODE500
|
|
|
|
|
/// </summary>
|
|
|
|
|
CODE500
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|