import { IHelpCenterAuthor } from '@gauzy/contracts' ; import { CommandHandler , ICommandHandler } from '@nestjs/cqrs' ; import { ArticleAuthorsBulkCreateCommand } from '..' ; import { HelpCenterAuthorService } from '../../help-center-author.service' ; @ CommandHandler ( ArticleAuthorsBulkCreateCommand ) export class ArticleAuthorsBulkCreateHandler implements ICommandHandler < ArticleAuthorsBulkCreateCommand > { constructor ( private readonly helpCenterAuthorService ) { } public async execute ( command ) { const { input } = command ; const { articleId , employeeIds , organizationId , tenantId } = input ; let author ; const createInput = [ ] ; for ( const employeeId of employeeIds ) { author = { articleId : articleId , employeeId : employeeId , organizationId , tenantId } ; createInput . push ( author ) ; } return await this . helpCenterAuthorService . createBulk ( createInput ) ; } }