36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package audio
|
||
|
||
import (
|
||
"context"
|
||
consts "media/consts/audio"
|
||
entity "media/model/entity/audio"
|
||
|
||
"gitea.redpowerfuture.com/red-future/common/db/gfdb"
|
||
)
|
||
|
||
var TranscribeTaskDetail = new(transcribeTaskDetailDao)
|
||
|
||
type transcribeTaskDetailDao struct{}
|
||
|
||
// Insert 插入明细
|
||
func (d *transcribeTaskDetailDao) Insert(ctx context.Context, data *entity.TranscribeTaskDetail) (id int64, err error) {
|
||
// FieldsEx 排除空 scenes 字段(JSONB 列不支持空串 '')
|
||
r, err := gfdb.DB(ctx).Model(ctx, consts.TranscribeTaskDetailTable).
|
||
Data(data).
|
||
FieldsEx(entity.TranscribeTaskDetailCols.Scenes).
|
||
Insert()
|
||
if err != nil {
|
||
return 0, err
|
||
}
|
||
return r.LastInsertId()
|
||
}
|
||
|
||
// ListByTaskID 根据taskId查询明细列表(按file_index升序)
|
||
func (d *transcribeTaskDetailDao) ListByTaskID(ctx context.Context, taskID string) (res []entity.TranscribeTaskDetail, err error) {
|
||
err = gfdb.DB(ctx).Model(ctx, consts.TranscribeTaskDetailTable).
|
||
Where(entity.TranscribeTaskDetailCols.TaskID, taskID).
|
||
OrderAsc(entity.TranscribeTaskDetailCols.FileIndex).
|
||
Scan(&res)
|
||
return
|
||
}
|