Fix: Username unique index was case sensitive and this allowed duplicate names.

Feature: Moved temporal products into their own module and reverted the products module
This commit is contained in:
2021-10-27 09:27:47 +05:30
parent debe0df7b7
commit 124cf4d9ff
40 changed files with 1522 additions and 313 deletions

View File

@ -0,0 +1,43 @@
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { catchError } from 'rxjs/operators';
import { ErrorLoggerService } from '../core/error-logger.service';
import { Product } from '../core/product';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
};
const url = '/api/temporal-products';
const serviceName = 'ProductService';
@Injectable({ providedIn: 'root' })
export class TemporalProductService {
constructor(private http: HttpClient, private log: ErrorLoggerService) {}
get(id: string): Observable<Product> {
return this.http
.get<Product>(`${url}/${id}`)
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Product>;
}
list(): Observable<Product[][]> {
return this.http
.get<Product[][]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Product[][]>;
}
update(product: Product): Observable<void> {
return this.http
.put<Product>(`${url}/${product.versionId}`, product, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'update'))) as Observable<void>;
}
delete(id: string): Observable<void> {
return this.http
.delete<Product>(`${url}/${id}`, httpOptions)
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<void>;
}
}