forked from fajiao/OnvifServer-CSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1009 B
41 lines
1009 B
3 years ago
|
using EC.App.Entity;
|
||
|
using Furion.UnifyResult;
|
||
|
using Microsoft.AspNetCore.Mvc;
|
||
|
using System;
|
||
|
|
||
|
namespace EC.App.Factory
|
||
|
{
|
||
|
public static class RespParamFactory
|
||
|
{
|
||
|
public static RespParam<object> New(int code, bool isSuccess = default, object data = default, object errors = default)
|
||
|
{
|
||
|
return new RespParam<object>
|
||
|
{
|
||
|
Code = code,
|
||
|
IsSuccess = isSuccess,
|
||
|
Data = data,
|
||
|
Errors = errors,
|
||
|
Extras = UnifyContext.Take(),
|
||
|
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public static RespParam<object> New(Enum code, bool isSuccess = default, object data = default, object errors = default)
|
||
|
{
|
||
|
return new RespParam<object>
|
||
|
{
|
||
|
Code = code.GetHashCode(),
|
||
|
IsSuccess = isSuccess,
|
||
|
Data = data,
|
||
|
Errors = errors,
|
||
|
Extras = UnifyContext.Take(),
|
||
|
Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
||
|
};
|
||
|
}
|
||
|
|
||
|
public static JsonResult ToJsonResult(this RespParam<object> respParam)
|
||
|
{
|
||
|
return new JsonResult(respParam);
|
||
|
}
|
||
|
}
|
||
|
}
|