mirror of
https://github.com/dadosfera/maestro.git
synced 2026-10-17 04:09:08 +00:00
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
|
|
import { IIdRequest, Info } from 'src/clients/outputs/interfaces';
|
|
import { OutputsClientService } from 'src/clients/outputs/client.service';
|
|
|
|
@Injectable()
|
|
export class OutputsService {
|
|
constructor(private outputClient: OutputsClientService) {}
|
|
|
|
async create(createOutputDto) {
|
|
try {
|
|
const createOutputResponse = await this.outputClient.create(
|
|
createOutputDto,
|
|
);
|
|
|
|
return createOutputResponse;
|
|
} catch (err) {
|
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
}
|
|
}
|
|
|
|
async findOne(data: IIdRequest) {
|
|
try {
|
|
const findOneOutputResponse = await this.outputClient.findOne(data);
|
|
return findOneOutputResponse;
|
|
} catch (err) {
|
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
}
|
|
}
|
|
|
|
async findAll(data) {
|
|
try {
|
|
const findAllOutputResponse = await this.outputClient.findAll(data);
|
|
|
|
return findAllOutputResponse;
|
|
} catch (err) {
|
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
}
|
|
}
|
|
|
|
async update(id: string, data, info: Info) {
|
|
try {
|
|
const updateOutputResponse = await this.outputClient.update({
|
|
id,
|
|
info,
|
|
...data,
|
|
});
|
|
|
|
return updateOutputResponse;
|
|
} catch (err) {
|
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
}
|
|
}
|
|
|
|
async remove(data: IIdRequest) {
|
|
try {
|
|
const removeOutputResponse = await this.outputClient.remove(data);
|
|
|
|
return removeOutputResponse;
|
|
} catch (err) {
|
|
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
|
}
|
|
}
|
|
}
|