查询模型详情时,钻取导航属性的模型

This commit is contained in:
2023-09-22 16:36:45 +08:00
parent 0afd486af2
commit 6f2d70725f
2 changed files with 15 additions and 9 deletions

View File

@@ -4,6 +4,8 @@
///////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////
using JNPF; using JNPF;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.ViewEngine; using JNPF.ViewEngine;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@@ -35,17 +37,22 @@ public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
/// </summary> /// </summary>
public override async Task<dynamic> GetAsync(VmGetInput input) public override async Task<dynamic> GetAsync(VmGetInput input)
{ {
VmodelGetInput para = new VmodelGetInput();
if (!string.IsNullOrEmpty(input.q))
{
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; Vmodel? vm = null;
if (long.TryParse(input.id, out long id)) if (!string.IsNullOrEmpty(input.id))
{ {
query.Where(a => a.id == input.id); vm = await _dataAccess.GetVmodelAsync(input.id, para.drill);
vm = await query.FirstAsync();
} }
else else if(!string.IsNullOrEmpty(para.areaCode) && !string.IsNullOrEmpty(para.vmCode))
{ {
vm = await query.FirstAsync(a => a.vmCode == input.id); vm = await _dataAccess.GetVmodelAsync(para.areaCode, para.vmCode, para.drill);
} }
ThrowIf.IsNull(vm, "输入参数有误, id 和 areaCode,vmCode 不可同时为空");
return vm; return vm;
} }

View File

@@ -23,10 +23,9 @@ public class CreatePageFromVmodelInput
public class VmodelGetInput public class VmodelGetInput
{ {
public long? id { get; set; } public string? areaCode { get; set; }
public string? moduleCode { get; set; }
public string? vmCode { get; set; } public string? vmCode { get; set; }
public string? dbCode { get; set; } public string? dbCode { get; set; }
public string? tableName { get; set; } public string? tableName { get; set; }
public bool drill { get; set; } public bool drill { get; set; } = false;
} }