feat(bookmark): implement bookmark management with CRUD operations (#1795)
* feat(bookmark): implement bookmark management with CRUD operations and UI integration Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> * feat(bookmark): add uniqueness constraint for bookmarks and check for existing bookmarks before creation Signed-off-by: Balázs Szücs <bszucs1209@gmail.com> --------- Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import {Injectable, inject} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {API_CONFIG} from '../../core/config/api-config';
|
||||
|
||||
export interface BookMark {
|
||||
id: number;
|
||||
bookId: number;
|
||||
cfi: string;
|
||||
title: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface CreateBookMarkRequest {
|
||||
bookId: number;
|
||||
cfi: string;
|
||||
title?: string;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class BookMarkService {
|
||||
|
||||
private readonly url = `${API_CONFIG.BASE_URL}/api/v1/bookmarks`;
|
||||
private readonly http = inject(HttpClient);
|
||||
|
||||
getBookmarksForBook(bookId: number): Observable<BookMark[]> {
|
||||
return this.http.get<BookMark[]>(`${this.url}/book/${bookId}`);
|
||||
}
|
||||
|
||||
createBookmark(request: CreateBookMarkRequest): Observable<BookMark> {
|
||||
return this.http.post<BookMark>(this.url, request);
|
||||
}
|
||||
|
||||
deleteBookmark(bookmarkId: number): Observable<void> {
|
||||
return this.http.delete<void>(`${this.url}/${bookmarkId}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user