Added: Alembic for migrations
Moving from Pyramid to FastAPI
This commit is contained in:
@ -9,7 +9,7 @@ const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
|
||||
const url = '/v1/products';
|
||||
const url = '/api/products';
|
||||
const serviceName = 'ProductService';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@ -19,7 +19,7 @@ export class ProductService {
|
||||
}
|
||||
|
||||
get(id: string): Observable<Product> {
|
||||
const getUrl: string = (id === null) ? `${url}/new` : `${url}/${id}`;
|
||||
const getUrl: string = (id === null) ? `${url}` : `${url}/${id}`;
|
||||
return <Observable<Product>>this.http.get<Product>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
@ -27,23 +27,22 @@ export class ProductService {
|
||||
}
|
||||
|
||||
list(): Observable<Product[]> {
|
||||
const options = {params: new HttpParams().set('l', '')};
|
||||
return <Observable<Product[]>>this.http.get<Product[]>(url, options)
|
||||
return <Observable<Product[]>>this.http.get<Product[]>(`${url}/list`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
}
|
||||
|
||||
listIsActiveOfCategory(id: string): Observable<Product[]> {
|
||||
const options = {params: new HttpParams().set('mc', id).set('a', '')};
|
||||
return <Observable<Product[]>>this.http.get<Product[]>(url, options)
|
||||
const options = {params: new HttpParams().set('mc', id).set('a', 'true')};
|
||||
return <Observable<Product[]>>this.http.get<Product[]>(`${url}/query`, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'listIsActiveOfCategory'))
|
||||
);
|
||||
}
|
||||
|
||||
save(product: Product): Observable<Product> {
|
||||
return <Observable<Product>>this.http.post<Product>(`${url}/new`, product, httpOptions)
|
||||
return <Observable<Product>>this.http.post<Product>(`${url}`, product, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
@ -56,8 +55,8 @@ export class ProductService {
|
||||
);
|
||||
}
|
||||
|
||||
updateSortOrder(list: Product[]): Observable<boolean> {
|
||||
return <Observable<boolean>>this.http.post<Product[]>(url, list, httpOptions)
|
||||
updateSortOrder(list: Product[]): Observable<Product[]> {
|
||||
return <Observable<Product[]>>this.http.post<Product[]>(`${url}/list`, list, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'updateSortOrder'))
|
||||
);
|
||||
@ -78,17 +77,9 @@ export class ProductService {
|
||||
);
|
||||
}
|
||||
|
||||
autocomplete(term: string): Observable<Product[]> {
|
||||
const options = {params: new HttpParams().set('t', term)};
|
||||
return <Observable<Product[]>>this.http.get<Product[]>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'autocomplete'))
|
||||
);
|
||||
}
|
||||
|
||||
balance(id: string, date: string): Observable<number> {
|
||||
const options = {params: new HttpParams().set('b', 'true').set('d', date)};
|
||||
return <Observable<number>>this.http.get<number>(`${url}/${id}`, options)
|
||||
const options = {params: new HttpParams().set('d', date)};
|
||||
return <Observable<number>>this.http.get<number>(`${url}/balance`, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'balance'))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user