net core WebAPI返回数据封装
{ "code": 200, //状态码 (int) "message": "string", //消息 (string) "data": {} //Action的原始响应内容 }
https://github.com/stratosblue/cuture.aspnetcore.responseautowrapper
待续。。
--返回类
using System.ComponentModel; using System.Runtime.Serialization; using Newtonsoft.Json; namespace JWTWebApi.Response; [Serializable] public class ResponseResult<T> where T : class { [JsonProperty("code")] public ResultStatus Code { get; set; } [JsonProperty("data")] public T? Data { get; set;} [JsonProperty("message")] public String Message { get; set; } = string.Empty; } public enum ResultStatus { [EnumMember(Value ="请求成功")] Success = 1, [EnumMember(Value ="请求失败")] Fail = 0, [EnumMember(Value ="请求异常")] Error = -1 }