云库增加 AI识图,缓存,我的云库收藏增加安全标志
调用外部API 扣费
This commit is contained in:
1 parent
7c29e57623
commit
150e8644b7
49 files changed
+1069
-28
No files matched your search
@@ -33,6 +33,9 @@ namespace Store.Modules.CloudProduct.Services
|
||||
/// <summary>批量写入收藏文档(存在则覆盖)</summary>
|
||||
Task IndexDocumentsAsync(IEnumerable<UserFavoritesSearchDocument> documents);
|
||||
|
||||
/// <summary>更新单条收藏的安全字段并等待对检索可见。</summary>
|
||||
Task UpdateSafetyAsync(string documentId, bool isSafe);
|
||||
|
||||
/// <summary>按文档Id批量删除收藏文档</summary>
|
||||
Task DeleteDocumentsAsync(IEnumerable<string> documentIds);
|
||||
|
||||
@@ -172,6 +175,7 @@ namespace Store.Modules.CloudProduct.Services
|
||||
)
|
||||
.Map<UserFavoritesSearchDocument>(m => m
|
||||
.Properties(p => p
|
||||
.Boolean(b => b.Name(x => x.IsSafe))
|
||||
.Keyword(k => k.Name(x => x.Id))
|
||||
.Number(n => n.Name(x => x.FavId).Type(NumberType.Long))
|
||||
.Keyword(k => k.Name(x => x.UserName))
|
||||
@@ -221,6 +225,14 @@ namespace Store.Modules.CloudProduct.Services
|
||||
return await CreateIndexAsync();
|
||||
}
|
||||
|
||||
public async Task UpdateSafetyAsync(string documentId, bool isSafe)
|
||||
{
|
||||
var response = await _client.UpdateAsync<UserFavoritesSearchDocument, object>(documentId, u => u
|
||||
.Index(_indexName).Doc(new { is_safe = isSafe }).Refresh(Refresh.WaitFor));
|
||||
if (!response.IsValid)
|
||||
throw new AppException("更新收藏安全状态索引失败: " + response.DebugInformation);
|
||||
}
|
||||
|
||||
private async Task RefreshIndexAsync()
|
||||
{
|
||||
var response = await _client.Indices.RefreshAsync(_indexName, d => d
|
||||
@@ -316,6 +328,9 @@ namespace Store.Modules.CloudProduct.Services
|
||||
throw new AppException("用户名不能为空", ResultCode.ValidationError);
|
||||
}
|
||||
|
||||
if (request.SafeStatus is < 0 or > 3)
|
||||
throw new AppException("状态必须为 0(全部)、1(安全)、2(违规)或 3(未检测)", ResultCode.ValidationError);
|
||||
|
||||
var keyword = request.Title;
|
||||
int? groupId = request.GroupId;
|
||||
var groupName = request.GroupName;
|
||||
@@ -341,6 +356,12 @@ namespace Store.Modules.CloudProduct.Services
|
||||
// 只检索当前用户自己的收藏 —— 放进 filters,避免被后面的 Filter 覆盖
|
||||
filters.Add(f => f.Term(t => t.Field(x => x.UserName).Value(request.UserName)));
|
||||
|
||||
// is_safe 为 null 或缺失时没有索引值,两者均表示暂无检测结论。
|
||||
if (request.SafeStatus is 1 or 2)
|
||||
filters.Add(f => f.Term(t => t.Field(x => x.IsSafe).Value(request.SafeStatus == 1)));
|
||||
else if (request.SafeStatus == 3)
|
||||
filters.Add(f => f.Bool(b => b.MustNot(q => q.Exists(e => e.Field(x => x.IsSafe)))));
|
||||
|
||||
if (groupId.HasValue)
|
||||
{
|
||||
filters.Add(f => f.Term(t => t.Field(x => x.GroupId).Value(groupId.Value)));
|
||||
|
||||
Reference in new issue
Block a user