2025-05-22 13:06:49 +08:00
|
|
|
|
using WcsMain.ApiServe.Controllers.Dto;
|
|
|
|
|
|
using WcsMain.Enum.ApiServer;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WcsMain.ApiServe.Factory;
|
|
|
|
|
|
|
|
|
|
|
|
public static class WcsApiResponseFactory
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表示一个操作成功的响应
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static WcsApiResponse Success(string msg = "操作成功")
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.success,
|
|
|
|
|
|
Msg = msg
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T> Success<T>(T? data = default, string msg = "操作成功") where T : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.success,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T1, T2> Success<T1, T2>(T1? tag = default, T2? data = default, string msg = "操作成功") where T1 : new() where T2 : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.success,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
Tag = tag,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表示一个操作失败的响应
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static WcsApiResponse Fail(string msg = "操作失败")
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.fail,
|
|
|
|
|
|
Msg = msg
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T> Fail<T>(T? data = default, string msg = "操作失败") where T : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.fail,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T1, T2> Fail<T1, T2>(T1? tag = default, T2? data = default, string msg = "操作失败") where T1 : new() where T2 : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.success,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
Tag = tag,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表示一个请求参数错误的响应
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static WcsApiResponse RequestErr(string msg = "请求参数错误")
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.requestDataErr,
|
|
|
|
|
|
Msg = msg
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T> RequestErr<T>(T? data = default, string msg = "请求参数错误") where T : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.requestDataErr,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T1, T2> RequestErr<T1, T2>(T1? tag = default, T2? data = default, string msg = "请求参数错误") where T1 : new() where T2 : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.success,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
Tag = tag,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表示一个数据重复的响应
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static WcsApiResponse DataRepetition(string msg = "数据重复")
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.dataRepetition,
|
|
|
|
|
|
Msg = msg
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T> DataRepetition<T>(T? data = default, string msg = "数据重复") where T : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.dataRepetition,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T1, T2> DataRepetition<T1, T2>(T1? tag = default, T2? data = default, string msg = "数据重复") where T1 : new() where T2 : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.success,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
Tag = tag,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表示一个服务器异常的响应
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static WcsApiResponse ServiceErr(string msg = "服务器异常")
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.serviceErr,
|
|
|
|
|
|
Msg = msg
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T> ServiceErr<T>(T? data = default, string msg = "服务器异常") where T : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.serviceErr,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T1, T2> ServiceErr<T1, T2>(T1? tag = default, T2? data = default, string msg = "服务器异常") where T1 : new() where T2 : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.success,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
Tag = tag,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 表示一个数据库异常的响应
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="msg"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static WcsApiResponse DataBaseErr(string msg = "后台数据库异常,请重试")
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.dataBaseErr,
|
|
|
|
|
|
Msg = msg
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T> DataBaseErr<T>(T? data = default, string msg = "后台数据库异常,请重试") where T : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.dataBaseErr,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
public static WcsApiResponse<T1, T2> DataBaseErr<T1, T2>(T1? tag = default, T2? data = default, string msg = "后台数据库异常,请重试") where T1 : new() where T2 : class
|
|
|
|
|
|
=> new()
|
|
|
|
|
|
{
|
|
|
|
|
|
Code = (int)ApiResponseCodeEnum.success,
|
|
|
|
|
|
Msg = msg,
|
|
|
|
|
|
Tag = tag,
|
|
|
|
|
|
ReturnData = data
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2024-05-14 16:30:56 +08:00
|
|
|
|
}
|