feat: update download job

This commit is contained in:
yanghao05
2025-04-17 20:49:05 +08:00
parent 9323fb4230
commit a60213a79b
3 changed files with 40 additions and 14 deletions

View File

@@ -231,3 +231,21 @@ func (m *mediasModel) Update(ctx context.Context, hash string, model *model.Medi
m.log.Infof("media item updated successfully")
return nil
}
// GetByID
func (m *mediasModel) GetByID(ctx context.Context, id int64) (*model.Medias, error) {
tbl := table.Medias
stmt := tbl.
SELECT(tbl.AllColumns).
WHERE(tbl.ID.EQ(Int64(id)))
m.log.Infof("sql: %s", stmt.DebugSql())
var media model.Medias
err := stmt.QueryContext(ctx, db, &media)
if err != nil {
m.log.Errorf("error querying media item by ID: %v", err)
return nil, err
}
return &media, nil
}