import connection from "./base.js"; export async function book_mate_insert({ book_name = "", book_id = "", book_md5 = "", language = "", date = null, creatorFileAs = "", UUID = "", ISBN = "", author_id = "", category_id = "", Introduction = "", }) { const sql = ` INSERT INTO book (book_name, book_id, book_md5, language, date, creatorFileAs, UUID, ISBN, author_id, category_id, Introduction) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE book_id = book_id; `; const values = [ book_name, book_id, book_md5, language, date, creatorFileAs, UUID, ISBN, author_id, category_id, Introduction, ]; return new Promise((resolve, reject) => { connection.execute(sql, values, (error, result) => { if (error) { console.error('Database error:', error); return reject(error); // 使用 reject 处理错误 } resolve(result); // 返回查询结果 }); }); } export async function getBookInfo(book_md5) { const sql = `select * from book where book_md5 = '${book_md5}';`; return new Promise((resolve, reject) => { connection.execute(sql, [], (error, result) => { if (error) { console.error('Database error:', error); return reject(error); // 使用 reject 处理错误 } resolve(result.length ? result[0] : false); // 返回查询结果 }); }); }