skailan-conversations
Version:
Servicio de conversaciones y mensajería para Skailan
18 lines • 686 B
JavaScript
import { Tag } from '../../domain/entities/Tag';
import { v4 as uuidv4 } from 'uuid';
export class CreateTag {
tagRepository;
constructor(tagRepository) {
this.tagRepository = tagRepository;
}
async execute(request) {
const { organizationId, name } = request;
const existingTag = await this.tagRepository.findByName(name, organizationId);
if (existingTag) {
throw new Error('Tag with this name already exists for this organization.');
}
const newTag = new Tag(uuidv4(), organizationId, name, new Date(), new Date());
return this.tagRepository.save(newTag);
}
}
//# sourceMappingURL=CreateTag.js.map