完善通用接口输入参数

This commit is contained in:
2023-11-21 00:19:45 +08:00
parent 079eec500b
commit 70de358f97
17 changed files with 375 additions and 226 deletions

View File

@@ -27,11 +27,10 @@ namespace Tnb.Vengine.AppService;
[Authorize]
//[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)]
[Route("api/[area]/[controller]/[action]")]
public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput, TGetListOutput, TCreateInput, TUpdateInput> : BaseAppService
public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TQueryOutput, TCreateInput, TUpdateInput> : BaseAppService
where TEntity : Entity
where TGetInput : VmGetInput
where TQueryInput : VmQueryInput
where TGetListInput : VmGetListInput
where TCreateInput : VmEditInput
where TUpdateInput : VmEditInput
{
@@ -93,10 +92,10 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGet
public virtual async Task<TGetOutput> GetAsync([FromQuery] TGetInput input)
{
var vm = await GetVmodelAsync();
TQueryInput arg = input.Adapt<TQueryInput>();
arg.AddQueryParaIf(!string.IsNullOrEmpty(input.id), vm.GetPrimary().code, input.id!);
if (!string.IsNullOrEmpty(input.id)) input.q.Add(vm.GetPrimary().code, input.id);
input.LoadFromHttpContext(App.HttpContext);
var data = (await ListAsync(arg)).items.FirstOrDefault();
var data = (await ListAsync(input.Adapt<TQueryInput>())).items.FirstOrDefault();
return data == null ? default! : data.Adapt<TGetOutput>();
}
@@ -104,20 +103,21 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGet
/// 获取多条 数据列表
/// </summary>
[HttpGet]
public virtual async Task<PagedOutput<TGetListOutput>> GetListAsync([FromQuery] TGetListInput input)
public virtual async Task<PagedOutput<TQueryOutput>> GetListAsync([FromQuery] TQueryInput input)
{
return await ListAsync(input.Adapt<TQueryInput>());
input.LoadFromHttpContext(App.HttpContext);
return await ListAsync(input);
}
/// <summary>
/// 获取多条 数据列表
/// </summary>
[HttpPost]
public virtual async Task<PagedOutput<TGetListOutput>> ListAsync([FromBody] TQueryInput input)
public virtual async Task<PagedOutput<TQueryOutput>> ListAsync([FromBody] TQueryInput input)
{
var vm = await GetVmodelAsync();
var ls = await _dataAccess.QueryDataAsync(vm, input);
return ls.ToPagedOutput<TGetListOutput>();
return ls.ToPagedOutput<TQueryOutput>();
}
/// <summary>
@@ -155,22 +155,31 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGet
}
#region
public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput, TGetListOutput> :
VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput, TGetListOutput, VmEditInput, VmEditInput>
public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TQueryOutput, TCreateInput> :
VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TQueryOutput, TCreateInput, VmEditInput>
where TEntity : Entity
where TGetInput : VmGetInput
where TQueryInput : VmQueryInput
where TCreateInput : VmEditInput
{
public VengineAppService(IDataAccess da) : base(da)
{
}
}
public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TQueryOutput> :
VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TQueryOutput, VmEditInput, VmEditInput>
where TEntity : Entity
where TGetInput : VmGetInput
where TGetListInput : VmGetListInput
where TQueryInput : VmQueryInput
{
public VengineAppService(IDataAccess da) : base(da)
{
}
}
public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput> :
VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput, dynamic, VmEditInput, VmEditInput>
public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput> :
VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, dynamic, VmEditInput, VmEditInput>
where TEntity : Entity
where TGetInput : VmGetInput
where TGetListInput : VmGetListInput
where TQueryInput : VmQueryInput
{
public VengineAppService(IDataAccess da) : base(da)
@@ -178,7 +187,7 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGet
}
}
public class VengineAppService<TEntity, TGetInput, TGetOutput> :
VengineAppService<TEntity, TGetInput, TGetOutput, VmQueryInput, VmGetListInput, dynamic, VmEditInput, VmEditInput>
VengineAppService<TEntity, TGetInput, TGetOutput, VmQueryInput, dynamic, VmEditInput, VmEditInput>
where TEntity : Entity
where TGetInput : VmGetInput
{
@@ -186,8 +195,18 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput> :
{
}
}
public class VengineAppService<TEntity, TGetInput> :
VengineAppService<TEntity, TGetInput, dynamic, VmQueryInput, dynamic, VmEditInput, VmEditInput>
where TEntity : Entity
where TGetInput : VmGetInput
{
public VengineAppService(IDataAccess da) : base(da)
{
}
}
public class VengineAppService<TEntity> :
VengineAppService<TEntity, VmGetInput, dynamic, VmQueryInput, VmGetListInput, dynamic, VmEditInput, VmEditInput>
VengineAppService<TEntity, VmGetInput, dynamic, VmQueryInput, dynamic, VmEditInput, VmEditInput>
where TEntity : Entity
{
public VengineAppService(IDataAccess da) : base(da)