取字典的值的时候进行判断
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
682e40febd
commit
5e8b5eed9f
|
@ -35,14 +35,22 @@ namespace IRaCIS.Core.Application.Filter
|
||||||
{
|
{
|
||||||
var error = context.Exception as BusinessValidationFailedException;
|
var error = context.Exception as BusinessValidationFailedException;
|
||||||
|
|
||||||
context.Result = new JsonResult(ResponseOutput.NotOk(context.Exception.Message,"", error!.Code,localizedInfo: $"[{error!.LocalizedKey}]:{StaticData.Log_Locoalize_Dic[error!.LocalizedKey]}"));
|
var info = string.Empty;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(error!.LocalizedKey) && StaticData.Log_Locoalize_Dic.ContainsKey(error!.LocalizedKey))
|
||||||
|
{
|
||||||
|
info = $"[{error!.LocalizedKey}]:{StaticData.Log_Locoalize_Dic[error!.LocalizedKey]}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
context.Result = new JsonResult(ResponseOutput.NotOk(context.Exception.Message, "", error!.Code, localizedInfo: info));
|
||||||
|
|
||||||
//warning 级别记录
|
//warning 级别记录
|
||||||
//_logger.LogWarning($"[{error!.LocalizedKey}]:{StaticData.Log_Locoalize_Dic[error!.LocalizedKey]}");
|
//_logger.LogWarning($"[{error!.LocalizedKey}]:{StaticData.Log_Locoalize_Dic[error!.LocalizedKey]}");
|
||||||
}
|
}
|
||||||
else if(context.Exception.GetType() == typeof(QueryBusinessObjectNotExistException))
|
else if (context.Exception.GetType() == typeof(QueryBusinessObjectNotExistException))
|
||||||
{
|
{
|
||||||
context.Result = new JsonResult(ResponseOutput.NotOk( context.Exception.Message, ApiResponseCodeEnum.DataNotExist));
|
context.Result = new JsonResult(ResponseOutput.NotOk(context.Exception.Message, ApiResponseCodeEnum.DataNotExist));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infrastructure.Extention
|
namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
{
|
{
|
||||||
|
@ -112,7 +113,16 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
public static IResponseOutput<string> NotOk(LocalizedString msg, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed)
|
public static IResponseOutput<string> NotOk(LocalizedString msg, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed)
|
||||||
{
|
{
|
||||||
|
|
||||||
return new ResponseOutput<string>().NotOk(msg, code: code, localizedInfo: $"[{msg.Name}]:{StaticData.Log_Locoalize_Dic[msg.Name]}" );
|
var key = msg.Name;
|
||||||
|
|
||||||
|
var info = string.Empty;
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(key) && StaticData.Log_Locoalize_Dic.ContainsKey(key))
|
||||||
|
{
|
||||||
|
info = $"[{key}]:{StaticData.Log_Locoalize_Dic[key]}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseOutput<string>().NotOk(msg, code: code, localizedInfo: info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IResponseOutput<string> DBNotExistIfNUll(object businessObject)
|
public static IResponseOutput<string> DBNotExistIfNUll(object businessObject)
|
||||||
|
|
Loading…
Reference in New Issue