Compare commits
No commits in common. "8ba22a343a7bbc6247a7bf0cf0440e23fe2ad4e0" and "062387e6a8a9789d85b1b0be95a71da047dbca6e" have entirely different histories.
8ba22a343a
...
062387e6a8
|
|
@ -8,7 +8,6 @@ using Panda.DynamicWebApi;
|
||||||
using Panda.DynamicWebApi.Attributes;
|
using Panda.DynamicWebApi.Attributes;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application
|
namespace IRaCIS.Core.Application
|
||||||
{
|
{
|
||||||
|
|
@ -18,8 +17,7 @@ namespace IRaCIS.Core.Application
|
||||||
|
|
||||||
#region 非泛型版本
|
#region 非泛型版本
|
||||||
|
|
||||||
[TypeFilter(typeof(UnifiedApiResultFilter))]
|
[Authorize, DynamicWebApi, UnifiedApiResultFilter]
|
||||||
[Authorize, DynamicWebApi]
|
|
||||||
public class BaseService : IBaseService, IDynamicWebApi
|
public class BaseService : IBaseService, IDynamicWebApi
|
||||||
{
|
{
|
||||||
public IMapper _mapper { get; set; }
|
public IMapper _mapper { get; set; }
|
||||||
|
|
@ -85,8 +83,8 @@ namespace IRaCIS.Core.Application
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TypeFilter(typeof(UnifiedApiResultFilter))]
|
|
||||||
[Authorize, DynamicWebApi]
|
[Authorize, DynamicWebApi, UnifiedApiResultFilter]
|
||||||
public class BaseServiceTest<T> : IBaseServiceTest<T>, IDynamicWebApi where T : Entity
|
public class BaseServiceTest<T> : IBaseServiceTest<T>, IDynamicWebApi where T : Entity
|
||||||
{
|
{
|
||||||
public IMapper _mapper { get; set; }
|
public IMapper _mapper { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Infrastructure;
|
||||||
using IRaCIS.Core.Infrastructure;
|
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
using IRaCIS.Core.Infrastructure.Extention;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
|
@ -35,10 +34,7 @@ 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]}"));
|
context.Result = new JsonResult(ResponseOutput.NotOk(context.Exception.Message, error!.Code));
|
||||||
|
|
||||||
//warning 级别记录
|
|
||||||
//_logger.LogWarning($"[{error!.LocalizedKey}]:{StaticData.Log_Locoalize_Dic[error!.LocalizedKey]}");
|
|
||||||
}
|
}
|
||||||
else if(context.Exception.GetType() == typeof(QueryBusinessObjectNotExistException))
|
else if(context.Exception.GetType() == typeof(QueryBusinessObjectNotExistException))
|
||||||
{
|
{
|
||||||
|
|
@ -48,10 +44,12 @@ namespace IRaCIS.Core.Application.Filter
|
||||||
{
|
{
|
||||||
context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["Project_ExceptionContactDeveloper"] + (context.Exception.InnerException is null ? (context.Exception.Message /*+ context.Exception.StackTrace*/)
|
context.Result = new JsonResult(ResponseOutput.NotOk(_localizer["Project_ExceptionContactDeveloper"] + (context.Exception.InnerException is null ? (context.Exception.Message /*+ context.Exception.StackTrace*/)
|
||||||
: (context.Exception.InnerException?.Message /*+ context.Exception.InnerException?.StackTrace*/)), ApiResponseCodeEnum.ProgramException));
|
: (context.Exception.InnerException?.Message /*+ context.Exception.InnerException?.StackTrace*/)), ApiResponseCodeEnum.ProgramException));
|
||||||
|
|
||||||
_logger.LogError(context.Exception.InnerException is null ? (context.Exception.Message + context.Exception.StackTrace) : (context.Exception.InnerException?.Message + context.Exception.InnerException?.StackTrace));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_logger.LogError(context.Exception.InnerException is null ? (context.Exception.Message + context.Exception.StackTrace) : (context.Exception.InnerException?.Message + context.Exception.InnerException?.StackTrace));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
using Microsoft.AspNetCore.Mvc.Filters;
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace IRaCIS.Application.Services.BusinessFilter
|
namespace IRaCIS.Application.Services.BusinessFilter
|
||||||
{
|
{
|
||||||
|
|
@ -11,12 +10,6 @@ namespace IRaCIS.Application.Services.BusinessFilter
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UnifiedApiResultFilter : Attribute, IAsyncResultFilter
|
public class UnifiedApiResultFilter : Attribute, IAsyncResultFilter
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
|
||||||
|
|
||||||
public UnifiedApiResultFilter(ILogger<UnifiedApiResultFilter> logger)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步版本
|
/// 异步版本
|
||||||
|
|
@ -38,11 +31,12 @@ namespace IRaCIS.Application.Services.BusinessFilter
|
||||||
var type = objectResult.Value?.GetType();
|
var type = objectResult.Value?.GetType();
|
||||||
|
|
||||||
|
|
||||||
if (type != null && type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(ValueTuple<,>) || type.GetGenericTypeDefinition() == typeof(Tuple<,>)))
|
if ( type!=null&& type.IsGenericType&&(type.GetGenericTypeDefinition()==typeof(ValueTuple<,>)|| type.GetGenericTypeDefinition()==typeof(Tuple<,>)))
|
||||||
{
|
{
|
||||||
|
|
||||||
//报错
|
//报错
|
||||||
//var tuple = (object, object))objectResult.Value;
|
//var tuple = (object, object))objectResult.Value;
|
||||||
|
|
||||||
//var (val1, val2) = ((dynamic, dynamic))objectResult.Value;
|
//var (val1, val2) = ((dynamic, dynamic))objectResult.Value;
|
||||||
//var apiResponse = ResponseOutput.Ok(val1, val2);
|
//var apiResponse = ResponseOutput.Ok(val1, val2);
|
||||||
|
|
||||||
|
|
@ -62,19 +56,16 @@ namespace IRaCIS.Application.Services.BusinessFilter
|
||||||
objectResult.DeclaredType = apiResponse.GetType();
|
objectResult.DeclaredType = apiResponse.GetType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//如果是200 是IResponseOutput 记录下日志
|
//如果不是200 是IResponseOutput 不处理
|
||||||
else if (statusCode == 200 && (objectResult.Value is IResponseOutput))
|
else if (statusCode != 200 && (objectResult.Value is IResponseOutput))
|
||||||
{
|
{
|
||||||
var result = objectResult.Value as IResponseOutput;
|
|
||||||
|
|
||||||
_logger.LogWarning($"{result.LocalizedInfo}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (statusCode != 200 && !(objectResult.Value is IResponseOutput))
|
else if(statusCode != 200&&!(objectResult.Value is IResponseOutput))
|
||||||
{
|
{
|
||||||
//---程序错误,请联系开发人员。
|
//---程序错误,请联系开发人员。
|
||||||
var apiResponse = ResponseOutput.NotOk(StaticData.International("UnifiedAPI_ProgramError"));
|
var apiResponse = ResponseOutput.NotOk(StaticData.International("UnifiedAPI_ProgramError"));
|
||||||
|
|
||||||
objectResult.Value = apiResponse;
|
objectResult.Value = apiResponse;
|
||||||
|
|
|
||||||
|
|
@ -53,9 +53,6 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
jsonObject[item.Code] = item.Value;
|
jsonObject[item.Code] = item.Value;
|
||||||
|
|
||||||
StaticData.En_US_Dic[item.Code] = item.Value;
|
StaticData.En_US_Dic[item.Code] = item.Value;
|
||||||
|
|
||||||
//日志记录该信息方便自己人看, 返回给客户的是配置的
|
|
||||||
StaticData.Log_Locoalize_Dic[item.Code] = item.Description;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -74,7 +71,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task AddOrUpdateJsonKeyValueAsync(string key, string value, string valueCN,string description)
|
public static async Task AddOrUpdateJsonKeyValueAsync(string key, string value, string valueCN)
|
||||||
{
|
{
|
||||||
|
|
||||||
VerifyFolder();
|
VerifyFolder();
|
||||||
|
|
@ -97,9 +94,6 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
jsonObject[key] = value;
|
jsonObject[key] = value;
|
||||||
|
|
||||||
StaticData.En_US_Dic[key] = value;
|
StaticData.En_US_Dic[key] = value;
|
||||||
|
|
||||||
//日志记录该信息方便自己人看, 返回给客户的是配置的
|
|
||||||
StaticData.Log_Locoalize_Dic[key] = description;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -123,8 +117,7 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
{
|
{
|
||||||
t.Code,
|
t.Code,
|
||||||
t.Value,
|
t.Value,
|
||||||
t.ValueCN,
|
t.ValueCN
|
||||||
t.Description
|
|
||||||
}).ToListAsync();
|
}).ToListAsync();
|
||||||
|
|
||||||
//组织成json 文件
|
//组织成json 文件
|
||||||
|
|
@ -138,9 +131,6 @@ namespace IRaCIS.Core.Application.Helper
|
||||||
{
|
{
|
||||||
StaticData.En_US_Dic[tojsonItem.Code] = tojsonItem.Value;
|
StaticData.En_US_Dic[tojsonItem.Code] = tojsonItem.Value;
|
||||||
StaticData.Zh_CN_Dic[tojsonItem.Code] = tojsonItem.ValueCN;
|
StaticData.Zh_CN_Dic[tojsonItem.Code] = tojsonItem.ValueCN;
|
||||||
|
|
||||||
//日志记录该信息方便自己人看, 返回给客户的是配置的
|
|
||||||
StaticData.Log_Locoalize_Dic[tojsonItem.Code] = tojsonItem.Description;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllText(usJsonPath, JsonConvert.SerializeObject(StaticData.En_US_Dic));
|
File.WriteAllText(usJsonPath, JsonConvert.SerializeObject(StaticData.En_US_Dic));
|
||||||
|
|
|
||||||
|
|
@ -711,7 +711,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsSelfAnalysis == false && c.TrialReadingCriterionId == trialReadingCriterionId),
|
IsHaveGeneratedTask = t.SubjectVisitTaskList.Any(c => c.IsSelfAnalysis == false && c.TrialReadingCriterionId == trialReadingCriterionId),
|
||||||
|
|
||||||
DoctorUserList = t.SubjectDoctorList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.IsConfirmed && t.ArmEnum <= Arm.DoubleReadingArm2).Select(t => new UserSimpleInfo()
|
DoctorUserList = t.SubjectDoctorList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.IsConfirmed && t.ArmEnum<=Arm.DoubleReadingArm2).Select(t => new UserSimpleInfo()
|
||||||
{
|
{
|
||||||
UserId = t.Id,
|
UserId = t.Id,
|
||||||
FullName = t.DoctorUser.FullName,
|
FullName = t.DoctorUser.FullName,
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ namespace IRaCIS.Core.Application.Service
|
||||||
|
|
||||||
if (addOrEditInternationalization.InternationalizationType == 1)
|
if (addOrEditInternationalization.InternationalizationType == 1)
|
||||||
{
|
{
|
||||||
await InternationalizationHelper.AddOrUpdateJsonKeyValueAsync(entity.Code, addOrEditInternationalization.Value, addOrEditInternationalization.ValueCN,addOrEditInternationalization.Description);
|
await InternationalizationHelper.AddOrUpdateJsonKeyValueAsync(entity.Code, addOrEditInternationalization.Value, addOrEditInternationalization.ValueCN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using IRaCIS.Core.Application.Auth;
|
using IRaCIS.Core.Application.Auth;
|
||||||
using IRaCIS.Core.Domain.Models;
|
using IRaCIS.Core.Domain.Models;
|
||||||
using IRaCIS.Core.Infrastructure;
|
|
||||||
|
|
||||||
namespace IRaCIS.Application.Services
|
namespace IRaCIS.Application.Services
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\IRaCIS.Core.Domain.Share\IRaCIS.Core.Domain.Share.csproj" />
|
<ProjectReference Include="..\IRaCIS.Core.Domain.Share\IRaCIS.Core.Domain.Share.csproj" />
|
||||||
<ProjectReference Include="..\IRaCIS.Core.Infrastructure\IRaCIS.Core.Infrastructure.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,6 @@ public static class StaticData
|
||||||
|
|
||||||
public static Dictionary<string, string> Zh_CN_Dic = new Dictionary<string, string>();
|
public static Dictionary<string, string> Zh_CN_Dic = new Dictionary<string, string>();
|
||||||
|
|
||||||
public static Dictionary<string, string> Log_Locoalize_Dic = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
|
|
||||||
public static readonly string En_US_Json = "en-US.json";
|
public static readonly string En_US_Json = "en-US.json";
|
||||||
public static readonly string Zh_CN_Json = "zh-CN.json";
|
public static readonly string Zh_CN_Json = "zh-CN.json";
|
||||||
|
|
@ -11,8 +11,6 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||||
<PackageReference Include="AutoMapper.Collection.EntityFrameworkCore" Version="10.0.0" />
|
<PackageReference Include="AutoMapper.Collection.EntityFrameworkCore" Version="10.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.37.2" />
|
<PackageReference Include="SharpCompress" Version="0.37.2" />
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using IRaCIS.Core.Infrastructure.Extention;
|
using IRaCIS.Core.Infrastructure.Extention;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infrastructure
|
namespace IRaCIS.Core.Infrastructure
|
||||||
|
|
@ -9,24 +8,15 @@ namespace IRaCIS.Core.Infrastructure
|
||||||
|
|
||||||
public ApiResponseCodeEnum Code { get; set; }
|
public ApiResponseCodeEnum Code { get; set; }
|
||||||
|
|
||||||
public string LocalizedKey { get; set; }=string.Empty;
|
public BusinessValidationFailedException()
|
||||||
|
|
||||||
public BusinessValidationFailedException()
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BusinessValidationFailedException(LocalizedString message, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed) : base(message)
|
|
||||||
{
|
|
||||||
Code = code;
|
|
||||||
LocalizedKey=message.Name;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public BusinessValidationFailedException(string message, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed) : base(message)
|
public BusinessValidationFailedException(string message, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed) : base(message)
|
||||||
{
|
{
|
||||||
Code = code;
|
Code = code;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@
|
||||||
/// 消息
|
/// 消息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
string ErrorMessage { get; }
|
string ErrorMessage { get; }
|
||||||
|
|
||||||
|
|
||||||
public string LocalizedInfo { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -33,4 +30,13 @@
|
||||||
T Data { get; set; }
|
T Data { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public interface IResponseOutput<T,T2> : IResponseOutput
|
||||||
|
//{
|
||||||
|
// /// <summary>
|
||||||
|
// /// 返回数据
|
||||||
|
// /// </summary>
|
||||||
|
// T Data { get; }
|
||||||
|
|
||||||
|
// T2 OtherInfo { get; }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
using IRaCIS.Core.Domain.Share;
|
using Newtonsoft.Json;
|
||||||
using Microsoft.Extensions.Localization;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace IRaCIS.Core.Infrastructure.Extention
|
namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
{
|
{
|
||||||
|
|
@ -10,10 +7,10 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ResponseOutput<T> : IResponseOutput<T>
|
public class ResponseOutput<T> : IResponseOutput<T>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否成功标记
|
/// 是否成功标记
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsSuccess { get; private set; }
|
public bool IsSuccess { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public ApiResponseCodeEnum Code { get; set; } = ApiResponseCodeEnum.OK;
|
public ApiResponseCodeEnum Code { get; set; } = ApiResponseCodeEnum.OK;
|
||||||
|
|
@ -28,20 +25,34 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
/// 数据 兼顾以前 Json序列化的时候返回属性名为“Result”
|
/// 数据 兼顾以前 Json序列化的时候返回属性名为“Result”
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("Result")]
|
[JsonProperty("Result")]
|
||||||
public T Data { get; set; }
|
public T Data { get; set; }
|
||||||
|
|
||||||
|
|
||||||
[JsonProperty("OtherInfo")]
|
[JsonProperty("OtherInfo")]
|
||||||
public object OtherData { get; set; }
|
public object OtherData { get; set; }
|
||||||
|
|
||||||
public string LocalizedInfo { get; set; }
|
|
||||||
|
|
||||||
public ResponseOutput<T> Ok(T data, object otherData, string msg = "", ApiResponseCodeEnum code = ApiResponseCodeEnum.OK)
|
/// <summary>
|
||||||
|
/// 成功
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">数据</param>
|
||||||
|
/// <param name="msg">消息</param>
|
||||||
|
//public ResponseOutput<T> Ok(T data, string msg = "", ApiResponseCodeEnum code = ApiResponseCodeEnum.OK)
|
||||||
|
//{
|
||||||
|
// IsSuccess = true;
|
||||||
|
// Code = code;
|
||||||
|
// Data = data;
|
||||||
|
// ErrorMessage = msg;
|
||||||
|
|
||||||
|
// return this;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public ResponseOutput<T> Ok(T data, object otherData, string msg = "", ApiResponseCodeEnum code = ApiResponseCodeEnum.OK)
|
||||||
{
|
{
|
||||||
IsSuccess = true;
|
IsSuccess = true;
|
||||||
Code = code;
|
Code = code;
|
||||||
Data = data;
|
Data = data;
|
||||||
OtherData = otherData;
|
OtherData=otherData;
|
||||||
ErrorMessage = msg;
|
ErrorMessage = msg;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -53,13 +64,12 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
/// <param name="msg">提示消息</param>
|
/// <param name="msg">提示消息</param>
|
||||||
/// <param name="data">数据</param>
|
/// <param name="data">数据</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ResponseOutput<T> NotOk(string msg = "", T data = default, ApiResponseCodeEnum code = ApiResponseCodeEnum.OK, string localizedInfo = "")
|
public ResponseOutput<T> NotOk(string msg = "", T data = default, ApiResponseCodeEnum code = ApiResponseCodeEnum.OK)
|
||||||
{
|
{
|
||||||
IsSuccess = false;
|
IsSuccess = false;
|
||||||
Code = code;
|
Code = code;
|
||||||
ErrorMessage = msg;
|
ErrorMessage = msg;
|
||||||
Data = data;
|
Data = data;
|
||||||
LocalizedInfo = localizedInfo;
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,6 +77,33 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//public class ResponseOutput<T, T2> : IResponseOutput<T, T2>
|
||||||
|
//{
|
||||||
|
// [JsonProperty("Result")]
|
||||||
|
// public T Data { get; private set; }
|
||||||
|
|
||||||
|
// public T2 OtherInfo { get; private set; }
|
||||||
|
|
||||||
|
// public bool IsSuccess { get; private set; }
|
||||||
|
|
||||||
|
// public ApiResponseCodeEnum Code { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
// public string ErrorMessage { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
// public ResponseOutput<T, T2> Ok(T data, T2 otherInfo, string msg = "")
|
||||||
|
// {
|
||||||
|
// IsSuccess = true;
|
||||||
|
// Data = data;
|
||||||
|
// OtherInfo = otherInfo;
|
||||||
|
// ErrorMessage = msg;
|
||||||
|
|
||||||
|
// return this;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 响应数据静态输出 为了代码简洁 不用每处都New
|
/// 响应数据静态输出 为了代码简洁 不用每处都New
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -74,6 +111,23 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
//public static IResponseOutput<T, T2> Ok<T, T2>(T data, T2 otherInfo, string msg = "")
|
||||||
|
//{
|
||||||
|
// return new ResponseOutput<T, T2>().Ok(data, otherInfo);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 成功 -----适合查询
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">数据</param>
|
||||||
|
/// <param name="msg">消息</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public static IResponseOutput<T> Ok<T>(T data = default, string msg = "")
|
||||||
|
//{
|
||||||
|
// return new ResponseOutput<T>().Ok(data, msg);
|
||||||
|
//}
|
||||||
|
|
||||||
public static IResponseOutput<T> Ok<T>(T data = default, object otherData = default, string msg = "", ApiResponseCodeEnum code = ApiResponseCodeEnum.OK)
|
public static IResponseOutput<T> Ok<T>(T data = default, object otherData = default, string msg = "", ApiResponseCodeEnum code = ApiResponseCodeEnum.OK)
|
||||||
{
|
{
|
||||||
return new ResponseOutput<T>().Ok(data, otherData, msg, code);
|
return new ResponseOutput<T>().Ok(data, otherData, msg, code);
|
||||||
|
|
@ -93,11 +147,15 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
/// <param name="msg">消息</param>
|
/// <param name="msg">消息</param>
|
||||||
/// <param name="data">数据</param>
|
/// <param name="data">数据</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IResponseOutput<T> NotOk<T>(string msg = "", T data = default, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed, string localizedInfo = "")
|
public static IResponseOutput<T> NotOk<T>(string msg = "", T data = default, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed)
|
||||||
{
|
{
|
||||||
return new ResponseOutput<T>().NotOk(msg, data, code, localizedInfo);
|
return new ResponseOutput<T>().NotOk(msg, data, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//public static IResponseOutput<T> NotOk<T>( T data = default, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed)
|
||||||
|
//{
|
||||||
|
// return new ResponseOutput<T>().NotOk("", data, code);
|
||||||
|
//}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 失败
|
/// 失败
|
||||||
|
|
@ -106,13 +164,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IResponseOutput<string> NotOk(string msg = "", ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed)
|
public static IResponseOutput<string> NotOk(string msg = "", ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed)
|
||||||
{
|
{
|
||||||
return new ResponseOutput<string>().NotOk(msg, code: code);
|
return new ResponseOutput<string>().NotOk(msg,code:code);
|
||||||
}
|
|
||||||
|
|
||||||
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]}" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IResponseOutput<string> DBNotExistIfNUll(object businessObject)
|
public static IResponseOutput<string> DBNotExistIfNUll(object businessObject)
|
||||||
|
|
@ -120,7 +172,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
return new ResponseOutput<string>().NotOk($"The business object{businessObject.GetType().Name} does not exist in the database, or was deleted by someone else, or an incorrect parameter query caused");
|
return new ResponseOutput<string>().NotOk($"The business object{businessObject.GetType().Name} does not exist in the database, or was deleted by someone else, or an incorrect parameter query caused");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据布尔值返回结果 --适合删除
|
/// 根据布尔值返回结果 --适合删除
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -138,7 +190,7 @@ namespace IRaCIS.Core.Infrastructure.Extention
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IResponseOutput<T> Result<T>(bool success, T data = default)
|
public static IResponseOutput<T> Result<T>(bool success, T data = default)
|
||||||
{
|
{
|
||||||
return success ? Ok<T>(data) : NotOk<T>("Saved failed", data);
|
return success ? Ok<T>(data) : NotOk<T>("Saved failed",data);
|
||||||
}
|
}
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue