忽略dll文件git
This commit is contained in:
@@ -1,111 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Hncore.Infrastructure.OpenApi
|
||||
{
|
||||
public class OpenApiResult<T> where T : class, new()
|
||||
{
|
||||
[JsonProperty("code")] public OpenApiReturnCode Code { get; private set; }
|
||||
|
||||
[JsonProperty("message")] public string Message { get; private set; } = "";
|
||||
|
||||
[JsonProperty("timestamp")] public long Timestamp { get; set; }
|
||||
|
||||
[JsonProperty("sign")] public string Sign { get; set; }
|
||||
|
||||
[JsonProperty("data")] public T Data { get; set; } = new T();
|
||||
|
||||
private static readonly Dictionary<Enum, string> Dic;
|
||||
|
||||
static OpenApiResult()
|
||||
{
|
||||
Dic = ObjectExtension.ToDescriptionDictionary<OpenApiReturnCode>();
|
||||
}
|
||||
|
||||
|
||||
public OpenApiResult(OpenApiReturnCode code = OpenApiReturnCode.Success, string message = "")
|
||||
{
|
||||
Code = code;
|
||||
|
||||
if (string.IsNullOrEmpty(message) && Dic.ContainsKey(Code))
|
||||
{
|
||||
Message = Dic[Code];
|
||||
}
|
||||
else
|
||||
{
|
||||
Message = message;
|
||||
}
|
||||
|
||||
this.Timestamp = DateTimeHelper.ToUnixTimestamp(DateTime.Now);
|
||||
}
|
||||
|
||||
public void CreateSign(string key)
|
||||
{
|
||||
this.Sign = OpenApiSignUtil.CreateSign(this.Timestamp, key);
|
||||
}
|
||||
|
||||
public OpenApiResult<T> CreateSign(HttpContext httpContext)
|
||||
{
|
||||
var key = httpContext.Items["OpenApiAppKey"].ToString();
|
||||
|
||||
this.Sign = OpenApiSignUtil.CreateSign(this.Timestamp, key);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public class OpenApiResult : OpenApiResult<object>
|
||||
{
|
||||
public OpenApiResult(OpenApiReturnCode code = OpenApiReturnCode.Success, string message = "") : base(code,
|
||||
message)
|
||||
{
|
||||
}
|
||||
|
||||
public new OpenApiResult CreateSign(HttpContext httpContext)
|
||||
{
|
||||
var key = httpContext.Items["OpenApiAppKey"].ToString();
|
||||
|
||||
this.Sign = OpenApiSignUtil.CreateSign(this.Timestamp, key);
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public enum OpenApiReturnCode
|
||||
{
|
||||
/// <summary>
|
||||
/// 成功
|
||||
/// </summary>
|
||||
[Description("成功")] Success = 10000,
|
||||
|
||||
/// <summary>
|
||||
/// 验签失败
|
||||
/// </summary>
|
||||
[Description("未授权")] Unauthorized = 40001,
|
||||
|
||||
/// <summary>
|
||||
/// 验签失败
|
||||
/// </summary>
|
||||
[Description("验签失败")] SignError = 40002,
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳过期
|
||||
/// </summary>
|
||||
[Description("时间戳过期")] TimeStampExpired = 40003,
|
||||
|
||||
/// <summary>
|
||||
/// 内部错误
|
||||
/// </summary>
|
||||
[Description("内部错误")] InternalError = 50000,
|
||||
|
||||
/// <summary>
|
||||
/// 处理失败
|
||||
/// </summary>
|
||||
[Description("处理失败")] Error = 500001
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user