using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
using static HH.WCS.Mobox3.DSZSH.Dtos.Response.BaseResponse;
|
using static HH.WCS.Mobox3.DSZSH.Dtos.Response.MoboxResponse;
|
|
namespace HH.WCS.Mobox3.DSZSH.Helpers {
|
public class ResultHelper {
|
public static Result BuildResult(int code, string message, bool pringLog = true) {
|
if (pringLog) {
|
LogHelper.Info(message);
|
}
|
return new Result { Code = code, Message = message };
|
}
|
|
/// <summary>
|
/// 构建 <see cref="SimpleResult"/> 返回值,选择打印日志信息(默认打印)
|
/// </summary>
|
/// <param name="code"></param>
|
/// <param name="message"></param>
|
/// <param name="pringLog"></param>
|
/// <returns></returns>
|
public static SimpleResult BuildSimpleResult(int code, string message, bool pringLog = true) {
|
if (pringLog) {
|
LogHelper.Info(message);
|
}
|
return new SimpleResult { Code = code, Message = message };
|
}
|
|
/// <summary>
|
/// 构建 <see cref="SimpleResult"/> 异常返回值,选择打印异常日志信息(默认打印)
|
/// </summary>
|
/// <param name="ex"></param>
|
/// <param name="exCode"></param>
|
/// <param name="pringLog"></param>
|
/// <returns></returns>
|
public static SimpleResult BuildSimpleEx(Exception ex, int exCode = 1, bool pringLog = true) {
|
if (pringLog) {
|
LogHelper.InfoEx(ex);
|
}
|
return new SimpleResult { Code = exCode, Message = ex.Message };
|
}
|
}
|
}
|