云数据模块修改
This commit is contained in:
1 parent
707eb5664a
commit
2f406c840f
6 files changed
+28
-5
No files matched your search
@@ -9,7 +9,6 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Store.Modules.CloudProduct.Services;
|
using Store.Modules.CloudProduct.Services;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
|
|
||||||
namespace Store.Modules.CloudProduct
|
namespace Store.Modules.CloudProduct
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,12 +19,14 @@ namespace Store.Modules.CloudProduct.Controllers
|
|||||||
private readonly IGoodsService _goodsService;
|
private readonly IGoodsService _goodsService;
|
||||||
private readonly IOpenSearchService _searchService;
|
private readonly IOpenSearchService _searchService;
|
||||||
private readonly IRawDataStorage _rawDataStorage;
|
private readonly IRawDataStorage _rawDataStorage;
|
||||||
|
private readonly GoodsIndexJob _goodsIndexJob;
|
||||||
|
|
||||||
public GoodsController(IGoodsService goodsService, IOpenSearchService searchService, IRawDataStorage rawDataStorage)
|
public GoodsController(IGoodsService goodsService, IOpenSearchService searchService, IRawDataStorage rawDataStorage, GoodsIndexJob goodsIndexJob)
|
||||||
{
|
{
|
||||||
_goodsService = goodsService;
|
_goodsService = goodsService;
|
||||||
_searchService = searchService;
|
_searchService = searchService;
|
||||||
_rawDataStorage = rawDataStorage;
|
_rawDataStorage = rawDataStorage;
|
||||||
|
_goodsIndexJob = goodsIndexJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
@@ -32,7 +34,11 @@ namespace Store.Modules.CloudProduct.Controllers
|
|||||||
{
|
{
|
||||||
return DateTime.Now.ToLongDateString();
|
return DateTime.Now.ToLongDateString();
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public async Task Job()
|
||||||
|
{
|
||||||
|
await _goodsIndexJob.ProcessPendingAsync();
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 搜索
|
/// 搜索
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using FreeSql;
|
using FreeSql;
|
||||||
using MAX.Core.DependencyInjection;
|
using MAX.Core.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Store.Modules.CloudProduct.Entities;
|
using Store.Modules.CloudProduct.Entities;
|
||||||
|
|
||||||
namespace Store.Modules.CloudProduct.Repositorys
|
namespace Store.Modules.CloudProduct.Repositorys
|
||||||
@@ -9,7 +10,7 @@ namespace Store.Modules.CloudProduct.Repositorys
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class GoodsRepository : BaseRepository<GoodsEntity>, IScopedDependency
|
public class GoodsRepository : BaseRepository<GoodsEntity>, IScopedDependency
|
||||||
{
|
{
|
||||||
public GoodsRepository(IFreeSql fsql) : base(fsql)
|
public GoodsRepository([FromKeyedServices("CloudProductConnection")] IFreeSql fsql) : base(fsql)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,23 @@ namespace Store.Modules.CloudProduct
|
|||||||
|
|
||||||
public void Register(IServiceRegistrar registrar)
|
public void Register(IServiceRegistrar registrar)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Func<IServiceProvider, IFreeSql> KJDFsqlFactory = r =>
|
||||||
|
{
|
||||||
|
var config = r.GetRequiredService<IConfiguration>();
|
||||||
|
var connection = config.GetValue<string>("CloudProductConnection");
|
||||||
|
IFreeSql fsql = new FreeSql.FreeSqlBuilder()
|
||||||
|
.UseConnectionString(FreeSql.DataType.MySql, connection)
|
||||||
|
.UseAdoConnectionPool(true)
|
||||||
|
.Build();
|
||||||
|
return fsql;
|
||||||
|
};
|
||||||
|
registrar.RegisterSingleton<IFreeSql>("CloudProductConnection", (s, k) =>
|
||||||
|
{
|
||||||
|
return KJDFsqlFactory(s);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Start(IServiceProvider serviceProvider)
|
public async void Start(IServiceProvider serviceProvider)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net10.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
|
"CloudProductConnection": "Server=192.168.0.200;Port=3306;Database=goods_center;Uid=root;Pwd=123456;Allow User Variables=true",
|
||||||
"Search": {
|
"Search": {
|
||||||
"Url": "http://192.168.0.200:9200",
|
"Url": "http://192.168.0.200:9200",
|
||||||
"IndexName": "goods_search"
|
"IndexName": "goods_search"
|
||||||
|
|||||||
Reference in new issue
Block a user