gpt
This commit is contained in:
@@ -2,6 +2,7 @@ package mysqldao
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"git.lzcwy.cn/zhengchiliu/zt-closet-backend/global"
|
||||
"git.lzcwy.cn/zhengchiliu/zt-closet-backend/internal/mysqlmodel"
|
||||
@@ -136,3 +137,20 @@ func (d *ClothesDao) ClothesListByUserID(ctx context.Context, userID int64, cate
|
||||
}
|
||||
return list, total, nil
|
||||
}
|
||||
|
||||
// ClothesListStaleProcessing 查询超时未完成的图片任务。
|
||||
func (d *ClothesDao) ClothesListStaleProcessing(ctx context.Context, before int64, limit int) ([]mysqlmodel.Clothes, error) {
|
||||
var list []mysqlmodel.Clothes
|
||||
err := d.db.WithContext(ctx).
|
||||
Where("image_process_status IN ? AND updated_at < ?", []int8{1, 2, 3}, before).
|
||||
Order("id ASC").Limit(limit).Find(&list).Error
|
||||
return list, err
|
||||
}
|
||||
|
||||
// ClothesClaimStaleProcessing 原子认领超时任务,避免多实例重复恢复。
|
||||
func (d *ClothesDao) ClothesClaimStaleProcessing(ctx context.Context, clothesUUID string, before int64) (bool, error) {
|
||||
res := d.db.WithContext(ctx).Model(&mysqlmodel.Clothes{}).
|
||||
Where("clothes_uuid = ? AND image_process_status IN ? AND updated_at < ?", clothesUUID, []int8{1, 2, 3}, before).
|
||||
Updates(map[string]any{"image_process_status": 3, "updated_at": time.Now().Unix()})
|
||||
return res.RowsAffected > 0, res.Error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user