修复清理vengine
This commit is contained in:
@@ -13,4 +13,4 @@ namespace Tnb.Vengine.AppService;
|
||||
/// </summary>
|
||||
public class BaseAppService : IDynamicApiController, ITransient
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,4 @@ namespace Tnb.Vengine.AppService;
|
||||
/// </summary>
|
||||
public interface IVengineAppService : ITransient
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,4 @@ namespace Tnb.Vengine.AppService;
|
||||
/// </summary>
|
||||
public interface IVmodelAppService : ITransient
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,4 @@ namespace Tnb.Vengine.AppService;
|
||||
/// </summary>
|
||||
public interface IVmodelPageAppService : ITransient
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 获取一条 数据信息
|
||||
/// </summary>
|
||||
[HttpGet("api/[area]/[controller]/{vmid}/get")]
|
||||
public async Task<dynamic?> GetAsync(string vmid, VmGetInput input)
|
||||
public async Task<dynamic?> GetAsync(string vmid, [FromQuery]VmGetInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid, true);
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
@@ -57,7 +57,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpGet("api/[area]/[controller]/{vmid}/get-list")]
|
||||
public async Task<VmPagedOutput> GetListAsync(string vmid, VmGetListInput input)
|
||||
public async Task<VmPagedOutput> GetListAsync(string vmid, [FromQuery] VmGetListInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid, true);
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
@@ -73,7 +73,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpPost("api/[area]/[controller]/{vmid}/query")]
|
||||
public async Task<VmPagedOutput> QueryAsync(string vmid, VmQueryInput input)
|
||||
public async Task<VmPagedOutput> QueryAsync(string vmid, [FromBody] VmQueryInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid, true);
|
||||
var ls = await _dataAccess.QueryDataAsync(vm, input);
|
||||
@@ -84,7 +84,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 新增 数据
|
||||
/// </summary>
|
||||
[HttpPost("api/[area]/[controller]/{vmid}/create")]
|
||||
public async Task<dynamic> CreateAsync(string vmid, VmCreateInput input)
|
||||
public async Task<dynamic> CreateAsync(string vmid, [FromBody] VmCreateInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid);
|
||||
var ret = await _dataAccess.CreateDataAsync(vm, input);
|
||||
@@ -95,7 +95,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 更新 数据
|
||||
/// </summary>
|
||||
[HttpPut("api/[area]/[controller]/{vmid}/update")]
|
||||
public async Task<dynamic> UpdateAsync(string vmid, VmUpdateInput input)
|
||||
public async Task<dynamic> UpdateAsync(string vmid, [FromBody] VmUpdateInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid);
|
||||
var ret = await _dataAccess.UpdateDataAsync(vm, input);
|
||||
@@ -106,19 +106,20 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 删除 数据
|
||||
/// </summary>
|
||||
[HttpDelete("api/[area]/[controller]/{vmid}/delete")]
|
||||
public async Task<dynamic> DeleteAsync(string vmid, VmDeleteInput input)
|
||||
public async Task<dynamic> DeleteAsync(string vmid, [FromQuery] VmDeleteInput input)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(vmid);
|
||||
var ret = await _dataAccess.DeleteDataAsync(vm, input);
|
||||
return ret;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion 按模型的id进行增删改查接口
|
||||
|
||||
#region 按模型的areaCode和vmcode进行增删改查接口
|
||||
|
||||
private async Task<Vmodel> GetVmodelAsync(string areaCode, string vmCode)
|
||||
{
|
||||
var vm = await _dataAccess.GetVmodelAsync(areaCode, vmCode, false);
|
||||
var vm = await _dataAccess.GetVmodelAsync(areaCode, vmCode, true);
|
||||
return vm;
|
||||
}
|
||||
|
||||
@@ -126,7 +127,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 获取一条 数据信息
|
||||
/// </summary>
|
||||
[HttpGet("api/{areaCode}/{vmCode}/get")]
|
||||
public async Task<dynamic?> GetAsync(string areaCode, string vmCode, VmGetInput input)
|
||||
public async Task<dynamic?> GetAsync(string areaCode, string vmCode, [FromQuery] VmGetInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
@@ -143,7 +144,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpGet("api/{areaCode}/{vmCode}/get-list")]
|
||||
public async Task<VmPagedOutput> GetListAsync(string areaCode, string vmCode, VmGetListInput input)
|
||||
public async Task<VmPagedOutput> GetListAsync(string areaCode, string vmCode, [FromQuery] VmGetListInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
@@ -159,7 +160,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpPost("api/{areaCode}/{vmCode}/query")]
|
||||
public async Task<VmPagedOutput> QueryAsync(string areaCode, string vmCode, VmQueryInput input)
|
||||
public async Task<VmPagedOutput> QueryAsync(string areaCode, string vmCode, [FromBody] VmQueryInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
var ls = await _dataAccess.QueryDataAsync(vm, input);
|
||||
@@ -170,7 +171,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 新增 数据
|
||||
/// </summary>
|
||||
[HttpPost("api/{areaCode}/{vmCode}/create")]
|
||||
public async Task<dynamic> CreateAsync(string areaCode, string vmCode, VmCreateInput input)
|
||||
public async Task<dynamic> CreateAsync(string areaCode, string vmCode, [FromBody] VmCreateInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
var ret = await _dataAccess.CreateDataAsync(vm, input);
|
||||
@@ -181,7 +182,7 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 更新 数据
|
||||
/// </summary>
|
||||
[HttpPut("api/{areaCode}/{vmCode}/update")]
|
||||
public async Task<dynamic> UpdateAsync(string areaCode, string vmCode, VmUpdateInput input)
|
||||
public async Task<dynamic> UpdateAsync(string areaCode, string vmCode, [FromBody] VmUpdateInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
var ret = await _dataAccess.UpdateDataAsync(vm, input);
|
||||
@@ -192,12 +193,12 @@ public class VengineAppService : BaseAppService, IVengineAppService
|
||||
/// 删除 数据
|
||||
/// </summary>
|
||||
[HttpDelete("api/{areaCode}/{vmCode}/delete")]
|
||||
public async Task<dynamic> DeleteAsync(string areaCode, string vmCode, VmDeleteInput input)
|
||||
public async Task<dynamic> DeleteAsync(string areaCode, string vmCode, [FromQuery] VmDeleteInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync(areaCode, vmCode);
|
||||
var ret = await _dataAccess.DeleteDataAsync(vm, input);
|
||||
return ret;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
#endregion 按模型的areaCode和vmcode进行增删改查接口
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using System.Reflection;
|
||||
using JNPF;
|
||||
using JNPF.Common.Security;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@@ -64,7 +63,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
/// 获取一条 数据信息
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public virtual async Task<dynamic> GetAsync(VmGetInput input)
|
||||
public virtual async Task<dynamic> GetAsync([FromQuery] VmGetInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
@@ -81,7 +80,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public virtual async Task<VmPagedOutput> GetListAsync(VmGetListInput input)
|
||||
public virtual async Task<VmPagedOutput> GetListAsync([FromQuery] VmGetListInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
VmQueryInput arg = input.Adapt<VmQueryInput>();
|
||||
@@ -97,7 +96,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
/// 获取多条 数据列表
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public virtual async Task<VmPagedOutput> QueryAsync(VmQueryInput input)
|
||||
public virtual async Task<VmPagedOutput> QueryAsync([FromBody] VmQueryInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
var ls = await _dataAccess.QueryDataAsync(vm, input);
|
||||
@@ -108,7 +107,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
/// 新增 数据
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
public virtual async Task<dynamic> CreateAsync(VmCreateInput input)
|
||||
public virtual async Task<dynamic> CreateAsync([FromBody] VmCreateInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
var ret = await _dataAccess.CreateDataAsync(vm, input);
|
||||
@@ -119,7 +118,7 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
/// 更新 数据
|
||||
/// </summary>
|
||||
[HttpPut]
|
||||
public virtual async Task<dynamic> UpdateAsync(VmUpdateInput input)
|
||||
public virtual async Task<dynamic> UpdateAsync([FromBody] VmUpdateInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
var ret = await _dataAccess.UpdateDataAsync(vm, input);
|
||||
@@ -130,11 +129,10 @@ public class VengineAppService<TEntity> : BaseAppService where TEntity : Entity
|
||||
/// 删除 数据
|
||||
/// </summary>
|
||||
[HttpDelete]
|
||||
public virtual async Task<dynamic> DeleteAsync(VmDeleteInput input)
|
||||
public virtual async Task<dynamic> DeleteAsync([FromQuery] VmDeleteInput input)
|
||||
{
|
||||
var vm = await GetVmodelAsync();
|
||||
var ret = await _dataAccess.DeleteDataAsync(vm, input);
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,13 @@
|
||||
// https://git.tuotong-tech.com/tnb/tnb-server //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using JNPF.Common.Configuration;
|
||||
using JNPF;
|
||||
using JNPF.ViewEngine;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
using Tnb.Core;
|
||||
using Tnb.Vengine.DataAccess;
|
||||
using Tnb.Vengine.Domain;
|
||||
using JNPF.ViewEngine;
|
||||
|
||||
namespace Tnb.Vengine.AppService;
|
||||
|
||||
@@ -22,11 +20,12 @@ namespace Tnb.Vengine.AppService;
|
||||
[Route("api/[area]/[controller]/[action]")]
|
||||
public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
|
||||
{
|
||||
private readonly ViewEngine _viewEngine;
|
||||
private readonly IViewEngine _viewEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public VmodelAppService(IDataAccess da, ViewEngine viewEngine) : base(da)
|
||||
public VmodelAppService(IDataAccess da, IViewEngine viewEngine) : base(da)
|
||||
{
|
||||
_viewEngine = viewEngine;
|
||||
}
|
||||
@@ -221,8 +220,6 @@ public class VmodelAppService : VengineAppService<Vmodel>, IVmodelAppService
|
||||
//code = CodeHelper.RunCompile($"{TemplateContext.KeyEntityPageVue}.cshtml", ctx, null, "SqlSugar");
|
||||
//CodeHelper.SaveCodeToFile(code, filePath);
|
||||
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,4 @@ public class VmodelGetInput
|
||||
public string? dbCode { get; set; }
|
||||
public string? tableName { get; set; }
|
||||
public bool drill { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,14 +3,12 @@
|
||||
// https://git.tuotong-tech.com/tnb/tnb-server //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using System.Text;
|
||||
using JNPF.Common.Security;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using System.Text;
|
||||
using Tnb.Core;
|
||||
using Tnb.Vengine.DataAccess;
|
||||
using Tnb.Vengine.Domain;
|
||||
|
||||
@@ -167,5 +165,4 @@ public class VmodelPageAppService : VengineAppService<VmodelPage>, IVmodelPageAp
|
||||
Console.WriteLine(s);
|
||||
return JObject.Parse(s);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,4 +14,4 @@ public class VmodelSettingAttribute : Attribute
|
||||
Area = area;
|
||||
Code = code;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,14 +16,14 @@ public class AcmenVmodelContext : TemplateContext
|
||||
_da = da;
|
||||
Vm = vm;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public IDataAccess _da { get; set; }
|
||||
|
||||
public Vmodel Vm { get; }
|
||||
|
||||
public string NsPrefix { get { return "Tnb"; } }
|
||||
|
||||
}
|
||||
|
||||
|
||||
public string NsPrefix
|
||||
{ get { return "Tnb"; } }
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Globalization;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Tnb.Vengine;
|
||||
|
||||
@@ -115,9 +114,10 @@ public class CodeHelper
|
||||
float.TryParse(propDefine, out float f);
|
||||
return (int)f;
|
||||
}
|
||||
|
||||
public static int PropDefineToScale(string? propDefine)
|
||||
{
|
||||
float.TryParse(propDefine, out float f);
|
||||
return (int)(f * 10) % 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using JNPF.Common.Configuration;
|
||||
using Tnb.Core;
|
||||
|
||||
namespace Tnb.Vengine;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public class TemplateContext
|
||||
{
|
||||
#region 模板文件名,同时作为模板Key
|
||||
|
||||
public const string KeyAppService = "AppService";
|
||||
public const string KeyDto = "AppServiceDto";
|
||||
public const string KeyEntity = "EntityInfo";
|
||||
@@ -17,10 +17,11 @@ public class TemplateContext
|
||||
public const string KeyEntityPageVue = "EntityPageVue";
|
||||
public const string KeyTableForeigns = "TableForeigns";
|
||||
public const string KeyVmodel = "Vmodel";
|
||||
#endregion
|
||||
|
||||
#endregion 模板文件名,同时作为模板Key
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public TemplateContext(string moduleCode)
|
||||
{
|
||||
@@ -31,27 +32,32 @@ public class TemplateContext
|
||||
#endif
|
||||
ModuleCode = moduleCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public string BasePath { get; set; }
|
||||
|
||||
private string ModuleCode { get; }
|
||||
|
||||
private string ModulePath => Path.Combine(BasePath, $"{ModuleCode}.Acmen");
|
||||
private string UiProjPath => Path.Combine(BasePath, "ItMgrWeb");
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public string AppServicePath => Path.Combine(ModulePath, "AppServices");
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public string PagePath => Path.Combine(UiProjPath, "src", "views");
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
@@ -75,4 +81,4 @@ public enum eLambdaType
|
||||
Where,
|
||||
MemberBinding,
|
||||
OneToMany
|
||||
}
|
||||
}
|
||||
@@ -66,5 +66,4 @@ public static class DbConsts
|
||||
public static Guid RoleAdminId = Guid.Parse("39fea2c8-01a4-75cd-026f-2f0349a94098");
|
||||
public static Guid EventDefaultCategoryId = Guid.Parse("39ffae5d-13d2-1e43-3f0e-98f774f71c8a");
|
||||
public static Guid DefaultViewId = Guid.Parse("39fea2c1-b2dd-cfae-1c3d-89de77f94709");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,4 +5,4 @@ public class ModuleConst
|
||||
public const string Tag = "Tnb";
|
||||
public const string Area = "tnb";
|
||||
public const string NsPrefix = "Tnb";
|
||||
}
|
||||
}
|
||||
@@ -11,41 +11,59 @@ public enum eCsType
|
||||
{
|
||||
[Description("string")]
|
||||
String = 10,
|
||||
|
||||
[Description("bool")]
|
||||
Bool = 12,
|
||||
|
||||
[Description("uuid")]
|
||||
Guid = 14,
|
||||
|
||||
[Description("int")]
|
||||
Int = 20,
|
||||
|
||||
[Description("short")]
|
||||
Short = 22,
|
||||
|
||||
[Description("long")]
|
||||
Long = 24,
|
||||
|
||||
[Description("float")]
|
||||
Float = 30,
|
||||
|
||||
[Description("double")]
|
||||
Double = 32,
|
||||
|
||||
[Description("decimal")]
|
||||
Decimal = 34,
|
||||
|
||||
[Description("date")]
|
||||
Date = 40,
|
||||
|
||||
[Description("time")]
|
||||
Time = 42,
|
||||
|
||||
[Description("datetime")]
|
||||
DateTime = 44,
|
||||
|
||||
[Description("timestamp")]
|
||||
Timestamp = 46,
|
||||
|
||||
[Description("enum")]
|
||||
Enum = 50,
|
||||
|
||||
[Description("dictionary")]
|
||||
Dictionary = 52,
|
||||
|
||||
[Description("json")]
|
||||
Json = 60,
|
||||
|
||||
[Description("entity")]
|
||||
Entity = 70,
|
||||
|
||||
[Description("customer")]
|
||||
Customer = 80,
|
||||
}
|
||||
|
||||
public enum eDbType
|
||||
{
|
||||
MySql,
|
||||
@@ -59,38 +77,51 @@ public enum eDbType
|
||||
Redis,
|
||||
InfluxDb
|
||||
}
|
||||
|
||||
public enum eResourceType
|
||||
{
|
||||
[Description("菜单")]
|
||||
Menu = 10,
|
||||
|
||||
[Description("页面")]
|
||||
Page = 20,
|
||||
|
||||
[Description("按钮")]
|
||||
Button = 30,
|
||||
|
||||
[Description("接口")]
|
||||
Interface = 40,
|
||||
|
||||
[Description("视图")]
|
||||
View = 50,
|
||||
}
|
||||
|
||||
public enum eSearchType
|
||||
{
|
||||
[Description("无")]
|
||||
None = 0,
|
||||
|
||||
[Description("精准查询")]
|
||||
Exact = 1,
|
||||
|
||||
[Description("模糊查询")]
|
||||
Fuzzy = 2,
|
||||
|
||||
[Description("范围查询")]
|
||||
Range = 3,
|
||||
}
|
||||
|
||||
public enum eNavigateType
|
||||
{
|
||||
[Description("无")]
|
||||
None = 0,
|
||||
|
||||
[Description("一对一")]
|
||||
OneToOne = 1,
|
||||
|
||||
[Description("一对多")]
|
||||
OneToMany = 2,
|
||||
|
||||
[Description("多对多")]
|
||||
ManyToMany = 3,
|
||||
}
|
||||
@@ -102,8 +133,10 @@ public enum ePropType
|
||||
{
|
||||
[Description("表字段")]
|
||||
DbTable = 0,
|
||||
|
||||
[Description("计算属性")]
|
||||
Calculate = 1,
|
||||
|
||||
[Description("导航属性")]
|
||||
Navigate = 2,
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,32 @@
|
||||
using JNPF;
|
||||
using System.Collections.Concurrent;
|
||||
using JNPF;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using SqlSugar;
|
||||
using System.Collections.Concurrent;
|
||||
using Tnb.Core;
|
||||
using Tnb.Vengine.Domain;
|
||||
|
||||
namespace Tnb.Vengine.DataAccess;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
{
|
||||
const int MAX_PAGE_SIZE = 1000;
|
||||
private const int MAX_PAGE_SIZE = 1000;
|
||||
private ISqlSugarClient? _db;
|
||||
|
||||
protected ISqlSugarClient Db
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_db == null)
|
||||
{
|
||||
var dbType = App.Configuration.GetConnectionString("DbType");
|
||||
var dbConn = App.Configuration.GetConnectionString("DbConn");
|
||||
_db = SugarHelper.CreateSugarClient("_db_default_", dbType, dbConn);
|
||||
ConnectionStringsOptions conn = App.GetConfig<ConnectionStringsOptions>("ConnectionStrings", true);
|
||||
//var dbType = App.Configuration.GetConnectionString("DbType");
|
||||
//var dbConn = App.Configuration.GetConnectionString("DbConn");
|
||||
_db = SugarHelper.CreateSugarClient(conn.ConfigId, conn.DBType, conn.ConnectString);
|
||||
}
|
||||
return _db;
|
||||
}
|
||||
@@ -35,7 +37,7 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
/// <summary>
|
||||
/// 全局缓存
|
||||
/// </summary>
|
||||
static ConcurrentDictionary<string, ISqlSugarClient> DbCache = new ConcurrentDictionary<string, ISqlSugarClient>();
|
||||
private static ConcurrentDictionary<string, ISqlSugarClient> DbCache = new ConcurrentDictionary<string, ISqlSugarClient>();
|
||||
|
||||
/// <summary>
|
||||
/// 构造
|
||||
@@ -290,9 +292,7 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
{
|
||||
ret.Add(prop.navCode, new List<DObject>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
@@ -424,5 +424,4 @@ public class DataAccess : IDataAccess, ITransient, IDisposable
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using Tnb.Vengine.Domain;
|
||||
namespace Tnb.Vengine.DataAccess;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public interface IDataAccess : ITransient
|
||||
{
|
||||
@@ -27,18 +27,22 @@ public interface IDataAccess : ITransient
|
||||
/// 获取 Vmodel, 为空时不抛异常
|
||||
/// </summary>
|
||||
Task<Vmodel?> TryGetVmodelAsync(string id, bool loadNavigate = false);
|
||||
|
||||
/// <summary>
|
||||
/// 获取 Vmodel, 为空时抛异常
|
||||
/// </summary>
|
||||
Task<Vmodel> GetVmodelAsync(string id, bool loadNavigate = false);
|
||||
|
||||
/// <summary>
|
||||
/// 获取 Vmodel, 为空时不抛异常
|
||||
/// </summary>
|
||||
Task<Vmodel?> TryGetVmodelAsync(string area, string vmCode, bool loadNavigate = false);
|
||||
|
||||
/// <summary>
|
||||
/// 获取 Vmodel, 为空时抛异常
|
||||
/// </summary>
|
||||
Task<Vmodel> GetVmodelAsync(string area, string vmCode, bool loadNavigate = false);
|
||||
|
||||
//Task<VmPagedOutput> QueryDataAsync(VmBaseInput input);
|
||||
|
||||
/// <summary>
|
||||
@@ -63,4 +67,4 @@ public interface IDataAccess : ITransient
|
||||
/// 删除数据 默认方法
|
||||
/// </summary>
|
||||
Task<int> DeleteDataAsync(Vmodel vm, VmDeleteInput input);
|
||||
}
|
||||
}
|
||||
@@ -7,67 +7,67 @@ namespace Tnb.Vengine.DataAccess;
|
||||
|
||||
public class SugarHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建SugarClient实例
|
||||
/// </summary>
|
||||
public static ISqlSugarClient CreateSugarClient(string dbCode, string dbType, string dbConnection, Action<ConnectionConfig>? configConnection = null, Action<ISqlSugarClient>? configSugar = null)
|
||||
{
|
||||
var config = new ConnectionConfig
|
||||
/// <summary>
|
||||
/// 创建SugarClient实例
|
||||
/// </summary>
|
||||
public static ISqlSugarClient CreateSugarClient(string dbCode, string dbType, string dbConnection, Action<ConnectionConfig>? configConnection = null, Action<ISqlSugarClient>? configSugar = null)
|
||||
{
|
||||
ConnectionString = dbConnection,
|
||||
DbType = dbType.Adapt<DbType>(),
|
||||
IsAutoCloseConnection = true,
|
||||
ConfigId = dbCode,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
MoreSettings = new ConnMoreSettings()
|
||||
{
|
||||
IsAutoRemoveDataCache = true, // 自动清理缓存
|
||||
IsAutoToUpper = false,
|
||||
PgSqlIsAutoToLower = false,
|
||||
DisableNvarchar = true
|
||||
},
|
||||
};
|
||||
configConnection?.Invoke(config);
|
||||
var sugar = new SqlSugarScope(config, configSugar == null ? ConfigSugar : configSugar);
|
||||
return sugar;
|
||||
}
|
||||
var config = new ConnectionConfig
|
||||
{
|
||||
ConnectionString = dbConnection,
|
||||
DbType = dbType.Adapt<DbType>(),
|
||||
IsAutoCloseConnection = true,
|
||||
ConfigId = dbCode,
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
MoreSettings = new ConnMoreSettings()
|
||||
{
|
||||
IsAutoRemoveDataCache = true, // 自动清理缓存
|
||||
IsAutoToUpper = false,
|
||||
PgSqlIsAutoToLower = false,
|
||||
DisableNvarchar = true
|
||||
},
|
||||
};
|
||||
configConnection?.Invoke(config);
|
||||
var sugar = new SqlSugarScope(config, configSugar == null ? ConfigSugar : configSugar);
|
||||
return sugar;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SqlSugar默认配置
|
||||
/// </summary>
|
||||
/// <param name="db"></param>
|
||||
public static void ConfigSugar(ISqlSugarClient db)
|
||||
{
|
||||
// 设置超时时间
|
||||
db.Ado.CommandTimeOut = 30;
|
||||
db.Aop.OnLogExecuted = (sql, pars) =>
|
||||
/// <summary>
|
||||
/// SqlSugar默认配置
|
||||
/// </summary>
|
||||
/// <param name="db"></param>
|
||||
public static void ConfigSugar(ISqlSugarClient db)
|
||||
{
|
||||
var finalSql = UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, sql, pars);
|
||||
if (db.Ado.SqlExecutionTime.TotalMilliseconds > 3000)
|
||||
{
|
||||
Log.Warning($"慢查询: {db.Ado.SqlExecutionTime.TotalMilliseconds}ms, SQL: " + finalSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine($"【{DateTime.Now.ToString("HH:mm:ss.fff")}——SQL执行完成】{db.Ado.SqlExecutionTime.TotalMilliseconds} ms");
|
||||
Console.WriteLine(finalSql);
|
||||
Console.ForegroundColor = oldColor;
|
||||
Console.WriteLine();
|
||||
}
|
||||
};
|
||||
db.Aop.OnError = (ex) =>
|
||||
{
|
||||
Log.Error(UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, ex.Sql, (SugarParameter[])ex.Parametres));
|
||||
};
|
||||
}
|
||||
// 设置超时时间
|
||||
db.Ado.CommandTimeOut = 30;
|
||||
db.Aop.OnLogExecuted = (sql, pars) =>
|
||||
{
|
||||
var finalSql = UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, sql, pars);
|
||||
if (db.Ado.SqlExecutionTime.TotalMilliseconds > 3000)
|
||||
{
|
||||
Log.Warning($"慢查询: {db.Ado.SqlExecutionTime.TotalMilliseconds}ms, SQL: " + finalSql);
|
||||
}
|
||||
else
|
||||
{
|
||||
var oldColor = Console.ForegroundColor;
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine($"【{DateTime.Now.ToString("HH:mm:ss.fff")}——SQL执行完成】{db.Ado.SqlExecutionTime.TotalMilliseconds} ms");
|
||||
Console.WriteLine(finalSql);
|
||||
Console.ForegroundColor = oldColor;
|
||||
Console.WriteLine();
|
||||
}
|
||||
};
|
||||
db.Aop.OnError = (ex) =>
|
||||
{
|
||||
Log.Error(UtilMethods.GetSqlString(db.CurrentConnectionConfig.DbType, ex.Sql, (SugarParameter[])ex.Parametres));
|
||||
};
|
||||
}
|
||||
|
||||
public static void CustomSnowId()
|
||||
{
|
||||
StaticConfig.CustomSnowFlakeFunc = () =>
|
||||
public static void CustomSnowId()
|
||||
{
|
||||
return YitIdHelper.NextId();
|
||||
};
|
||||
}
|
||||
}
|
||||
StaticConfig.CustomSnowFlakeFunc = () =>
|
||||
{
|
||||
return YitIdHelper.NextId();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -10,21 +10,21 @@ namespace Tnb.Vengine.Domain;
|
||||
[Serializable]
|
||||
public abstract class Entity : IEntity
|
||||
{
|
||||
protected Entity()
|
||||
{
|
||||
//EntityHelper.TrySetTenantId(this);
|
||||
}
|
||||
protected Entity()
|
||||
{
|
||||
//EntityHelper.TrySetTenantId(this);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[ENTITY: {GetType().Name}] Keys = {string.Join(", ", GetKeys())}";
|
||||
}
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return $"[ENTITY: {GetType().Name}] Keys = {string.Join(", ", GetKeys())}";
|
||||
}
|
||||
|
||||
public abstract object[] GetKeys();
|
||||
public abstract object[] GetKeys();
|
||||
|
||||
//public bool EntityEquals(IEntity other)
|
||||
//{
|
||||
// return EntityHelper.EntityEquals(this, other);
|
||||
//}
|
||||
}
|
||||
//public bool EntityEquals(IEntity other)
|
||||
//{
|
||||
// return EntityHelper.EntityEquals(this, other);
|
||||
//}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ public class VmBaseInput
|
||||
///// </summary>
|
||||
//public string vmid { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class VmGetInput : VmBaseInput
|
||||
{
|
||||
/// <summary>
|
||||
@@ -58,6 +59,7 @@ public class VmGetListInput : VmBaseInput
|
||||
/// 过滤条件
|
||||
/// </summary>
|
||||
public string? q { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 输出字段
|
||||
/// </summary>
|
||||
@@ -138,7 +140,6 @@ public class PagedOutput<T>
|
||||
/// </summary>
|
||||
public class VmPagedOutput : PagedOutput<dynamic>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -152,4 +153,4 @@ public class VmSelectProp
|
||||
public string navCode { get; set; } = MAIN_ALIES;
|
||||
public ePropType propType { get; set; }
|
||||
public eNavigateType navType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -12,25 +12,25 @@ namespace Tnb.Vengine.Domain;
|
||||
/// </summary>
|
||||
public class VmBaseProp
|
||||
{
|
||||
/// <summary>
|
||||
/// 属性代码
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 属性代码
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 显示名称
|
||||
/// </summary>
|
||||
public string name { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 显示名称
|
||||
/// </summary>
|
||||
public string name { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public class DictOption
|
||||
{
|
||||
public string dictTypeId { get; set; } = string.Empty;
|
||||
public string refField { get; set; } = "id";
|
||||
public string dictTypeId { get; set; } = string.Empty;
|
||||
public string refField { get; set; } = "id";
|
||||
}
|
||||
|
||||
public class CompOption
|
||||
{
|
||||
public string type { get; set; } = "el-input";
|
||||
public JObject attr { get; set; } = new JObject();
|
||||
public string type { get; set; } = "el-input";
|
||||
public JObject attr { get; set; } = new JObject();
|
||||
}
|
||||
@@ -5,8 +5,7 @@
|
||||
|
||||
namespace Tnb.Vengine.Domain;
|
||||
|
||||
|
||||
public class VmCalProp : VmBaseProp
|
||||
{
|
||||
public string calculate { get; set; } = string.Empty;
|
||||
}
|
||||
public string calculate { get; set; } = string.Empty;
|
||||
}
|
||||
@@ -15,6 +15,7 @@ namespace Tnb.Vengine.Domain;
|
||||
public class VmDbProp : VmBaseProp
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// 字段名称
|
||||
/// </summary>
|
||||
@@ -70,7 +71,8 @@ public class VmDbProp : VmBaseProp
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string? descrip { get; set; }
|
||||
#endregion
|
||||
|
||||
#endregion Properties
|
||||
|
||||
/// <summary>
|
||||
/// 获取默认值
|
||||
@@ -79,7 +81,7 @@ public class VmDbProp : VmBaseProp
|
||||
public object? GetDefaultValue()
|
||||
{
|
||||
object? val = null;
|
||||
if(!required) { return val; }
|
||||
if (!required) { return val; }
|
||||
if (string.IsNullOrEmpty(defValue))
|
||||
{
|
||||
val = csType switch
|
||||
@@ -168,11 +170,13 @@ public class VmDbProp : VmBaseProp
|
||||
comp.attr.Add("maxlength", length);
|
||||
comp.attr.Add("showWordLimit", true);
|
||||
break;
|
||||
|
||||
case "int":
|
||||
case "short":
|
||||
case "long":
|
||||
comp.type = "el-input-number";
|
||||
break;
|
||||
|
||||
case "DateTime":
|
||||
comp.type = "el-date-picker";
|
||||
break;
|
||||
@@ -205,6 +209,5 @@ public class VmDbProp : VmBaseProp
|
||||
//if(isJson) sb.Add("IsJson = true")
|
||||
if (sb.Any()) attr += $"\t[SugarColumn({sb.JoinAsString(", ")})]{Environment.NewLine}";
|
||||
return attr;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,6 @@ public class VmNavProp : VmBaseProp
|
||||
|
||||
[JsonIgnore]
|
||||
public Vmodel? naviModel { get; set; }
|
||||
#endregion
|
||||
|
||||
}
|
||||
#endregion Properties
|
||||
}
|
||||
@@ -3,15 +3,15 @@
|
||||
// https://git.tuotong-tech.com/tnb/tnb.server //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Reflection;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Extension;
|
||||
using Mapster;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Reflection;
|
||||
using Tnb.Core;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Tnb.Vengine.Domain;
|
||||
public partial class Vmodel : Entity
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// 主键标识
|
||||
/// </summary>
|
||||
@@ -133,7 +134,8 @@ public partial class Vmodel : Entity
|
||||
public string? modifyId { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string fullCode { get { return areaCode + "/" + vmCode; } }
|
||||
public string fullCode
|
||||
{ get { return areaCode + "/" + vmCode; } }
|
||||
|
||||
/// <summary>
|
||||
/// 主键
|
||||
@@ -142,7 +144,8 @@ public partial class Vmodel : Entity
|
||||
{
|
||||
return new object[] { id };
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion Properties
|
||||
|
||||
/// <summary>
|
||||
/// 通过实体创建模型
|
||||
@@ -351,7 +354,6 @@ public partial class Vmodel : Entity
|
||||
// TODO 按子表条件查询
|
||||
if (item.Key.Contains("."))
|
||||
{
|
||||
|
||||
}
|
||||
var prop = dbProps.FirstOrDefault(a => a.code == item.Key);
|
||||
if (prop == null) continue;
|
||||
@@ -364,21 +366,26 @@ public partial class Vmodel : Entity
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThan, CSharpTypeName = prop.csType });
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThan, CSharpTypeName = prop.csType });
|
||||
break;
|
||||
|
||||
case ">=<":
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThanOrEqual, CSharpTypeName = prop.csType });
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThan, CSharpTypeName = prop.csType });
|
||||
break;
|
||||
|
||||
case "><=":
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThan, CSharpTypeName = prop.csType });
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThanOrEqual, CSharpTypeName = prop.csType });
|
||||
break;
|
||||
|
||||
case ">=<=":
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[1].ToString(), ConditionalType = ConditionalType.GreaterThanOrEqual, CSharpTypeName = prop.csType });
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val[2].ToString(), ConditionalType = ConditionalType.LessThanOrEqual, CSharpTypeName = prop.csType });
|
||||
break;
|
||||
|
||||
case "in":
|
||||
wheres.Add(new ConditionalModel { FieldName = prop.field, FieldValue = val.Skip(1).ToString(), ConditionalType = ConditionalType.In, CSharpTypeName = prop.csType });
|
||||
break;
|
||||
|
||||
default: op = string.Empty; break;
|
||||
}
|
||||
}
|
||||
@@ -425,7 +432,7 @@ public partial class Vmodel : Entity
|
||||
{
|
||||
return selProps.Where(a => a.navType != eNavigateType.OneToMany && a.navType != eNavigateType.ManyToMany).Select(a => new SelectModel
|
||||
{
|
||||
FiledName = (a.navCode == VmSelectProp.MAIN_ALIES ? "" : a.navCode + ".") + a.field,
|
||||
FiledName = a.navCode + "." + a.field,
|
||||
AsName = (a.navCode == VmSelectProp.MAIN_ALIES ? "" : a.navCode + "_") + a.code
|
||||
}).ToList();
|
||||
}
|
||||
@@ -503,6 +510,4 @@ public partial class Vmodel : Entity
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using SqlSugar;
|
||||
using Tnb.Core;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace Tnb.Vengine.Domain;
|
||||
@@ -20,6 +19,7 @@ public partial class VmodelLink : Entity
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string id { get; set; } = YitIdHelper.NextId().ToString();
|
||||
|
||||
/// <summary>
|
||||
/// 数据库连接
|
||||
/// </summary>
|
||||
@@ -45,6 +45,4 @@ public partial class VmodelLink : Entity
|
||||
{
|
||||
return new object[] { id };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@
|
||||
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SqlSugar;
|
||||
using Tnb.Core;
|
||||
using Yitter.IdGenerator;
|
||||
|
||||
namespace Tnb.Vengine.Domain;
|
||||
@@ -17,6 +16,7 @@ namespace Tnb.Vengine.Domain;
|
||||
public partial class VmodelPage : Entity
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// 主键标识
|
||||
/// </summary>
|
||||
@@ -102,6 +102,6 @@ public partial class VmodelPage : Entity
|
||||
{
|
||||
return new object[] { id };
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
}
|
||||
@@ -10,15 +10,15 @@ namespace Tnb.Vengine;
|
||||
|
||||
public class TypeAdapter
|
||||
{
|
||||
public static TypeAdapterConfig IgnoreNull { get; }
|
||||
static TypeAdapter()
|
||||
{
|
||||
TypeAdapterConfig.GlobalSettings.Default.PreserveReference(true);
|
||||
TypeAdapterConfig.GlobalSettings.NewConfig<JToken, JToken>().MapWith(json => json);
|
||||
TypeAdapterConfig.GlobalSettings.NewConfig<JObject, JObject>().MapWith(json => json);
|
||||
TypeAdapterConfig.GlobalSettings.NewConfig<JArray, JArray>().MapWith(json => json);
|
||||
IgnoreNull = TypeAdapterConfig.GlobalSettings.Clone();
|
||||
IgnoreNull.Default.IgnoreNullValues(true);
|
||||
}
|
||||
public static TypeAdapterConfig IgnoreNull { get; }
|
||||
|
||||
}
|
||||
static TypeAdapter()
|
||||
{
|
||||
TypeAdapterConfig.GlobalSettings.Default.PreserveReference(true);
|
||||
TypeAdapterConfig.GlobalSettings.NewConfig<JToken, JToken>().MapWith(json => json);
|
||||
TypeAdapterConfig.GlobalSettings.NewConfig<JObject, JObject>().MapWith(json => json);
|
||||
TypeAdapterConfig.GlobalSettings.NewConfig<JArray, JArray>().MapWith(json => json);
|
||||
IgnoreNull = TypeAdapterConfig.GlobalSettings.Clone();
|
||||
IgnoreNull.Default.IgnoreNullValues(true);
|
||||
}
|
||||
}
|
||||
@@ -13,41 +13,41 @@ namespace Tnb.Vengine;
|
||||
|
||||
public class VmodelMapper : IRegister
|
||||
{
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.ForType<VmGetInput, VmQueryInput>()
|
||||
.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>()
|
||||
.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())
|
||||
.Map(dest => dest.name, src => src.ColumnDescription)
|
||||
.Map(dest => dest.field, src => src.DbColumnName)
|
||||
.Map(dest => dest.dataType, src => src.DataType)
|
||||
//.Map(dest => dest.csType, src => src.DbColumnName)
|
||||
//.Map(dest => dest.propType, src => ePropType.DbTable)
|
||||
.Map(dest => dest.length, src => src.Length)
|
||||
.Map(dest => dest.digit, src => src.DecimalDigits)
|
||||
//.Map(dest => dest.ordinal, src => src.i)
|
||||
.Map(dest => dest.required, src => !src.IsNullable)
|
||||
.Map(dest => dest.pkey, src => src.IsPrimarykey)
|
||||
public void Register(TypeAdapterConfig config)
|
||||
{
|
||||
config.ForType<VmGetInput, VmQueryInput>()
|
||||
.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>()
|
||||
.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())
|
||||
.Map(dest => dest.name, src => src.ColumnDescription)
|
||||
.Map(dest => dest.field, src => src.DbColumnName)
|
||||
.Map(dest => dest.dataType, src => src.DataType)
|
||||
//.Map(dest => dest.csType, src => src.DbColumnName)
|
||||
//.Map(dest => dest.propType, src => ePropType.DbTable)
|
||||
.Map(dest => dest.length, src => src.Length)
|
||||
.Map(dest => dest.digit, src => src.DecimalDigits)
|
||||
//.Map(dest => dest.ordinal, src => src.i)
|
||||
.Map(dest => dest.required, src => !src.IsNullable)
|
||||
.Map(dest => dest.pkey, src => src.IsPrimarykey)
|
||||
//.Map(dest => dest.descrip, src => src.DbColumnName)
|
||||
.Map(dest => dest.defValue, src => src.DefaultValue);
|
||||
config.ForType<SugarColumn, VmDbProp>()
|
||||
//.Map(dest => dest.code, src => src.DbColumnName.SnakeToCamelCase(false))
|
||||
.Map(dest => dest.name, src => src.ColumnDescription)
|
||||
.Map(dest => dest.field, src => src.ColumnName)
|
||||
.Map(dest => dest.dataType, src => src.ColumnDataType)
|
||||
//.Map(dest => dest.csType, src => src.DbColumnName)
|
||||
//.Map(dest => dest.propType, src => ePropType.DbTable)
|
||||
.Map(dest => dest.length, src => src.Length)
|
||||
.Map(dest => dest.digit, src => src.DecimalDigits)
|
||||
//.Map(dest => dest.ordinal, src => src.i)
|
||||
.Map(dest => dest.required, src => !src.IsNullable)
|
||||
.Map(dest => dest.pkey, src => src.IsPrimaryKey);
|
||||
//.Map(dest => dest.descrip, src => src.DbColumnName)
|
||||
.Map(dest => dest.defValue, src => src.DefaultValue);
|
||||
config.ForType<SugarColumn, VmDbProp>()
|
||||
//.Map(dest => dest.code, src => src.DbColumnName.SnakeToCamelCase(false))
|
||||
.Map(dest => dest.name, src => src.ColumnDescription)
|
||||
.Map(dest => dest.field, src => src.ColumnName)
|
||||
.Map(dest => dest.dataType, src => src.ColumnDataType)
|
||||
//.Map(dest => dest.csType, src => src.DbColumnName)
|
||||
//.Map(dest => dest.propType, src => ePropType.DbTable)
|
||||
.Map(dest => dest.length, src => src.Length)
|
||||
.Map(dest => dest.digit, src => src.DecimalDigits)
|
||||
//.Map(dest => dest.ordinal, src => src.i)
|
||||
.Map(dest => dest.required, src => !src.IsNullable)
|
||||
.Map(dest => dest.pkey, src => src.IsPrimaryKey);
|
||||
//.Map(dest => dest.descrip, src => src.DbColumnName)
|
||||
//.Map(dest => dest.defValue, src => src.DefaultValue);
|
||||
}
|
||||
}
|
||||
//.Map(dest => dest.defValue, src => src.DefaultValue);
|
||||
}
|
||||
}
|
||||
@@ -6,13 +6,15 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Extension\**" />
|
||||
<EmbeddedResource Remove="Extension\**" />
|
||||
<None Remove="Extension\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\common\Tnb.Common.Core\Tnb.Common.Core.csproj" />
|
||||
<ProjectReference Include="..\..\common\Tnb.Common\Tnb.Common.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Extension\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user