Remove CharacterComponent and CharacterDetail components
- Deleted `CharacterComponent` and `CharacterDetail` files from the project. - Refactored related logic to improve code maintainability and reduce redundancy.
This commit is contained in:
@@ -123,7 +123,7 @@ export default class BookRepo {
|
||||
let book: BookQuery;
|
||||
try {
|
||||
const db: Database = System.getDb();
|
||||
const query: string = 'SELECT book_id, author_id, title, summary, sub_title, cover_image, desired_release_date, desired_word_count, words_count FROM erit_books WHERE book_id=? AND author_id=?';
|
||||
const query: string = 'SELECT book_id, author_id, title, summary, sub_title, cover_image, desired_release_date, desired_word_count, words_count, serie_id FROM erit_books WHERE book_id=? AND author_id=?';
|
||||
const params: SQLiteValue[] = [bookId, userId];
|
||||
book = db.get(query, params) as BookQuery;
|
||||
} catch (error: unknown) {
|
||||
@@ -456,4 +456,40 @@ export default class BookRepo {
|
||||
throw new Error(lang === 'fr' ? "Une erreur inconnue s'est produite." : "An unknown error occurred.");
|
||||
}
|
||||
}
|
||||
|
||||
static isBookExist(userId: string, bookId: string, lang: 'fr' | 'en'): boolean {
|
||||
try {
|
||||
const db: Database = System.getDb();
|
||||
const query: string = 'SELECT 1 FROM erit_books WHERE author_id = ? AND book_id = ? LIMIT 1';
|
||||
const params: SQLiteValue[] = [userId, bookId];
|
||||
const result = db.get(query, params);
|
||||
return result !== undefined && result !== null;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.error(`DB Error: ${error.message}`);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the series_id for a book from series_books table.
|
||||
* @param bookId - The book identifier
|
||||
* @param lang - The language for error messages
|
||||
* @returns The series_id or null if book is not in a series
|
||||
*/
|
||||
static fetchBookSeriesId(bookId: string, lang: 'fr' | 'en'): string | null {
|
||||
try {
|
||||
const db: Database = System.getDb();
|
||||
const query: string = 'SELECT series_id FROM series_books WHERE book_id = ? LIMIT 1';
|
||||
const params: SQLiteValue[] = [bookId];
|
||||
const result = db.get(query, params) as { series_id: string } | undefined;
|
||||
return result?.series_id || null;
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.error(`DB Error: ${error.message}`);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user