修改 平台类型 存放位置

This commit is contained in:
chfei committed 2026-11-13 19:20:32 +08:00
1 parent b18aad1f85
commit 9bc35bb2d6
11 files changed
+961 -39

No files matched your search

@@ -10,6 +10,7 @@ using Store.Modules.CloudProduct.Entities;
using Store.Modules.CloudProduct.ImportConverters;
using Store.Modules.CloudProduct.Services;
using System.Text.Json.Nodes;
using Microsoft.Extensions.Logging;
namespace Store.Modules.CloudProduct.Controllers
{
@@ -23,10 +24,12 @@ namespace Store.Modules.CloudProduct.Controllers
private readonly IRawDataStorage _rawDataStorage;
private readonly GoodsIndexJob _goodsIndexJob;
private readonly GoodsViolationService _violations;
private readonly ILogger<GoodsController> _logger;
public GoodsController(IGoodsService goodsService, IOpenSearchService searchService, IRawDataStorage rawDataStorage, GoodsIndexJob goodsIndexJob, GoodsViolationService violations)
public GoodsController(IGoodsService goodsService, IOpenSearchService searchService, IRawDataStorage rawDataStorage, GoodsIndexJob goodsIndexJob, GoodsViolationService violations, ILogger<GoodsController> logger)
{
_violations = violations;
_logger = logger;
_goodsService = goodsService;
_searchService = searchService;
_rawDataStorage = rawDataStorage;
@@ -96,7 +99,7 @@ namespace Store.Modules.CloudProduct.Controllers
int batchCount;
do
{
batchCount = await _goodsService.IndexPendingGoodsAsync(1000);
batchCount = await _goodsService.IndexPendingGoodsAsync(20000);
count += batchCount;
} while (batchCount > 0);
@@ -260,6 +263,35 @@ namespace Store.Modules.CloudProduct.Controllers
});
}
[HttpPost]
[Route("/api/wx/data/import")]
[EndpointSummary("导入商品数据")]
public async Task<GoodsImportResult> ImportWXData([FromBody] string data)
{
try
{
if (string.IsNullOrEmpty(data))
{
throw new ArgumentNullException(nameof(data));
}
var content = data;
var goods = GoodsConverterFactory.ConvertContent(content);
if (goods == null)
{
throw new AppException("未找到匹配的转换器,无法解析测试数据");
}
return await _goodsService.ImportGoodsAsync(new[]
{
new GoodsImportItem { Goods = goods, RawData = content }
});
}
catch (Exception ex)
{
_logger.LogError(ex, "导入微信数据:");
throw new AppException("导入微信数据失败");
}
}
/// <summary>
/// 导入接口:接收客户端批量上传的 JSON 文件,解析后入库并写入分词索引。
/// </summary>
@@ -398,7 +430,7 @@ namespace Store.Modules.CloudProduct.Controllers
var node = JsonNode.Parse(raw);
return node ?? throw new AppException("商品详情解析失败", ResultCode.BusinessError);
}
catch(Exception ex)
catch (Exception ex)
{
throw new AppException(ex.Message);
}