修复最新简化集合方式的报错

This commit is contained in:
2023-11-16 15:15:00 +08:00
parent dca3712828
commit 9e42729e04
4 changed files with 37 additions and 35 deletions

View File

@@ -169,7 +169,7 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGet
} }
} }
public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput> : public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput> :
VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput, DObject, VmCreateInput, VmUpdateInput> VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGetListInput, dynamic, VmCreateInput, VmUpdateInput>
where TEntity : Entity where TEntity : Entity
where TGetInput : VmGetInput where TGetInput : VmGetInput
where TGetListInput : VmGetListInput where TGetListInput : VmGetListInput
@@ -180,7 +180,7 @@ public class VengineAppService<TEntity, TGetInput, TGetOutput, TQueryInput, TGet
} }
} }
public class VengineAppService<TEntity, TGetInput, TGetOutput> : public class VengineAppService<TEntity, TGetInput, TGetOutput> :
VengineAppService<TEntity, TGetInput, TGetOutput, VmQueryInput, VmGetListInput, DObject, VmCreateInput, VmUpdateInput> VengineAppService<TEntity, TGetInput, TGetOutput, VmQueryInput, VmGetListInput, dynamic, VmCreateInput, VmUpdateInput>
where TEntity : Entity where TEntity : Entity
where TGetInput : VmGetInput where TGetInput : VmGetInput
{ {

View File

@@ -21,7 +21,7 @@ namespace Tnb.Vengine.AppService;
/// </summary> /// </summary>
[ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, KeepVerb = true, Order = 1102)] [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, KeepVerb = true, Order = 1102)]
[Route("api/[area]/[controller]/[action]")] [Route("api/[area]/[controller]/[action]")]
public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService public class VmodelAppService : VengineAppService<Vmodel, VmodelGetInput, Vmodel>, IVmodelAppService
{ {
private readonly IViewEngine _viewEngine; private readonly IViewEngine _viewEngine;
private readonly ICacheManager _cache; private readonly ICacheManager _cache;
@@ -38,34 +38,34 @@ public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
/// <summary> /// <summary>
/// 获取一条 数据信息 /// 获取一条 数据信息
/// </summary> /// </summary>
public override async Task<dynamic> GetAsync(VmGetInput input) public override async Task<Vmodel> GetAsync(VmodelGetInput input)
{ {
VmodelGetInput para = new VmodelGetInput(); //VmodelGetInput para = new VmodelGetInput();
if (!string.IsNullOrEmpty(input.q)) //if (!string.IsNullOrEmpty(input.q))
{ //{
para = input.q.ToObject<VmodelGetInput>(); // para = input.q.ToObject<VmodelGetInput>();
} //}
var query = _db.Queryable<Vmodel>().Where(a => a.deleted == 0); //var query = _db.Queryable<Vmodel>().Where(a => a.deleted == 0);
Vmodel? vm = null; //Vmodel? vm = null;
if (!string.IsNullOrEmpty(input.id)) //if (!string.IsNullOrEmpty(input.id))
{ //{
vm = await _dataAccess.GetVmodelAsync(input.id, para.drill); // vm = await _dataAccess.GetVmodelAsync(input.id, para.drill);
} //}
else if (!string.IsNullOrEmpty(para.areaCode) && !string.IsNullOrEmpty(para.vmCode)) //else if (!string.IsNullOrEmpty(para.areaCode) && !string.IsNullOrEmpty(para.vmCode))
{ //{
vm = await _dataAccess.GetVmodelAsync(para.areaCode, para.vmCode, para.drill); // vm = await _dataAccess.GetVmodelAsync(para.areaCode, para.vmCode, para.drill);
} //}
ThrowIf.IsNull(vm, "输入参数有误, id 和 areaCode,vmCode 不可同时为空"); //ThrowIf.IsNull(vm, "输入参数有误, id 和 areaCode,vmCode 不可同时为空");
return vm; return await base.GetAsync(input);
} }
/// <summary> ///// <summary>
/// 获取多条 数据列表 ///// 获取多条 数据列表
/// </summary> ///// </summary>
public override async Task<PagedOutput<dynamic>> GetListAsync(VmGetListInput input) //public override async Task<PagedOutput<dynamic>> GetListAsync(VmGetListInput input)
{ //{
return await ListAsync(input.ToQueryInput()); // return await ListAsync(input.ToQueryInput());
} //}
[NonAction] [NonAction]
public override async Task<PagedOutput<dynamic>> ListAsync(VmQueryInput input) public override async Task<PagedOutput<dynamic>> ListAsync(VmQueryInput input)

View File

@@ -3,6 +3,8 @@
// https://git.tuotong-tech.com/tnb/tnb.server // // https://git.tuotong-tech.com/tnb/tnb.server //
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
using Tnb.Vengine.Domain;
namespace Tnb.Vengine.AppService; namespace Tnb.Vengine.AppService;
public class VmodelCreateFromTableInput public class VmodelCreateFromTableInput
@@ -21,7 +23,7 @@ public class CreatePageFromVmodelInput
public string? vmid { get; set; } public string? vmid { get; set; }
} }
public class VmodelGetInput public class VmodelGetInput : VmGetInput
{ {
public string? areaCode { get; set; } public string? areaCode { get; set; }
public string? vmCode { get; set; } public string? vmCode { get; set; }

View File

@@ -65,19 +65,19 @@ public partial class Vmodel : Entity
/// 表字段属性 /// 表字段属性
/// </summary> /// </summary>
[SugarColumn(ColumnName = "db_props", IsNullable = false, IsJson = true)] [SugarColumn(ColumnName = "db_props", IsNullable = false, IsJson = true)]
public List<VmDbProp> dbProps { get; set; } = []; public List<VmDbProp> dbProps { get; set; } = new List<VmDbProp>();
/// <summary> /// <summary>
/// 导航属性 /// 导航属性
/// </summary> /// </summary>
[SugarColumn(ColumnName = "nav_props", IsNullable = true, IsJson = true)] [SugarColumn(ColumnName = "nav_props", IsNullable = true, IsJson = true)]
public List<VmNavProp> navProps { get; set; } = []; public List<VmNavProp> navProps { get; set; } = new List<VmNavProp>();
/// <summary> /// <summary>
/// 计算属性 /// 计算属性
/// </summary> /// </summary>
[SugarColumn(ColumnName = "cal_props", IsNullable = true, IsJson = true)] [SugarColumn(ColumnName = "cal_props", IsNullable = true, IsJson = true)]
public List<VmCalProp> calProps { get; set; } = []; public List<VmCalProp> calProps { get; set; } = new List<VmCalProp>();
/// <summary> /// <summary>
/// 排序 /// 排序
@@ -225,7 +225,7 @@ public partial class Vmodel : Entity
/// <returns></returns> /// <returns></returns>
public DObject GetDefaultDObject() public DObject GetDefaultDObject()
{ {
DObject obj = []; DObject obj = new ();
foreach (VmDbProp p in dbProps) foreach (VmDbProp p in dbProps)
{ {
obj.Add(p.code, p.GetDefaultValue()!); obj.Add(p.code, p.GetDefaultValue()!);
@@ -239,7 +239,7 @@ public partial class Vmodel : Entity
/// <returns></returns> /// <returns></returns>
public DObject ToCreateEntity(DObject input, IUserManager user) public DObject ToCreateEntity(DObject input, IUserManager user)
{ {
DObject obj = []; DObject obj = new ();
foreach (VmDbProp p in dbProps) foreach (VmDbProp p in dbProps)
{ {
if (input.ContainsKey(p.code)) if (input.ContainsKey(p.code))
@@ -273,7 +273,7 @@ public partial class Vmodel : Entity
/// <returns></returns> /// <returns></returns>
public DObject ToUpdateEntity(DObject input, IUserManager user) public DObject ToUpdateEntity(DObject input, IUserManager user)
{ {
DObject obj = []; DObject obj = new ();
foreach (VmDbProp p in dbProps) foreach (VmDbProp p in dbProps)
{ {
if (input.ContainsKey(p.code)) if (input.ContainsKey(p.code))