添加其他数据库
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.ProductionMgr.Entities.Entity
|
||||
{
|
||||
[SugarTable("ERP_BD_MATERIAL")]
|
||||
public class ErpBdMaterial: BaseEntity<string>
|
||||
{
|
||||
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; }
|
||||
}
|
||||
}
|
||||
@@ -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 =>
|
||||
|
||||
@@ -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<DBConnectionConfig> ConfigList { get; set; }
|
||||
}
|
||||
@@ -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<ErpBdMaterial> list = mysqlDb.Queryable<ErpBdMaterial>().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<string>
|
||||
{
|
||||
public BasFactoryConfig2()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// key
|
||||
/// </summary>
|
||||
public string code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public string value { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public int enabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public long? ordinal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否系统
|
||||
/// </summary>
|
||||
public int? is_system { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程任务Id
|
||||
/// </summary>
|
||||
public string? f_flowtaskid { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 流程引擎Id
|
||||
/// </summary>
|
||||
public string? f_flowid { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user