增加一个重新转换文档的状态

dev
truthhun 11 months ago
parent 7b856ed1de
commit 2d11e6b67a

@ -26,6 +26,7 @@ const (
DocumentStatusConverted // 已转换
DocumentStatusFailed // 转换失败
DocumentStatusDisabled // 已禁用
DocumentStatusRePending // 重新等待转换
)
var DocumentStatusMap = map[int]struct{}{
@ -600,7 +601,7 @@ func (m *DBModel) GetDocumentStatusConvertedByHash(hash []string) (hashMapDocume
// 7. 更新文档状态
func (m *DBModel) ConvertDocument() (err error) {
var document Document
err = m.db.Where("status = ?", DocumentStatusPending).First(&document).Error
err = m.db.Where("status in ?", []int{DocumentStatusPending, DocumentStatusRePending}).First(&document).Error
if err != nil {
if err != gorm.ErrRecordNotFound {
m.logger.Error("ConvertDocument", zap.Error(err))
@ -623,10 +624,11 @@ func (m *DBModel) ConvertDocument() (err error) {
return
}
if !cfg.EnableConvertRepeatedDocument {
if !cfg.EnableConvertRepeatedDocument && document.Status != DocumentStatusRePending {
// 文档hash
hashMapDocs := m.GetDocumentStatusConvertedByHash([]string{attachment.Hash})
if len(hashMapDocs) > 0 {
m.logger.Info("ConvertDocument", zap.Bool("EnableConvertRepeatedDocument", cfg.EnableConvertRepeatedDocument), zap.String("hash", attachment.Hash), zap.Any("hashMapDocs", hashMapDocs))
// 已有文档转换成功将hash相同的文档相关数据迁移到当前文档
sql := " UPDATE `%s` SET `description`= ? , `enable_gzip` = ?, `width` = ?, `height`= ?, `preview`= ?, `pages` = ?, `status` = ? WHERE status in ? and id in (select type_id from `%s` where `hash` = ? and `type` = ?)"
sql = fmt.Sprintf(sql, Document{}.TableName(), Attachment{}.TableName())

@ -23,6 +23,7 @@ export const documentStatusOptions = [
{ label: '', value: 2, type: 'success' },
{ label: '', value: 3, type: 'warning' },
{ label: '', value: 4, type: 'danger' },
{ label: '', value: 5, type: 'info' },
]
// 0 网站横幅1 小程序横幅2 APP横幅

Loading…
Cancel
Save