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.

62 lines
1.5 KiB
C#

using System;
using System.Runtime.Serialization;
namespace SlnMesnac.Model.dto
{
/// <summary>
/// 接口返回信息
/// </summary>
[DataContract(Name = "ApiResponse 返回信息")]
public class ApiResponse
{
/// <summary>
/// 状态码,成功-200异常-500
/// </summary>
public int StatusCode { get; set; }
/// <summary>
/// 是否成功
/// </summary>
public bool IsSuccess { get; set; }
/// <summary>
/// 信息
/// </summary>
public string Message { get; set; }
/// <summary>
/// 成功
/// </summary>
/// <param name="message"></param>
public void SetSuccess(string message = "")
{
StatusCode = 200;
IsSuccess = true;
Message = message;
}
/// <summary>
/// 失败
/// </summary>
/// <param name="message"></param>
public void SetFailure(string message = "")
{
StatusCode = 500;
IsSuccess = false;
Message = message;
}
/// <summary>
/// 异常
/// </summary>
/// <param name="ex"></param>
/// <param name="message"></param>
public void SetException(Exception ex, string message = "")
{
StatusCode = 500;
IsSuccess = false;
Message = message + ex.Message;
}
}
}