From d8a9562ffa1d72c5ffd8e1c0fc3b247f086fb9b4 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 18 Jul 2024 08:40:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=85=B6=E4=BB=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/ErpBdMaterial.cs | 22 +++++ .../Extensions/ConfigureSqlSugarExtensions.cs | 20 +++++ .../Options/ConnectionStringsOptions.cs | 2 + system/Tnb.Systems/Common/TestService.cs | 84 ++++++++++++++++++- 4 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpBdMaterial.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpBdMaterial.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpBdMaterial.cs new file mode 100644 index 00000000..04eb9407 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/ErpBdMaterial.cs @@ -0,0 +1,22 @@ +using JNPF.Common.Contracts; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities.Entity +{ + [SugarTable("ERP_BD_MATERIAL")] + public class ErpBdMaterial: BaseEntity + { + public string CODE { get; set; } + public string PK_ORG { get; set; } + public string NAME { get; set; } + public string MATERIALSPEC { get; set; } + public string MATERIALTYPE { get; set; } + public string PK_MEASDOC { get; set; } + public string MEASRATE { get; set; } + public string FMEASDOC { get; set; } + public string VID { get; set; } + public string MEANAME { get; set; } + public string FMEANAME { get; set; } + public string AID { get; set; } + } +} \ No newline at end of file diff --git a/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs b/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs index 2204c17e..77a29dcf 100644 --- a/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs +++ b/apihost/Tnb.API.Entry/Extensions/ConfigureSqlSugarExtensions.cs @@ -33,6 +33,26 @@ public static class ConfigureSqlSugarExtensions }, }); + foreach (var item in conn.ConfigList) + { + connectConfigList.Add(new ConnectionConfig + { + ConnectionString = item.connectionStr, + DbType = item.dbType, + IsAutoCloseConnection = true, + ConfigId = item.ServiceName, + InitKeyType = InitKeyType.Attribute, + MoreSettings = new ConnMoreSettings() + { + IsAutoRemoveDataCache = true, // 自动清理缓存 + IsAutoToUpper = false, + //PgSqlIsAutoToLower = false, + DisableNvarchar = true + }, + }); + + } + services.AddSqlSugar(connectConfigList, client => { //connectConfigList.ForEach(config => diff --git a/common/Tnb.SqlSugar/Options/ConnectionStringsOptions.cs b/common/Tnb.SqlSugar/Options/ConnectionStringsOptions.cs index 90bba155..233fb5e8 100644 --- a/common/Tnb.SqlSugar/Options/ConnectionStringsOptions.cs +++ b/common/Tnb.SqlSugar/Options/ConnectionStringsOptions.cs @@ -48,4 +48,6 @@ public sealed class ConnectionStringsOptions : IConfigurableOptions public string DefaultConnection { get; set; } public string ConnectString { get { return string.Format(DefaultConnection, Host, Port, DBName, UserName, Password); } } + + public List ConfigList { get; set; } } \ No newline at end of file diff --git a/system/Tnb.Systems/Common/TestService.cs b/system/Tnb.Systems/Common/TestService.cs index 048e0cb9..f5efec4a 100644 --- a/system/Tnb.Systems/Common/TestService.cs +++ b/system/Tnb.Systems/Common/TestService.cs @@ -11,6 +11,7 @@ using JNPF.Systems.Entitys.Permission; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using Npgsql.TypeHandlers; using SqlSugar; using Tnb.ProductionMgr.Entities.Entity; @@ -93,7 +94,9 @@ public class TestService : IDynamicApiController, ITransient [AllowAnonymous] public string test1() { - return "测试成功"; + var mysqlDb = _sugar.GetConnection("erpdb"); + List list = mysqlDb.Queryable().ToList(); + return JsonConvert.SerializeObject(list); } [HttpGet] @@ -150,4 +153,83 @@ public class TestService : IDynamicApiController, ITransient public string name { get; set; } } + [SugarTable("bas_factory_config")] + public partial class BasFactoryConfig2 : BaseEntity + { + public BasFactoryConfig2() + { + id = SnowflakeIdHelper.NextId(); + } + + /// + /// 名称 + /// + public string name { get; set; } = string.Empty; + + /// + /// key + /// + public string code { get; set; } = string.Empty; + + /// + /// 值 + /// + public string value { get; set; } = string.Empty; + + /// + /// 是否启用 + /// + public int enabled { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 排序 + /// + public long? ordinal { get; set; } + + /// + /// 是否系统 + /// + public int? is_system { get; set; } + + /// + /// 流程任务Id + /// + public string? f_flowtaskid { get; set; } + + /// + /// 流程引擎Id + /// + public string? f_flowid { get; set; } + } + }