debug: 添加DouyinAuthClient依赖注入调试信息和错误处理
- 在DouyinContentAdapter构造函数中添加调试日志 - 在getAccessToken方法中添加详细的错误检查和处理 - 将DouyinAuthClient添加到module的exports中 - 提供更详细的错误信息帮助诊断注入问题
This commit is contained in:
parent
dfa2d5eaae
commit
d3562b4d36
|
|
@ -36,6 +36,13 @@ export class DouyinContentAdapter extends BaseContentAdapter {
|
||||||
) {
|
) {
|
||||||
super(httpService, configService, auditLogRepository);
|
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
|
// 抖音开放平台配置:clientKey/clientSecret 实际使用的是 APP_ID/APP_SECRET
|
||||||
this.douyinConfig = {
|
this.douyinConfig = {
|
||||||
clientKey: this.configService.get('BYTEDANCE_APP_ID') || '',
|
clientKey: this.configService.get('BYTEDANCE_APP_ID') || '',
|
||||||
|
|
@ -157,6 +164,17 @@ export class DouyinContentAdapter extends BaseContentAdapter {
|
||||||
* 获取访问令牌
|
* 获取访问令牌
|
||||||
*/
|
*/
|
||||||
private async getAccessToken(): Promise<string> {
|
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)
|
return this.douyinAuthClient.getAccessToken().then(res => res.accessToken)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,6 @@ import { ContentAuditGuard } from './guards/content-audit.guard';
|
||||||
ContentAuditGuard,
|
ContentAuditGuard,
|
||||||
],
|
],
|
||||||
controllers: [ContentModerationController],
|
controllers: [ContentModerationController],
|
||||||
exports: [UnifiedContentService, ContentAdapterFactory, ContentAuditGuard],
|
exports: [UnifiedContentService, ContentAdapterFactory, ContentAuditGuard, DouyinAuthClient],
|
||||||
})
|
})
|
||||||
export class ContentModerationModule {}
|
export class ContentModerationModule {}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue