修复钻取一对多子表时条件使用了字段的错误
This commit is contained in:
@@ -3,8 +3,13 @@
|
||||
// https://git.tuotong-tech.com/tnb/tnb.server //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using Aspose.Cells.Drawing;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Tnb.Core;
|
||||
using Tnb.Vengine.Domain;
|
||||
|
||||
namespace Tnb.Vengine.AppService;
|
||||
|
||||
@@ -13,4 +18,17 @@ namespace Tnb.Vengine.AppService;
|
||||
/// </summary>
|
||||
public class BaseAppService : IDynamicApiController, ITransient
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
//[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 100)]
|
||||
//public class VTestAppService : BaseAppService
|
||||
//{
|
||||
// /// <summary>
|
||||
// /// 获取多条 数据列表
|
||||
// /// </summary>
|
||||
// public async Task<dynamic> ListAsync(string vmid, [FromQuery] VmGetListInput input)
|
||||
// {
|
||||
// return new List<string>();
|
||||
// }
|
||||
|
||||
//}
|
||||
@@ -43,7 +43,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
public async Task<dynamic?> GetAsync(string vmid, [FromQuery]VmGetInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid, true);
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
VmListInput arg = input.Adapt<VmListInput>();
|
||||
if (input.id != null)
|
||||
{
|
||||
if (arg.q == null) arg.q = new DObject();
|
||||
@@ -60,7 +60,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
public async Task<VmPagedOutput> GetListAsync(string vmid, [FromQuery] VmGetListInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid, true);
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
VmListInput arg = input.Adapt<VmListInput>();
|
||||
if (!string.IsNullOrEmpty(input.q))
|
||||
{
|
||||
arg.q = input.q.ToObject<DObject>();
|
||||
@@ -72,8 +72,8 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// <summary>
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpPost("api/[area]/[controller]/{vmid}/query")]
|
||||
public async Task<VmPagedOutput> QueryAsync(string vmid, [FromBody] VmQueryInput input)
|
||||
[HttpPost("api/[area]/[controller]/{vmid}/list")]
|
||||
public async Task<VmPagedOutput> ListAsync(string vmid, [FromBody] VmListInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid, true);
|
||||
var ls = await _dataAccess.QueryDataAsync(vm, input);
|
||||
@@ -130,7 +130,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
public async Task<dynamic?> GetAsync(string areaCode, string vmCode, [FromQuery] VmGetInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
VmListInput arg = input.Adapt<VmListInput>();
|
||||
if (input.id != null)
|
||||
{
|
||||
if (arg.q == null) arg.q = new DObject();
|
||||
@@ -147,7 +147,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
public async Task<VmPagedOutput> GetListAsync(string areaCode, string vmCode, [FromQuery] VmGetListInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
VmListInput arg = input.Adapt<VmListInput>();
|
||||
if (!string.IsNullOrEmpty(input.q))
|
||||
{
|
||||
arg.q = input.q.ToObject<DObject>();
|
||||
@@ -159,8 +159,8 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// <summary>
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpPost("api/{areaCode}/{vmCode}/query")]
|
||||
public async Task<VmPagedOutput> QueryAsync(string areaCode, string vmCode, [FromBody] VmQueryInput input)
|
||||
[HttpPost("api/{areaCode}/{vmCode}/list")]
|
||||
public async Task<VmPagedOutput> ListAsync(string areaCode, string vmCode, [FromBody] VmListInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
var ls = await _dataAccess.QueryDataAsync(vm, input);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
public virtual async Task<dynamic> GetAsync([FromQuery] VmGetInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
VmListInput arg = input.Adapt<VmListInput>();
|
||||
if (input.id != null)
|
||||
{
|
||||
if (arg.q == null) arg.q = new DObject();
|
||||
@@ -83,12 +83,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
public virtual async Task<VmPagedOutput> GetListAsync([FromQuery] VmGetListInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
if (!string.IsNullOrEmpty(input.q))
|
||||
{
|
||||
arg.q = input.q.ToObject<DObject>();
|
||||
}
|
||||
var ls = await _dataAccess.QueryDataAsync(vm, arg);
|
||||
var ls = await _dataAccess.QueryDataAsync(vm, input.ToListInput());
|
||||
return ls;
|
||||
}
|
||||
|
||||
@@ -96,7 +91,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public virtual async Task<VmPagedOutput> QueryAsync([FromBody] VmQueryInput input)
|
||||
public virtual async Task<VmPagedOutput> ListAsync([FromBody] VmListInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
var ls = await _dataAccess.QueryDataAsync(vm, input);
|
||||
|
||||
@@ -71,9 +71,9 @@ public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
|
||||
}
|
||||
|
||||
[NonAction]
|
||||
public override Task<VmPagedOutput> QueryAsync(VmQueryInput input)
|
||||
public override Task<VmPagedOutput> ListAsync(VmListInput input)
|
||||
{
|
||||
return base.QueryAsync(input);
|
||||
return base.ListAsync(input);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -184,7 +184,7 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
/// <summary>
|
||||
/// 查询数据 默认方法
|
||||
/// </summary>
|
||||
public async Task<VmPagedOutput> QueryDataAsync(Vmodel vm, VmQueryInput input)
|
||||
public async Task<VmPagedOutput> QueryDataAsync(Vmodel vm, VmListInput input)
|
||||
{
|
||||
ISqlSugarClient db = GetSqlSugar(vm.dbCode);
|
||||
var query = db.Queryable<object>().AS(vm.tableName, VmSelectProp.MAIN_ALIES);
|
||||
@@ -259,8 +259,10 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
{
|
||||
if (prop.navType == eNavigateType.OneToOne)
|
||||
{
|
||||
//以 nav_prop的形式返回
|
||||
var key = prop.navCode + "_" + prop.code;
|
||||
ret.Add(key, src[key]);
|
||||
//以 nav.prop的形式返回
|
||||
//if (!ret.ContainsKey(prop.navCode))
|
||||
//{
|
||||
// ret.Add(prop.navCode, new DObject());
|
||||
@@ -280,10 +282,14 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
var navProp = vm.navProps.First(a => a.code == prop.navCode);
|
||||
if (navProp != null && navProp.naviModel != null && src.ContainsKey(navProp.refField))
|
||||
{
|
||||
VmQueryInput input = new VmQueryInput();
|
||||
input.q = new DObject(navProp.refField, src[navProp.refField]);
|
||||
input.o = string.Join(',', selProps.Where(a => a.navCode == prop.navCode).Select(a => a.code));
|
||||
ret[prop.navCode] = (await QueryDataAsync(navProp.naviModel, input)).items;
|
||||
VmListInput input = new VmListInput();
|
||||
var fkProp = navProp.naviModel.FieldCodeToPropCode(navProp.fkField);
|
||||
if (!string.IsNullOrEmpty(fkProp))
|
||||
{
|
||||
input.q = new DObject(fkProp, src[navProp.refField]);
|
||||
input.o = string.Join(',', selProps.Where(a => a.navCode == prop.navCode).Select(a => a.code));
|
||||
ret[prop.navCode] = (await QueryDataAsync(navProp.naviModel, input)).items;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (prop.navType == eNavigateType.ManyToMany)
|
||||
|
||||
@@ -48,7 +48,7 @@ public interface IDataAccess : ITransient
|
||||
/// <summary>
|
||||
/// 查询数据 默认方法
|
||||
/// </summary>
|
||||
Task<VmPagedOutput> QueryDataAsync(Vmodel vm, VmQueryInput input);
|
||||
Task<VmPagedOutput> QueryDataAsync(Vmodel vm, VmListInput input);
|
||||
|
||||
//Task<dynamic> CreateDataAsync(VmCreateInput input);
|
||||
/// <summary>
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
// https://git.tuotong-tech.com/tnb/tnb.server //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using JNPF.Common.Security;
|
||||
using Mapster;
|
||||
using Tnb.Core;
|
||||
|
||||
namespace Tnb.Vengine.Domain;
|
||||
@@ -64,12 +66,24 @@ public class VmGetListInput : VmBaseInput
|
||||
/// 输出字段
|
||||
/// </summary>
|
||||
public string o { get; set; } = "*";
|
||||
|
||||
public VmListInput ToListInput()
|
||||
{
|
||||
VmListInput arg = this.Adapt<VmListInput>();
|
||||
|
||||
if (!string.IsNullOrEmpty(q))
|
||||
{
|
||||
arg.q = q.ToObject<DObject>();
|
||||
}
|
||||
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取多条数据输入参数
|
||||
/// </summary>
|
||||
public class VmQueryInput : VmGetListInput
|
||||
public class VmListInput : VmGetListInput
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询条件
|
||||
|
||||
@@ -15,11 +15,11 @@ public class VmodelMapper : IRegister
|
||||
{
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.ForType<VmGetInput, VmQueryInput>()
|
||||
config.ForType<VmGetInput, VmListInput>()
|
||||
.Map(dest => dest.psize, src => 1)
|
||||
.Map(dest => dest.pnum, src => 0)
|
||||
.Map(dest => dest.q, src => string.IsNullOrEmpty(src.q) ? null : src.q.ToObject<DObject>());
|
||||
config.ForType<VmGetListInput, VmQueryInput>()
|
||||
config.ForType<VmGetListInput, VmListInput>()
|
||||
.Map(dest => dest.q, src => string.IsNullOrEmpty(src.q) ? null : src.q.ToObject<DObject>());
|
||||
config.ForType<DbColumnInfo, VmDbProp>()
|
||||
.Map(dest => dest.code, src => src.DbColumnName.ToCamel())
|
||||
|
||||
Reference in New Issue
Block a user