LaiTool V3.0.1-preview.7

This commit is contained in:
2024-08-18 16:22:19 +08:00
parent 07f99708da
commit 223678f761
78 changed files with 2827 additions and 917 deletions
+23 -3
View File
@@ -11,6 +11,7 @@ import { isEmpty } from 'lodash'
import { FfmpegOptions } from '../../../../main/Service/ffmpegOptions.js'
import { version } from '../../../../../package.json'
import { Book } from '../../../../model/book.js'
import { GeneralResponse } from '../../../../model/generalResponse.js'
export class BookService extends BaseRealmService {
static instance: BookService | null = null
@@ -37,7 +38,7 @@ export class BookService extends BaseRealmService {
* 获取小说信息,没有找到返回null
* @param bookId
*/
GetBookDataById(bookId): Book.SelectBook | null {
GetBookDataById(bookId: string): Book.SelectBook | null {
try {
if (isEmpty(bookId)) {
throw new Error('获取小说信息失败,缺少小说ID')
@@ -275,7 +276,7 @@ export class BookService extends BaseRealmService {
* @param bookId 小说的ID
* @param bookData 要修改的小说数据
*/
async UpdateBookData(bookId: string, bookData: Book.SelectBook) {
UpdateBookData(bookId: string, bookData: Book.SelectBook): Book.SelectBook {
try {
if (bookId == null) {
throw new Error('修改小说数据失败,缺少小说ID')
@@ -303,8 +304,27 @@ export class BookService extends BaseRealmService {
if (bookRes == null) {
throw new Error('获取修改后的小说数据失败,小说ID对应的数据不存在')
}
// return successMessage(bookRes, '修改小说数据成功', 'ReverseBook_UpdateBookData')
return bookRes;
} catch (error) {
throw error
}
}
return successMessage(bookRes, '修改小说数据成功', 'ReverseBook_UpdateBookData')
/**
* 删除指定的小说任务
* @param bookId 需要删除的小说的ID
*/
DeleteBookData(bookId: string): void {
try {
this.transaction(() => {
let book = this.realm.objectForPrimaryKey('Book', bookId);
if (book == null) {
throw new Error('未找到对应的小说')
}
// 删除对应的小说
this.realm.delete(book)
})
} catch (error) {
throw error
}