/// <summary> /// 获取错误的返回 /// </summary> protected JsonResult ErrorJsonResult(ErrCodeEnum code, string title = null, Exception ex = null) { if (!string.IsNullOrEmpty(title) || ex != null) { LogHelper.ErrorAsync(title, code.ToDescription(), ex); } return(new JsonResult(new ResponseContext <object>(false, code, null))); }
/// <summary> /// 获取错误的返回 /// </summary> protected JsonResult ErrorJsonResult(ErrCodeEnum code, RequestHead head = null, string title = null, Exception ex = null) { if (!string.IsNullOrEmpty(title) || ex != null) { log.ErrorAsync(title, ex, head); } return(new JsonResult(new ResponseContext <object>(code, null))); }
public Response(ErrCodeEnum err, string msg = null) { ResultCode = err; ResultMessage = err.ToDescription(); if (!msg.IsNullOrEmpty()) { ResultMessage = msg; } }
/// <summary> /// 获取错误的返回 /// </summary> protected JsonResult ErrorJsonResult(ErrCodeEnum code) { var errResponse = new ResponseContext <object>(null) { Head = new ResponseHead(-1, code, code.ToDescription()) }; return(new JsonResult(errResponse)); }
public ResponseContext(ErrCodeEnum codeEnum, T data, string msg = null) { ResultCode = codeEnum; ResultMessage = codeEnum.ToDescription(); Data = data; if (!msg.IsNullOrEmpty()) { ResultMessage = msg; } }
public ResponseContext(bool success, ErrCodeEnum err, T data, string msg = null) { Success = success; Code = err; ResultMessage = err.ToDescription(); Content = data; if (!msg.IsNullOrEmpty()) { ResultMessage = msg; } }
/// <summary> /// 写入服务接口调用日志到数据库,用作接口性能检测 /// </summary> protected void WriteServiceLog(string module, string method, RequestHead reqHead, ErrCodeEnum code, string msg, object request, object response) { if (reqHead == null || request == null) { return; } LogHelper.WriteServiceLog(new ServiceLogEntity() { Module = module, Method = method, Request = request.SerializeToString(), Response = response.SerializeToString(), UId = reqHead.UId, Code = (int)code, Msg = msg, Platform = reqHead.Platform.ToString(), TransactionId = reqHead.TransactionId, CreateTime = DateTime.Now }); }
public ResponseContext(ErrCodeEnum codeEnum) { ResultCode = codeEnum; ResultMessage = codeEnum.ToDescription(); Data = default; }
public ResponseHead(int ret, ErrCodeEnum code, string msg) { Ret = ret; Code = code; Msg = msg; }