using System.Text;
namespace WmsMobileServe.Utils.HttpUtils.Entity;
public class ApiResponseInfo
{
///
/// 请求 URL
///
public string? RequestUrl { get; set; }
///
/// 请求字符串
///
public string? RequestMsg { get; set; }
///
/// 响应字符串
///
public string? ResponseMsg { get; set; }
///
/// 请求时间
///
public DateTime? RequestTime { get; set; }
///
/// 响应时间
///
public DateTime? ResponseTime { get; set; }
///
/// 是否发送成功
///
///
/// 注意:这里仅表示服务端有响应
///
public bool IsSend { get; set; }
///
/// 请求方式
///
public string? RequestMethod { get; set; }
///
/// 请求耗时
///
public double UseTime { get; set; }
///
/// 返回的异常,没有异常返回 null
///
public Exception? Exception { get; set; }
///
/// 重写toString
///
///
public override string ToString()
{
StringBuilder builder = new();
builder.AppendLine($"[请求结果] {IsSend}");
builder.AppendLine($"[请求方式] {RequestMethod}");
builder.AppendLine($"[请求地址] {RequestUrl}");
builder.AppendLine($"[请求信息] {RequestMsg}");
builder.AppendLine($"[响应信息] {ResponseMsg}");
builder.AppendLine($"[请求时间] {RequestTime}");
builder.AppendLine($"[响应时间] {RequestTime}");
builder.AppendLine($"[请求耗时] {UseTime} ms");
if (Exception != default)
{
builder.AppendLine($"[异常信息] {Exception.Message}");
}
return builder.ToString();
}
}
public class ApiResponseInfo : ApiResponseInfo where T : class, new()
{
///
/// 响应的实体类
///
public T? ResponseEntity { get; set; }
}