fix: 修复平台适配器依赖注入问题
- 为 WechatAdapter 和 BytedanceAdapter 添加完整的构造函数 - 正确注入 Repository, HttpService, ConfigService, JwtService 依赖 - 修复 UnknownDependenciesException 错误 - 确保适配器可以正常实例化和使用
This commit is contained in:
parent
b750aede6a
commit
546ccad21a
|
|
@ -16,9 +16,11 @@ import { AdWatchEntity } from './entities/ad-watch.entity';
|
||||||
import { N8nTemplateFactoryService } from './services/n8n-template-factory.service';
|
import { N8nTemplateFactoryService } from './services/n8n-template-factory.service';
|
||||||
import { TemplateController } from './controllers/template.controller';
|
import { TemplateController } from './controllers/template.controller';
|
||||||
import { PlatformModule } from './platform/platform.module';
|
import { PlatformModule } from './platform/platform.module';
|
||||||
|
import { HttpModule } from '@nestjs/axios';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
|
HttpModule,
|
||||||
ConfigModule.forRoot({
|
ConfigModule.forRoot({
|
||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
envFilePath: ['.env.local', '.env'],
|
envFilePath: ['.env.local', '.env'],
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
import { Injectable, BadRequestException } from '@nestjs/common';
|
import { Injectable, BadRequestException } from '@nestjs/common';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
import { HttpService } from '@nestjs/axios';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { BaseAdapter } from './base.adapter';
|
import { BaseAdapter } from './base.adapter';
|
||||||
import { PlatformType } from '../../entities/platform-user.entity';
|
import { UserEntity } from '../../entities/user.entity';
|
||||||
|
import { PlatformUserEntity, PlatformType } from '../../entities/platform-user.entity';
|
||||||
import {
|
import {
|
||||||
PlatformLoginData,
|
PlatformLoginData,
|
||||||
PlatformRegisterData,
|
PlatformRegisterData,
|
||||||
|
|
@ -25,6 +31,24 @@ interface BytedanceAuthResponse {
|
||||||
export class BytedanceAdapter extends BaseAdapter {
|
export class BytedanceAdapter extends BaseAdapter {
|
||||||
platform = PlatformType.BYTEDANCE;
|
platform = PlatformType.BYTEDANCE;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
httpService: HttpService,
|
||||||
|
configService: ConfigService,
|
||||||
|
@InjectRepository(UserEntity)
|
||||||
|
userRepository: Repository<UserEntity>,
|
||||||
|
@InjectRepository(PlatformUserEntity)
|
||||||
|
platformUserRepository: Repository<PlatformUserEntity>,
|
||||||
|
jwtService: JwtService,
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
httpService,
|
||||||
|
configService,
|
||||||
|
userRepository,
|
||||||
|
platformUserRepository,
|
||||||
|
jwtService,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private readonly bytedanceConfig = {
|
private readonly bytedanceConfig = {
|
||||||
appId: this.configService.get('BYTEDANCE_APP_ID'),
|
appId: this.configService.get('BYTEDANCE_APP_ID'),
|
||||||
appSecret: this.configService.get('BYTEDANCE_APP_SECRET'),
|
appSecret: this.configService.get('BYTEDANCE_APP_SECRET'),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
import { Injectable, BadRequestException } from '@nestjs/common';
|
import { Injectable, BadRequestException } from '@nestjs/common';
|
||||||
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
|
import { Repository } from 'typeorm';
|
||||||
|
import { HttpService } from '@nestjs/axios';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import { BaseAdapter } from './base.adapter';
|
import { BaseAdapter } from './base.adapter';
|
||||||
import { PlatformType } from '../../entities/platform-user.entity';
|
import { UserEntity } from '../../entities/user.entity';
|
||||||
|
import { PlatformUserEntity, PlatformType } from '../../entities/platform-user.entity';
|
||||||
import {
|
import {
|
||||||
PlatformLoginData,
|
PlatformLoginData,
|
||||||
PlatformRegisterData,
|
PlatformRegisterData,
|
||||||
|
|
@ -32,6 +38,24 @@ interface WechatUserInfo {
|
||||||
export class WechatAdapter extends BaseAdapter {
|
export class WechatAdapter extends BaseAdapter {
|
||||||
platform = PlatformType.WECHAT;
|
platform = PlatformType.WECHAT;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
httpService: HttpService,
|
||||||
|
configService: ConfigService,
|
||||||
|
@InjectRepository(UserEntity)
|
||||||
|
userRepository: Repository<UserEntity>,
|
||||||
|
@InjectRepository(PlatformUserEntity)
|
||||||
|
platformUserRepository: Repository<PlatformUserEntity>,
|
||||||
|
jwtService: JwtService,
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
httpService,
|
||||||
|
configService,
|
||||||
|
userRepository,
|
||||||
|
platformUserRepository,
|
||||||
|
jwtService,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private readonly wechatConfig = {
|
private readonly wechatConfig = {
|
||||||
appId: this.configService.get('WECHAT_APP_ID'),
|
appId: this.configService.get('WECHAT_APP_ID'),
|
||||||
appSecret: this.configService.get('WECHAT_APP_SECRET'),
|
appSecret: this.configService.get('WECHAT_APP_SECRET'),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue