添加文案处理的功能

This commit is contained in:
2024-07-13 15:44:13 +08:00
parent 669e57824d
commit c8a46d59fb
80 changed files with 7383 additions and 2613 deletions
+41 -1
View File
@@ -237,7 +237,7 @@ export class BookService extends BaseRealmService {
delete book.imageFolder
// 修改数据
book.updateTime = new Date()
this.realm.write(() => {
this.transaction(() => {
this.realm.create('Book', book, UpdateMode.Modified)
})
@@ -248,4 +248,44 @@ export class BookService extends BaseRealmService {
throw error
}
}
/**
* 修改小说数据
* @param bookId 小说的ID
* @param bookData 要修改的小说数据
*/
async UpdateBookData(bookId: string, bookData) {
try {
if (bookId == null) {
throw new Error('修改小说数据失败,缺少小说ID')
}
if (bookData == null) {
throw new Error('修改小说数据失败,缺少小说数据')
}
// 检查小说ID对应的数据是不是存在
let bookRes = this.GetBookDataById(bookId)
if (bookRes.data == null) {
throw new Error('修改小说数据失败,小说ID对应的数据不存在')
}
if (bookData && bookData.id) {
delete bookData.id
}
// 开始修改
this.transaction(() => {
this.realm.create('Book', { id: bookId, ...bookData }, UpdateMode.Modified)
})
bookRes = this.GetBookDataById(bookId)
if (bookRes.data == null) {
throw new Error('获取修改后的小说数据失败,小说ID对应的数据不存在')
}
return successMessage(bookRes.data, '修改小说数据成功', 'ReverseBook_UpdateBookData')
} catch (error) {
throw error
}
}
}