debug: 添加DouyinAuthClient依赖注入调试信息和错误处理

- 在DouyinContentAdapter构造函数中添加调试日志
- 在getAccessToken方法中添加详细的错误检查和处理
- 将DouyinAuthClient添加到module的exports中
- 提供更详细的错误信息帮助诊断注入问题
This commit is contained in:
imeepos 2025-09-08 14:14:44 +08:00
parent dfa2d5eaae
commit d3562b4d36
2 changed files with 19 additions and 1 deletions

View File

@ -36,6 +36,13 @@ export class DouyinContentAdapter extends BaseContentAdapter {
) {
super(httpService, configService, auditLogRepository);
// 调试:检查 douyinAuthClient 是否正确注入
console.log('DouyinContentAdapter constructor - douyinAuthClient:', this.douyinAuthClient);
console.log('douyinAuthClient type:', typeof this.douyinAuthClient);
if (this.douyinAuthClient) {
console.log('douyinAuthClient.getAccessToken type:', typeof this.douyinAuthClient.getAccessToken);
}
// 抖音开放平台配置clientKey/clientSecret 实际使用的是 APP_ID/APP_SECRET
this.douyinConfig = {
clientKey: this.configService.get('BYTEDANCE_APP_ID') || '',
@ -157,6 +164,17 @@ export class DouyinContentAdapter extends BaseContentAdapter {
* 访
*/
private async getAccessToken(): Promise<string> {
console.log('getAccessToken called - douyinAuthClient:', this.douyinAuthClient);
console.log('douyinAuthClient type:', typeof this.douyinAuthClient);
if (!this.douyinAuthClient) {
throw new Error('DouyinAuthClient 未正确注入');
}
if (typeof this.douyinAuthClient.getAccessToken !== 'function') {
throw new Error(`DouyinAuthClient.getAccessToken 不是函数,类型: ${typeof this.douyinAuthClient.getAccessToken}`);
}
return this.douyinAuthClient.getAccessToken().then(res => res.accessToken)
}

View File

@ -51,6 +51,6 @@ import { ContentAuditGuard } from './guards/content-audit.guard';
ContentAuditGuard,
],
controllers: [ContentModerationController],
exports: [UnifiedContentService, ContentAdapterFactory, ContentAuditGuard],
exports: [UnifiedContentService, ContentAdapterFactory, ContentAuditGuard, DouyinAuthClient],
})
export class ContentModerationModule {}