添加文案处理的功能
This commit is contained in:
@@ -3,10 +3,19 @@ import path from 'path'
|
||||
import { BaseService } from '../baseService.js'
|
||||
import { define } from '../../../define.js'
|
||||
import { BookTaskModel } from '../../model/Book/bookTask.js'
|
||||
import { BookTaskStatus } from '../../../enum/bookEnum.js'
|
||||
import {
|
||||
BookBackTaskStatus,
|
||||
BookBackTaskType,
|
||||
BookTaskStatus,
|
||||
TaskExecuteType
|
||||
} from '../../../enum/bookEnum.js'
|
||||
import { errorMessage, successMessage } from '../../../../main/generalTools.js'
|
||||
import { BaseRealmService } from './bookBasic'
|
||||
import { isEmpty } from 'lodash'
|
||||
import { DefaultObject } from 'realm/dist/public-types/schema.js'
|
||||
import { BookModel } from '../../model/Book/book.js'
|
||||
import { OtherData } from '../../../enum/softwareEnum.js'
|
||||
import { BookBackTaskList } from '../../model/Book/BookBackTaskListModel.js'
|
||||
const { v4: uuidv4 } = require('uuid')
|
||||
|
||||
export class BookBackTaskListService extends BaseRealmService {
|
||||
@@ -32,13 +41,93 @@ export class BookBackTaskListService extends BaseRealmService {
|
||||
|
||||
/**
|
||||
* 获取指定条件的后台任务队列
|
||||
* bookId 必填
|
||||
* bookId 和 status 必填一个
|
||||
* @param query bookId,bookTaskId,name,type,status
|
||||
*/
|
||||
getBookBackTaskList(query) {
|
||||
GetBookBackTaskList(query) {
|
||||
try {
|
||||
// if()
|
||||
if (query == null) {
|
||||
throw new Error('查询后台队列任务失败,没有查询条件')
|
||||
}
|
||||
if (isEmpty(query.bookId) && isEmpty(query.status)) {
|
||||
throw new Error('查询后台队列任务失败,没有查询条件')
|
||||
}
|
||||
|
||||
// 构建查询条件
|
||||
// 下面时可空的条件
|
||||
let queryString = ''
|
||||
if (query.bookId) {
|
||||
queryString = `bookId = ${query.bookId}`
|
||||
}
|
||||
if (query.bookTaskId) {
|
||||
queryString += ` && bookTaskId = ${query.bookTaskId}`
|
||||
}
|
||||
if (query.name) {
|
||||
queryString += ` && name = ${query.name}`
|
||||
}
|
||||
if (query.type) {
|
||||
queryString += ` && type = ${query.type}`
|
||||
}
|
||||
if (query.status) {
|
||||
queryString += ` && status = ${query.status}`
|
||||
}
|
||||
if (query.executeType) {
|
||||
queryString += ` && executeType = ${query.executeType}`
|
||||
}
|
||||
|
||||
// 获取数据
|
||||
let tasks = this.realm
|
||||
.objects('BookBackTaskList')
|
||||
.filtered(queryString)
|
||||
.sorted('createTime', true)
|
||||
let res
|
||||
if (query.count) {
|
||||
res = tasks.slice(0, query.count)
|
||||
} else {
|
||||
res = tasks
|
||||
}
|
||||
|
||||
return successMessage(
|
||||
res.toJSON(),
|
||||
'查询后台队列任务成功',
|
||||
'BookBackTaskList_GetBookBackTaskList'
|
||||
)
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取等待状态的任务和返回指定数量的数据
|
||||
* @param executeType 任务的执行类型
|
||||
* @param count 返回数据的数量
|
||||
*/
|
||||
GetWaitTaskAndSlice(executeType: TaskExecuteType, count: number) {
|
||||
try {
|
||||
let tasks = this.realm
|
||||
.objects<BookBackTaskList>('BookBackTaskList')
|
||||
.filtered(
|
||||
'status == $0 && executeType == $1',
|
||||
BookBackTaskStatus.WAIT,
|
||||
executeType ? executeType : TaskExecuteType.AUTO
|
||||
)
|
||||
.sorted('createTime', false)
|
||||
|
||||
if (count != null) {
|
||||
tasks = tasks.slice(0, count) as unknown as Realm.Results<BookBackTaskList>
|
||||
}
|
||||
let res = Array.from(tasks).map((item) => {
|
||||
let resObj = {
|
||||
...item
|
||||
}
|
||||
return resObj
|
||||
})
|
||||
|
||||
return successMessage(
|
||||
res,
|
||||
'查询等待状态的后台队列任务成功',
|
||||
'BookBackTaskList_GetWaitTaskAndSlice'
|
||||
)
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
@@ -48,25 +137,61 @@ export class BookBackTaskListService extends BaseRealmService {
|
||||
* 新增一个小说相关的后台任务队列
|
||||
* @param bookBackTask 要添加的小说数据
|
||||
*/
|
||||
AddBookBackTaskList(bookBackTask) {
|
||||
async AddBookBackTask(
|
||||
bookId: string,
|
||||
taskType: BookBackTaskType,
|
||||
executeType = TaskExecuteType.AUTO,
|
||||
bookTaskId = null,
|
||||
bookTaskDetailId = null
|
||||
) {
|
||||
try {
|
||||
// 判断数据是不是存在
|
||||
if (
|
||||
isEmpty(bookBackTask.bookId) ||
|
||||
isEmpty(bookBackTask.bookTaskId) ||
|
||||
isEmpty(bookBackTask.name) ||
|
||||
isEmpty(bookBackTask.type)
|
||||
) {
|
||||
throw new Error('新增后台队列任务到数据库失败,数据不完整,缺少必要字段')
|
||||
// 通过bookid获取book信息
|
||||
let book = this.realm.objectForPrimaryKey('Book', bookId)
|
||||
if (book == null) {
|
||||
throw new Error('新增后台队列任务到数据库失败,没有找到对应的小说')
|
||||
}
|
||||
let bookTask
|
||||
if (bookTaskId) {
|
||||
bookTask = this.realm.objectForPrimaryKey('BookTask', bookTaskId)
|
||||
if (bookTask == null) {
|
||||
throw new Error('新增后台队列任务到数据库失败,没有找到对应的小说批次任务')
|
||||
}
|
||||
}
|
||||
|
||||
let bookTaskDetail
|
||||
if (bookTaskDetailId) {
|
||||
bookTaskDetail = this.realm.objectForPrimaryKey('BookTaskDetail', bookTaskDetailId)
|
||||
if (bookTaskDetail == null) {
|
||||
throw new Error(
|
||||
'新增后台队列任务到数据库失败,没有找到对应的小说批次任务详情(分镜数据)'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// 开始往数据库中写数据
|
||||
let name = `${book.name}-${bookTask ? bookTask.name : 'default'}-${
|
||||
bookTaskDetail ? bookTaskDetail.name : 'default'
|
||||
}-${taskType}`
|
||||
|
||||
let bookBackTask = {
|
||||
id: uuidv4(),
|
||||
bookId: bookId,
|
||||
bookTaskId: bookTaskId ? bookTaskId : OtherData.DEFAULT,
|
||||
bookTaskDetailId: bookTaskDetailId ? bookTaskDetailId : OtherData.DEFAULT,
|
||||
name: name,
|
||||
type: taskType,
|
||||
executeType: executeType,
|
||||
status: BookBackTaskStatus.WAIT,
|
||||
createTime: new Date(),
|
||||
updateTime: new Date()
|
||||
}
|
||||
// 开始新建
|
||||
bookBackTask.id = uuidv4()
|
||||
bookBackTask.createTime = new Date()
|
||||
bookBackTask.updateTime = new Date()
|
||||
bookBackTask.status = BookTaskStatus.WAIT
|
||||
this.realm.write(() => {
|
||||
this.realm.create('BookBackTaskList', bookBackTask)
|
||||
})
|
||||
|
||||
// 添加成功之后,调用开始执行任务的方法
|
||||
await global.taskManager.ExecuteAutoTask()
|
||||
|
||||
return successMessage(
|
||||
bookBackTask,
|
||||
'新增后台队列任务到数据库成功',
|
||||
@@ -74,24 +199,25 @@ export class BookBackTaskListService extends BaseRealmService {
|
||||
)
|
||||
} catch (error) {
|
||||
return errorMessage(
|
||||
'新增后台队列任务到数据库失败,错误信息入校' + error.toString(),
|
||||
'新增后台队列任务到数据库失败,错误信息如下' + error.toString(),
|
||||
'BookBackTaskList_AddBookBackTaskList'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改一个小说相关的后台任务队列中的详细信息(对于后台的队列任务只能修改状态)
|
||||
* 修改一个小说相关的后台任务队列中的详细信息
|
||||
* (对于后台的队列任务只能修改状态)和错误信息
|
||||
* @param bookBackTask 修改的数据
|
||||
*/
|
||||
async ModifyBookBackTaskList(bookBackTask) {
|
||||
UpdateTaskStatus(bookBackTask) {
|
||||
try {
|
||||
// 判断数据是不是存在
|
||||
if (isEmpty(bookBackTask.id) || isEmpty(bookBackTask.status)) {
|
||||
throw new Error('修改后台队列任务失败,数据不完整,缺少必要字段')
|
||||
}
|
||||
// 开始修改
|
||||
this.realm.write(() => {
|
||||
this.transaction(() => {
|
||||
// 获取指定ID的队列任务
|
||||
let _bookBackTask = this.realm.objectForPrimaryKey('BookBackTaskList', bookBackTask.id)
|
||||
// 判断数据是不是存在
|
||||
@@ -100,46 +226,50 @@ export class BookBackTaskListService extends BaseRealmService {
|
||||
}
|
||||
// 修改数据
|
||||
_bookBackTask.status = bookBackTask.status
|
||||
if (bookBackTask.errorMessage) {
|
||||
_bookBackTask.errorMessage = bookBackTask.errorMessage
|
||||
}
|
||||
})
|
||||
return successMessage(
|
||||
bookBackTask,
|
||||
'修改后台队列任务成功',
|
||||
'修改后台队列任务状态成功',
|
||||
'BookBackTaskList_ModifyBookBackTaskList'
|
||||
)
|
||||
} catch (error) {
|
||||
return errorMessage(
|
||||
'修改后台队列任务失败,错误信息如下:' + error.toString(),
|
||||
'BookBackTaskList_ModifyBookBackTaskList'
|
||||
)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除满足条件的数据,包含 id、bookId、bookTaskId
|
||||
* 上面的条件,至少要有一个
|
||||
* @param bookBackTask 删除的数据
|
||||
*/
|
||||
async DeleteBookBackTaskListBy(bookBackTask) {
|
||||
async DeleteBookBackTask(bookBackTask) {
|
||||
try {
|
||||
this.realm.write(() => {
|
||||
if (
|
||||
!bookBackTask.hasOwnProperty('id') &&
|
||||
!bookBackTask.hasOwnProperty('bookId') &&
|
||||
!bookBackTask.hasOwnProperty('bookTaskId')
|
||||
) {
|
||||
throw new Error('删除后台队列任务失败,缺少必要的删除条件')
|
||||
}
|
||||
|
||||
this.transaction(() => {
|
||||
// 构建查询条件
|
||||
let query = [] as string[]
|
||||
if (bookBackTask.id) {
|
||||
query.push(`id = ${bookBackTask.id}`)
|
||||
}
|
||||
const tasksToDelete = this.realm
|
||||
.objects('BookBackTaskList')
|
||||
.filtered('id == $0', bookBackTask.id)
|
||||
|
||||
if (bookBackTask.bookId) {
|
||||
query.push(`bookId = ${bookBackTask.bookId}`)
|
||||
tasksToDelete.filtered('bookId == $0', bookBackTask.bookId)
|
||||
}
|
||||
if (bookBackTask.bookTaskId) {
|
||||
query.push(`bookTaskId = ${bookBackTask.bookTaskId}`)
|
||||
}
|
||||
const queryString = query.join(' && ')
|
||||
// 获取指定的数据
|
||||
if (queryString) {
|
||||
const tasksToDelete = this.realm.objects('BookBackTaskList').filtered(queryString)
|
||||
this.realm.delete(tasksToDelete)
|
||||
} else {
|
||||
throw new Error('删除后台队列任务失败,没有筛选条件')
|
||||
tasksToDelete.filtered('bookTaskId == $0', bookBackTask.bookTaskId)
|
||||
}
|
||||
|
||||
this.realm.delete(tasksToDelete)
|
||||
|
||||
return successMessage(
|
||||
bookBackTask,
|
||||
'删除后台队列任务成功',
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
WebuiConfig
|
||||
} from '../../model/Book/bookTaskDetail'
|
||||
import { BookBackTaskList } from '../../model/Book/BookBackTaskListModel'
|
||||
import { TaskExecuteType } from '../../../enum/bookEnum'
|
||||
import { version } from '../../../../../package.json'
|
||||
|
||||
let dbPath = path.resolve(define.db_path, 'book.realm')
|
||||
|
||||
@@ -39,6 +41,42 @@ const migration = (oldRealm: Realm, newRealm: Realm) => {
|
||||
newBookTask[i].audioPath = null // 为新属性设置默认值
|
||||
}
|
||||
}
|
||||
if (oldRealm.schemaVersion < 4) {
|
||||
const oldBookTask = oldRealm.objects('BookBackTaskList')
|
||||
const newBookTask = newRealm.objects('BookBackTaskList')
|
||||
for (let i = 0; i < oldBookTask.length; i++) {
|
||||
newBookTask[i].errorMessage = null // 设置错误信息的默认值
|
||||
}
|
||||
}
|
||||
if (oldRealm.schemaVersion < 5) {
|
||||
const oldBookTask = oldRealm.objects('BookBackTaskList')
|
||||
const newBookTask = newRealm.objects('BookBackTaskList')
|
||||
for (let i = 0; i < oldBookTask.length; i++) {
|
||||
newBookTask[i].executeType = TaskExecuteType.AUTO // 设置错误信息的默认值
|
||||
}
|
||||
}
|
||||
if (oldRealm.schemaVersion < 6) {
|
||||
const oldBookTask = oldRealm.objects('BookBackTaskList')
|
||||
const newBookTask = newRealm.objects('BookBackTaskList')
|
||||
for (let i = 0; i < oldBookTask.length; i++) {
|
||||
newBookTask[i].bookTaskDetailId = 'default' // 设置错误信息的默认值
|
||||
}
|
||||
}
|
||||
if (oldRealm.schemaVersion < 7) {
|
||||
const oldBookTask = oldRealm.objects('Book')
|
||||
const newBookTask = newRealm.objects('Book')
|
||||
for (let i = 0; i < oldBookTask.length; i++) {
|
||||
newBookTask[i].version = version // 设置版本的默认值
|
||||
newBookTask[i].subtitlePosition = null // 设置字幕位置的默认值
|
||||
}
|
||||
}
|
||||
if (oldRealm.schemaVersion < 8) {
|
||||
const oldBookTask = oldRealm.objects('BookTaskDetail')
|
||||
const newBookTask = newRealm.objects('BookTaskDetail')
|
||||
for (let i = 0; i < oldBookTask.length; i++) {
|
||||
newBookTask[i].subtitlePosition = null // 设置字幕位置的默认值
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class BaseRealmService extends BaseService {
|
||||
@@ -79,7 +117,7 @@ export class BaseRealmService extends BaseService {
|
||||
BookTaskDetailModel
|
||||
],
|
||||
path: this.dbpath,
|
||||
schemaVersion: 3,
|
||||
schemaVersion: 8,
|
||||
migration: migration
|
||||
}
|
||||
this.realm = await Realm.open(config)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { endsWith, isEmpty } from 'lodash'
|
||||
import { book } from '../../../../preload/book.js'
|
||||
import { DefaultObject } from 'realm/dist/public-types/schema.js'
|
||||
import { JoinPath } from '../../../Tools/file.js'
|
||||
import { BookTaskDetailModel } from '../../model/Book/bookTaskDetail.js'
|
||||
const { v4: uuidv4 } = require('uuid')
|
||||
|
||||
let dbPath = path.resolve(define.db_path, 'book.realm')
|
||||
@@ -47,28 +48,20 @@ export class BookTaskDetailService extends BaseRealmService {
|
||||
if (condition == null) {
|
||||
throw new Error('查询小说分镜信息,查询条件不能为空')
|
||||
}
|
||||
let query = [] as string[]
|
||||
let tasksToDelete = this.realm.objects<BookTaskDetailModel>('BookTaskDetail')
|
||||
if (condition.id) {
|
||||
query.push(`id = ${condition.id}`)
|
||||
tasksToDelete = tasksToDelete.filtered('id==$0', condition.id)
|
||||
}
|
||||
if (condition.bookId) {
|
||||
query.push(`bookId = ${condition.bookId}`)
|
||||
tasksToDelete = tasksToDelete.filtered('bookId==$0', condition.bookId)
|
||||
}
|
||||
if (condition.bookTaskId) {
|
||||
query.push(`bookTaskId = ${condition.bookTaskId}`)
|
||||
tasksToDelete = tasksToDelete.filtered('bookTaskId==$0', condition.bookTaskId)
|
||||
}
|
||||
if (condition.name) {
|
||||
query.push(`name = ${condition.name}`)
|
||||
}
|
||||
const queryString = query.join(' && ')
|
||||
let tasksToDelete: Realm.Results<Realm.Object<DefaultObject, never> & DefaultObject>
|
||||
// 获取指定的数据
|
||||
if (queryString) {
|
||||
tasksToDelete = this.realm.objects('BookTaskDetail').filtered(queryString)
|
||||
} else {
|
||||
// 返回全部
|
||||
tasksToDelete = this.realm.objects('BookTaskDetail')
|
||||
tasksToDelete = tasksToDelete.filtered('name==$0', condition.name)
|
||||
}
|
||||
|
||||
let resData = Array.from(tasksToDelete).map((item) => {
|
||||
let resObj = {
|
||||
...item,
|
||||
@@ -138,19 +131,20 @@ export class BookTaskDetailService extends BaseRealmService {
|
||||
let bookTaskDetails = this.realm
|
||||
.objects<BookTaskModel>('BookTaskDetail')
|
||||
.filtered(
|
||||
'bookId = $0 AND bookTaskId = $1',
|
||||
'bookId == $0 AND bookTaskId == $1',
|
||||
bookTaskDetail.bookId,
|
||||
bookTaskDetail.bookTaskId
|
||||
)
|
||||
|
||||
let maxNo = bookTaskDetails.max('no')
|
||||
bookTaskDetail.no = maxNo ? Number(maxNo) + 1 : 1
|
||||
let name = bookTaskDetail.no.tosString().padStart(5, '0')
|
||||
let name = bookTaskDetail.no.toString().padStart(5, '0')
|
||||
|
||||
bookTaskDetail.name = name
|
||||
bookTaskDetail.id = uuidv4()
|
||||
bookTaskDetail.createTime = new Date()
|
||||
bookTaskDetail.updateTime = new Date()
|
||||
bookTaskDetail.adetailer = false // 先写死false
|
||||
// 开始添加
|
||||
this.transaction(() => {
|
||||
this.realm.create('BookTaskDetail', bookTaskDetail)
|
||||
@@ -203,25 +197,20 @@ export class BookTaskDetailService extends BaseRealmService {
|
||||
if (isEmpty(condition.id) && isEmpty(condition.bookTaskId) && isEmpty(condition.bookId)) {
|
||||
throw new Error('删除小说分镜信息失败,没有必要参数')
|
||||
}
|
||||
let query = [] as string[]
|
||||
let tasksToDelete = this.realm.objects<BookTaskDetailModel>('BookTaskDetail')
|
||||
if (condition.id) {
|
||||
query.push(`id = ${condition.id}`)
|
||||
tasksToDelete = tasksToDelete.filtered('id==$0', condition.id)
|
||||
}
|
||||
if (condition.bookId) {
|
||||
query.push(`bookId = ${condition.bookId}`)
|
||||
tasksToDelete = tasksToDelete.filtered('bookId==$0', condition.bookId)
|
||||
}
|
||||
if (condition.bookTaskId) {
|
||||
query.push(`bookTaskId = ${condition.bookTaskId}`)
|
||||
tasksToDelete = tasksToDelete.filtered('bookTaskId==$0', condition.bookTaskId)
|
||||
}
|
||||
if (condition.name) {
|
||||
query.push(`name = ${condition.name}`)
|
||||
tasksToDelete = tasksToDelete.filtered('name==$0', condition.name)
|
||||
}
|
||||
|
||||
if (query.length <= 0) {
|
||||
throw new Error('删除小说分镜任务失败,没有查询条件')
|
||||
}
|
||||
const queryString = query.join(' && ')
|
||||
let tasksToDelete = this.realm.objects('BookTaskDetail').filtered(queryString)
|
||||
this.transaction(() => {
|
||||
this.realm.delete(tasksToDelete)
|
||||
})
|
||||
|
||||
@@ -3,11 +3,12 @@ import path from 'path'
|
||||
import { BaseService } from '../baseService.js'
|
||||
import { define } from '../../../define.js'
|
||||
import { BookTaskModel } from '../../model/Book/bookTask.js'
|
||||
import { BookTaskStatus } from '../../../enum/bookEnum.js'
|
||||
import { BookBackTaskStatus, BookTaskStatus } from '../../../enum/bookEnum.js'
|
||||
import { successMessage } from '../../../../main/generalTools.js'
|
||||
import { BaseRealmService } from './bookBasic'
|
||||
import { isEmpty } from 'lodash'
|
||||
import { JoinPath } from '../../../Tools/file.js'
|
||||
import { BookBackTaskList } from '../../model/Book/BookBackTaskListModel.js'
|
||||
const { v4: uuidv4 } = require('uuid')
|
||||
|
||||
let dbPath = path.resolve(define.db_path, 'book.realm')
|
||||
@@ -153,6 +154,35 @@ export class BookTaskService extends BaseRealmService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改后台等待的所有任务的状态为fial。
|
||||
* 并且错误信息为任务被丢弃
|
||||
* @param bookId
|
||||
* @param bookTaskId
|
||||
*/
|
||||
UpdetedBookTaskToFail(bookId: string, bookTaskId: string) {
|
||||
try {
|
||||
this.transaction(() => {
|
||||
let updateData = this.realm
|
||||
.objects<BookBackTaskList>('BookBackTaskList')
|
||||
.filtered(
|
||||
'bookId == $0 AND bookTaskId == $1 AND status == $2',
|
||||
bookId,
|
||||
bookTaskId,
|
||||
BookBackTaskStatus.WAIT
|
||||
)
|
||||
|
||||
// 修改
|
||||
updateData.forEach((data) => {
|
||||
data.status = BookBackTaskStatus.FAIL
|
||||
data.errorMessage = '任务被丢弃'
|
||||
})
|
||||
})
|
||||
} catch (error) {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
// 添加一条数据
|
||||
AddOrModifyBookTask(bookTask) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user