|
|
|
|
using Durkee.Mes.Api.Config;
|
|
|
|
|
using Durkee.Mes.Api.Model;
|
|
|
|
|
using Durkee.Mes.Api.Repository.service.Impl;
|
|
|
|
|
using Durkee.Mes.Api.Repository.service;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Configuration;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Durkee.Mes.Api.Repository
|
|
|
|
|
{
|
|
|
|
|
public static class SqlsugarSetup
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 注册SqlSugar
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="services"></param>
|
|
|
|
|
public static void AddSqlSugarSetup(this IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddSingleton<ISqlSugarClient>(x =>
|
|
|
|
|
{
|
|
|
|
|
var appConfig = x.GetService<AppConfig>();
|
|
|
|
|
SqlSugarScope Db = new SqlSugarScope(new List<ConnectionConfig>()
|
|
|
|
|
{
|
|
|
|
|
new ConnectionConfig()
|
|
|
|
|
{
|
|
|
|
|
ConfigId = "mes",
|
|
|
|
|
DbType = DbType.Oracle,
|
|
|
|
|
ConnectionString = appConfig.mesConnStr,
|
|
|
|
|
InitKeyType = InitKeyType.Attribute,
|
|
|
|
|
IsAutoCloseConnection = true,
|
|
|
|
|
},
|
|
|
|
|
new ConnectionConfig()
|
|
|
|
|
{
|
|
|
|
|
ConfigId = "mcs",
|
|
|
|
|
DbType = DbType.Oracle,
|
|
|
|
|
ConnectionString = appConfig.mcsConnStr,
|
|
|
|
|
InitKeyType = InitKeyType.Attribute,
|
|
|
|
|
IsAutoCloseConnection = true,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
db =>
|
|
|
|
|
{
|
|
|
|
|
db.Aop.OnLogExecuting = (sql, pars) => { };
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Db;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 注册Repository、Service服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="services"></param>
|
|
|
|
|
public static void AddServices(this IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddSingleton<Repository<BaseBomInfo>>();
|
|
|
|
|
services.AddSingleton<IBaseBomInfoService, BaseBomInfoServiceImpl>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|