using EC.App.Entity; using Furion.UnifyResult; using Microsoft.AspNetCore.Mvc; using System; namespace EC.App.Factory { public static class RespParamFactory { public static RespParam New(int code, bool isSuccess = default, object data = default, object errors = default) { return new RespParam { Code = code, IsSuccess = isSuccess, Data = data, Errors = errors, Extras = UnifyContext.Take(), Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }; } public static RespParam New(Enum code, bool isSuccess = default, object data = default, object errors = default) { return new RespParam { Code = code.GetHashCode(), IsSuccess = isSuccess, Data = data, Errors = errors, Extras = UnifyContext.Take(), Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() }; } public static JsonResult ToJsonResult(this RespParam respParam) { return new JsonResult(respParam); } } }