云数据模块修改

This commit is contained in:
chfei committed 2026-09-24 16:41:48 +08:00
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 MySql.Data.MySqlClient;
using Store.Modules.CloudProduct.Services;
using Microsoft.Extensions.Configuration;
namespace Store.Modules.CloudProduct
{
@@ -19,12 +19,14 @@ namespace Store.Modules.CloudProduct.Controllers
private readonly IGoodsService _goodsService;
private readonly IOpenSearchService _searchService;
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;
_searchService = searchService;
_rawDataStorage = rawDataStorage;
_goodsIndexJob = goodsIndexJob;
}
[HttpGet]
@@ -32,7 +34,11 @@ namespace Store.Modules.CloudProduct.Controllers
{
return DateTime.Now.ToLongDateString();
}
[HttpGet]
public async Task Job()
{
await _goodsIndexJob.ProcessPendingAsync();
}
/// <summary>
/// 搜索
/// </summary>
@@ -1,5 +1,6 @@
using FreeSql;
using MAX.Core.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Store.Modules.CloudProduct.Entities;
namespace Store.Modules.CloudProduct.Repositorys
@@ -9,7 +10,7 @@ namespace Store.Modules.CloudProduct.Repositorys
/// </summary>
public class GoodsRepository : BaseRepository<GoodsEntity>, IScopedDependency
{
public GoodsRepository(IFreeSql fsql) : base(fsql)
public GoodsRepository([FromKeyedServices("CloudProductConnection")] IFreeSql fsql) : base(fsql)
{
}
}
+17
View File
@@ -19,6 +19,23 @@ namespace Store.Modules.CloudProduct
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)
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
+1
View File
@@ -1,4 +1,5 @@
{
"CloudProductConnection": "Server=192.168.0.200;Port=3306;Database=goods_center;Uid=root;Pwd=123456;Allow User Variables=true",
"Search": {
"Url": "http://192.168.0.200:9200",
"IndexName": "goods_search"