完善模型通用接口的无限层级一对一和单层级一对多

This commit is contained in:
2023-11-15 13:43:24 +08:00
parent d800987307
commit 9c03ef2bcc
145 changed files with 758 additions and 10219 deletions

View File

@@ -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);
VmListInput arg = input.Adapt<VmListInput>();
VmQueryInput arg = input.Adapt<VmQueryInput>();
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);
VmListInput arg = input.Adapt<VmListInput>();
VmQueryInput arg = input.Adapt<VmQueryInput>();
if (!string.IsNullOrEmpty(input.q))
{
arg.q = input.q.ToObject<DObject>();
@@ -73,7 +73,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
/// 获取多条 数据列表
/// </summary>
[HttpPost("api/[area]/[controller]/{vmid}/list")]
public async Task<VmPagedOutput> ListAsync(string vmid, [FromBody] VmListInput input)
public async Task<VmPagedOutput> ListAsync(string vmid, [FromBody] VmQueryInput input)
{
var vm = await _dataAccess.GetVmodelAsync(vmid, true);
var ls = await _dataAccess.QueryDataAsync(vm, input);
@@ -119,7 +119,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
private async Task<Vmodel> GetVmodelAsync(string areaCode, string vmCode)
{
var vm = await _dataAccess.GetVmodelAsync(areaCode, vmCode, true);
var vm = await _dataAccess.GetVmodelAsync(areaCode, vmCode, false);
return vm;
}
@@ -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);
VmListInput arg = input.Adapt<VmListInput>();
VmQueryInput arg = input.Adapt<VmQueryInput>();
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);
VmListInput arg = input.Adapt<VmListInput>();
VmQueryInput arg = input.Adapt<VmQueryInput>();
if (!string.IsNullOrEmpty(input.q))
{
arg.q = input.q.ToObject<DObject>();
@@ -160,7 +160,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
/// 获取多条 数据列表
/// </summary>
[HttpPost("api/{areaCode}/{vmCode}/list")]
public async Task<VmPagedOutput> ListAsync(string areaCode, string vmCode, [FromBody] VmListInput input)
public async Task<VmPagedOutput> ListAsync(string areaCode, string vmCode, [FromBody] VmQueryInput input)
{
var vm = await GetVmodelAsync(areaCode, vmCode);
var ls = await _dataAccess.QueryDataAsync(vm, input);

View File

@@ -34,7 +34,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
_db = _dataAccess.GetSqlSugar();
}
protected async Task<Vmodel> GetVmodelAsync()
protected virtual async Task<Vmodel> GetVmodelAsync()
{
var tp = typeof(TEntity);
string? area = null, code = null;
@@ -53,7 +53,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
{
code = tp.Name.ToKebab();
}
var vm = await _dataAccess.GetVmodelAsync(area, code, true);
var vm = await _dataAccess.GetVmodelAsync(area, code, false);
return vm;
}
@@ -65,7 +65,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
public virtual async Task<dynamic> GetAsync([FromQuery] VmGetInput input)
{
var vm = await GetVmodelAsync();
VmListInput arg = input.Adapt<VmListInput>();
VmQueryInput arg = input.Adapt<VmQueryInput>();
if (input.id != null)
{
if (arg.q == null) arg.q = new DObject();
@@ -90,7 +90,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
/// 获取多条 数据列表
/// </summary>
[HttpPost]
public virtual async Task<VmPagedOutput> ListAsync([FromBody] VmListInput input)
public virtual async Task<VmPagedOutput> ListAsync([FromBody] VmQueryInput input)
{
var vm = await GetVmodelAsync();
var ls = await _dataAccess.QueryDataAsync(vm, input);

View File

@@ -9,6 +9,7 @@ using JNPF.ViewEngine;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using Tnb.Core;
using Tnb.Vengine.DataAccess;
using Tnb.Vengine.Domain;
@@ -65,12 +66,12 @@ public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
RefAsync<int> total = 0;
var data = await q.OrderBy(input.sort).ToPageListAsync((input.pnum - 1) * input.psize, input.psize, total);
ret.total = total;
ret.items = data.ConvertAll<dynamic>(a => a);
ret.items = data.Adapt<List<DObject>>();
return ret;
}
[NonAction]
public override Task<VmPagedOutput> ListAsync(VmListInput input)
public override Task<VmPagedOutput> ListAsync(VmQueryInput input)
{
return base.ListAsync(input);
}
@@ -127,12 +128,17 @@ public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
foreach (var tb in lsTable)
{
if (!string.IsNullOrEmpty(input.removePrefix) && !tb.Name.StartsWith(input.removePrefix)) continue;
var n = tb.Name.IndexOf('_');
if (string.IsNullOrEmpty(input.removePrefix) && n > 0 && n < 5)
{
input.removePrefix = tb.Name.Substring(0, n);
}
var colInfo = sugar.DbMaintenance.GetColumnInfosByTableName(tb.Name);
Vmodel model = new() { dbCode = input.dbCode, vmName = tb.Description, tableName = tb.Name };
model.areaCode = input.areaCode.ToKebab();
model.vmCode = (string.IsNullOrEmpty(input.removePrefix) ? tb.Name.ToKebab() : tb.Name.RemovePreFix(input.removePrefix)).ToKebab();
//model.createId = CurrentUser.Id;
int n = 1;
n = 1;
foreach (var p in colInfo)
{
var prop = p.Adapt<VmDbProp>();

View File

@@ -9,6 +9,7 @@ using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.Core;
using Tnb.Vengine.DataAccess;
using Tnb.Vengine.Domain;
@@ -48,7 +49,7 @@ public class VmodelPageAppService : VengineAppService<VmodelPage>, IVmodelPageAp
RefAsync<int> total = 0;
var data = await q.OrderBy(input.sort).ToPageListAsync((input.pnum - 1) * input.psize, input.psize, total);
ret.total = total;
ret.items = data.ConvertAll<dynamic>(a => a);
ret.items = data.Adapt<List<DObject>>();
return ret;
}