first commit
This commit is contained in:
61
templates/api.repository.impl.mustache
Normal file
61
templates/api.repository.impl.mustache
Normal file
@@ -0,0 +1,61 @@
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { environment } from '@environment';
|
||||
|
||||
import { MRepository } from '@mercadona/core/utils/repository';
|
||||
|
||||
import { {{classname}}Repository } from '../../../domain/repositories/{{classFilename}}.repository.contract';
|
||||
{{#imports}}
|
||||
import { {{classname}}Dto } from '@/dtos/{{classFilename}}/{{classFilename}}.dto';
|
||||
import { {{classname}} } from '@/entities/models/{{classFilename}}.model';
|
||||
import { {{classVarName}}Mapper } from '@/mappers/{{classFilename}}/{{classFilename}}.mapper';
|
||||
{{/imports}}
|
||||
|
||||
/**
|
||||
* {{classname}} Repository Implementation
|
||||
* Generated from OpenAPI tag: {{classname}}
|
||||
*/
|
||||
@Injectable()
|
||||
export class {{classname}}RepositoryImpl extends MRepository implements {{classname}}Repository {
|
||||
constructor() {
|
||||
super(`${environment.modapApi.url}`);
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
{{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{dataType}}{{^-last}}, {{/-last}}{{/allParams}}): Observable<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}void{{/returnType}}> {
|
||||
{{#isListContainer}}
|
||||
return this.{{httpMethod}}<{{returnBaseType}}Dto>('{{path}}'{{#hasQueryParams}}, {
|
||||
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
||||
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}})
|
||||
.pipe(
|
||||
map((response) => response.{{#vendorExtensions}}{{x-response-property}}{{/vendorExtensions}}{{^vendorExtensions}}items{{/vendorExtensions}}.map({{returnBaseType}}Mapper))
|
||||
);
|
||||
{{/isListContainer}}
|
||||
{{^isListContainer}}
|
||||
{{#returnType}}
|
||||
return this.{{httpMethod}}<{{returnType}}Dto>('{{path}}'{{#hasQueryParams}}, {
|
||||
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
||||
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}})
|
||||
.pipe(
|
||||
map({{returnType}}Mapper)
|
||||
);
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return this.{{httpMethod}}<void>('{{path}}'{{#hasQueryParams}}, {
|
||||
params: { {{#queryParams}}{{paramName}}{{^-last}}, {{/-last}}{{/queryParams}} }
|
||||
}{{/hasQueryParams}}{{#hasBodyParam}}, {{bodyParam}}{{/hasBodyParam}});
|
||||
{{/returnType}}
|
||||
{{/isListContainer}}
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
Reference in New Issue
Block a user