Feature: Paged customer list.

This commit is contained in:
tanshu committed 2025-07-10 09:39:55 +00:00
1 parent af684c976e
commit 0dbec4784b
9 files changed
+390 -39

No files matched your search

+12 -3
View File
@@ -5,6 +5,7 @@ import { catchError } from 'rxjs/operators';
import { Customer } from '../core/customer';
import { ErrorLoggerService } from '../core/error-logger.service';
import { PagedResult } from '../core/paged-result';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
@@ -26,10 +27,18 @@ export class CustomerService {
.pipe(catchError(this.log.handleError(serviceName, `get id=${id}`))) as Observable<Customer>;
}
list(): Observable<Customer[]> {
list(q: string | null, page = 0, size = 50, field = 'name', direction = 'asc'): Observable<PagedResult<Customer>> {
const params = {
...(q ? { q } : {}),
p: page,
s: size,
f: field,
d: direction,
};
console.log('CustomerService.list', params);
return this.http
.get<Customer[]>(`${url}/list`)
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<Customer[]>;
.get<PagedResult<Customer>>(`${url}/list`, { params })
.pipe(catchError(this.log.handleError(serviceName, 'list'))) as Observable<PagedResult<Customer>>;
}
save(customer: Customer): Observable<Customer> {