Remove template model and related functionality (prisma/postgresql-schema.prisma, src/api/services/template.service.ts)

This commit removes the Template model, including its related functionality, from the project. The template table has been removed from the database schema, and all related functions and methods in the template service have been deleted. This change was made because the project now uses the persistence of the meta, eliminating the need for a separate template model.

Please note that this change may affect other parts of the application that rely on the Template model. Ensure that all necessary adjustments have been made before merging this commit.
This commit is contained in:
Davidson Gomes
2024-07-12 13:25:59 -03:00
parent ca3dadfb35
commit c782305456
3 changed files with 15 additions and 31 deletions

View File

@@ -1,4 +1,3 @@
import { Template } from '@prisma/client';
import axios from 'axios';
import { ConfigService, WaBusiness } from '../../config/env.config';
@@ -39,7 +38,7 @@ export class TemplateService {
return response.data;
}
public async create(instance: InstanceDto, data: TemplateDto): Promise<Template> {
public async create(instance: InstanceDto, data: TemplateDto) {
try {
const getInstance = await this.waMonitor.waInstances[instance.instanceName].instance;
@@ -61,21 +60,10 @@ export class TemplateService {
const response = await this.requestTemplate(postData, 'POST');
if (!response) {
throw new Error('Error to create template');
return response;
}
console.log(response);
const template = await this.prismaRepository.template.create({
data: {
instanceId: getInstance.id,
templateId: response.id,
name: data.name,
language: data.language,
},
});
return template;
return response;
} catch (error) {
this.logger.error(error);
throw new Error('Error to create template');
@@ -94,13 +82,10 @@ export class TemplateService {
} else if (method === 'POST') {
const result = await axios.post(urlServer, data, { headers });
return result.data;
} else if (method === 'DELETE') {
const result = await axios.delete(urlServer + '/' + data, { headers });
return result.data;
}
} catch (e) {
this.logger.error(e.response.data);
return null;
return e.response.data.error;
}
}
}