2026-04-09 23:12:51 +08:00
|
|
|
using Furion.HttpRemote;
|
2026-04-10 22:39:32 +08:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2025-12-17 10:32:52 +08:00
|
|
|
|
2025-12-17 11:12:13 +08:00
|
|
|
namespace YD_Event.Application;
|
2025-12-17 10:32:52 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 第三方API调用
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ApiService : IScoped
|
|
|
|
|
{
|
2026-04-10 22:39:32 +08:00
|
|
|
private readonly string _baseUrl;
|
|
|
|
|
|
|
|
|
|
public ApiService(IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
_baseUrl = configuration["ExternalApi:BaseUrl"] ?? "https://api.wer.plus";
|
|
|
|
|
}
|
2025-12-17 10:32:52 +08:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 检查 文本内容是否包含违禁词
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="content">内容</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<bool> Keywords([FromQuery] string content)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var httpRemoteService = App.GetRequiredService<IHttpRemoteService>();
|
2026-04-10 22:39:32 +08:00
|
|
|
var dto = await httpRemoteService.GetAsAsync<KeywordsResponseDto>($"{_baseUrl}/api/min");
|
2025-12-17 10:32:52 +08:00
|
|
|
return dto.Success && dto.Num > 0;
|
|
|
|
|
|
|
|
|
|
}
|
2026-04-09 23:12:51 +08:00
|
|
|
catch (Exception)
|
2025-12-17 10:32:52 +08:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|