up.go 897 B

12345678910111213141516171819202122232425262728293031323334
  1. package manager
  2. import (
  3. "context"
  4. "database/sql"
  5. "go-common/app/service/main/videoup/model/archive"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _upsWithGroup = "SELECT ups.id,mid,up_group.id as group_id ,up_group.short_tag as group_tag,up_group.name as group_name,ups.note,ups.ctime FROM ups INNER JOIN up_group on ups.type=up_group.id"
  10. )
  11. // UpSpecial load all ups with group info
  12. func (d *Dao) UpSpecial(c context.Context) (ups []*archive.Up, err error) {
  13. rows, err := d.managerDB.Query(c, _upsWithGroup)
  14. if err != nil {
  15. log.Error("d.tpsStmt.Query error(%v)", err)
  16. return
  17. }
  18. defer rows.Close()
  19. var note sql.NullString
  20. for rows.Next() {
  21. up := &archive.Up{}
  22. if err = rows.Scan(&up.ID, &up.Mid, &up.GroupID, &up.GroupTag, &up.GroupName, &note, &up.CTime); err != nil {
  23. log.Error("rows.Scan error(%v)", err)
  24. return
  25. }
  26. up.Note = note.String
  27. ups = append(ups, up)
  28. }
  29. return
  30. }