添加文案处理的功能
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user