mirror of
https://github.com/dadosfera/maestro.git
synced 2026-11-12 23:49:09 +00:00
REFACTOR: Add Auth Validators
This commit is contained in:
@@ -5,73 +5,66 @@ import { trSnakeToCamel } from 'src/utils/CaseConverter';
|
||||
|
||||
@Injectable()
|
||||
export class TransformationsService {
|
||||
constructor(private transformationClient: TransformationsClientService) {}
|
||||
|
||||
constructor( private transformationClient: TransformationsClientService){}
|
||||
async create(createTransformationDto: ICreateTransformationsRequest) {
|
||||
try {
|
||||
const convertedDTO = createTransformationDto.transformations.map((tr) => {
|
||||
return trSnakeToCamel(tr);
|
||||
});
|
||||
|
||||
async create(createTransformationDto:ICreateTransformationsRequest){
|
||||
try{
|
||||
const createTransformationResponse =
|
||||
await this.transformationClient.create({
|
||||
transformations: convertedDTO,
|
||||
});
|
||||
|
||||
let convertedDTO = createTransformationDto.transformations.map((tr)=>{
|
||||
|
||||
return trSnakeToCamel(tr)
|
||||
})
|
||||
|
||||
const createTransformationResponse = await this.transformationClient.create({transformations:convertedDTO});
|
||||
|
||||
return createTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findOne(id:string){
|
||||
|
||||
try{
|
||||
const findOneTransformationResponse = await this.transformationClient.findOne({id});
|
||||
return findOneTransformationResponse
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async findAll(){
|
||||
|
||||
try{
|
||||
const findAllTransformationResponse = await this.transformationClient.findAll();
|
||||
|
||||
return findAllTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return createTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async update(id:string, data){
|
||||
|
||||
try{
|
||||
data.transformation["id"] = id
|
||||
const updateTransformationResponse = await this.transformationClient.update({...data});
|
||||
|
||||
return updateTransformationResponse
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
async findOne(id: string) {
|
||||
try {
|
||||
const findOneTransformationResponse =
|
||||
await this.transformationClient.findOne({ id });
|
||||
return findOneTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id:string){
|
||||
async findAll() {
|
||||
try {
|
||||
const findAllTransformationResponse =
|
||||
await this.transformationClient.findAll();
|
||||
|
||||
try{
|
||||
return findAllTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
const removeTransformationResponse = await this.transformationClient.remove({id});
|
||||
|
||||
return removeTransformationResponse
|
||||
async update(id: string, data) {
|
||||
try {
|
||||
data.transformation['id'] = id;
|
||||
const updateTransformationResponse =
|
||||
await this.transformationClient.update({ ...data });
|
||||
|
||||
}catch(err){
|
||||
throw new HttpException(err.message,HttpStatus.NOT_FOUND)
|
||||
return updateTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
async remove(id: string) {
|
||||
try {
|
||||
const removeTransformationResponse =
|
||||
await this.transformationClient.remove({ id });
|
||||
|
||||
return removeTransformationResponse;
|
||||
} catch (err) {
|
||||
throw new HttpException(err.message, HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user