deploy: auto commit repo-root changes 2026-07-05 12:33:57

This commit is contained in:
hajimi
2026-07-05 12:33:57 +08:00
parent 1954948445
commit f641276b9d
123 changed files with 1182 additions and 572 deletions
@@ -12,6 +12,7 @@ use app\common\model\user\User;
use app\common\model\ai\AiAnalysis;
use app\common\enum\user\AccountLogEnum;
use app\common\logic\AccountLogLogic;
use app\common\service\ai\AiAnalysisRequestService;
use app\common\service\ai\AiService;
use app\common\service\ai\KbSyncService;
use app\common\service\chat\PrivateChatService;
@@ -585,56 +586,20 @@ class CommunityController extends BaseApiController
public function aiAnalysis()
{
try {
$postId = $this->request->get('post_id/d', 0);
if ($postId <= 0) {
return $this->fail('参数缺失');
}
$result = AiAnalysisRequestService::analyzePost(
$this->request->get('post_id/d', 0),
$this->userId,
$this->request->get('force/d', 0) === 1
);
$post = CommunityPost::where('id', $postId)->where('status', 1)->findOrEmpty();
if ($post->isEmpty()) {
return $this->fail('帖子不存在');
}
$data = $post->toArray();
$ext = is_array($data['ext'] ?? null) ? $data['ext'] : (json_decode((string) ($data['ext'] ?? ''), true) ?: []);
$tags = $this->getPostTags($postId);
$isTrumpPost = $this->isTrumpPost($tags);
$isLiuhePost = $this->isLiuhePost($tags, $ext);
if ($isTrumpPost) {
return $this->fail('特朗普帖子仅支持翻译');
}
if (!$isLiuhePost) {
return $this->fail('该帖子类型无需AI分析');
}
$analysis = $this->ensureLiuheAnalysisContent($post, $ext);
if (!$analysis['success']) {
return $this->fail($analysis['error'] ?? '图片分析失败');
}
$ext = $analysis['ext'];
$data['tags'] = array_values($tags);
$data['ext'] = $ext;
if (!empty($ext['translated_content'])) {
$data['translated_content'] = (string) $ext['translated_content'];
}
if (!empty($ext['lottery_analysis_content'])) {
$data['lottery_analysis_content'] = (string) $ext['lottery_analysis_content'];
}
$force = $this->request->get('force/d', 0) === 1;
$result = AiService::analyzePost($postId, $data, $this->userId, true, $force);
if (!$result['success']) {
return $this->fail($result['error'] ?? 'AI分析失败');
}
return $this->data([
'analysis' => $result['data'],
'from_cache' => $result['from_cache'] ?? false,
if (empty($result['success'])) {
return $this->fail($result['error'] ?? 'AI分析失败', [
'remain_count' => $result['remain_count'] ?? null,
]);
} catch (\Throwable $e) {
return $this->fail('AI分析异常: ' . $e->getMessage());
}
unset($result['success'], $result['error'], $result['code']);
return $this->data($result);
}
public function aiAnalysisResult()