video.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/admin/main/videoup-task/model"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. )
  8. func (s *Service) getVideo(ctx context.Context, aid int64, cid int64) (video *model.Video, err error) {
  9. if video, err = s.dao.Video(ctx, aid, cid); err != nil {
  10. log.Error("getVideo s.arc.Video error(%v) aid(%d) cid(%d)", err, aid, cid)
  11. return
  12. }
  13. if video == nil {
  14. err = ecode.NothingFound
  15. log.Error("getVideo s.arc.Video error(%v) aid(%d) cid(%d)", err, aid, cid)
  16. return
  17. }
  18. video.AttributeList = model.AttributeList(video.Attribute)
  19. if video.XcodeState >= model.VideoXcodeHDFinish {
  20. video.Encoding = 1
  21. }
  22. return
  23. }
  24. func (s *Service) getVideoOperInfo(ctx context.Context, vid int64) (list []*model.VideoOperInfo, err error) {
  25. var (
  26. vopers []*model.VOper
  27. uids []int64
  28. users map[int64]*model.UserDepart
  29. )
  30. list = []*model.VideoOperInfo{}
  31. if vopers, uids, err = s.dao.VideoOpers(ctx, vid); err != nil {
  32. log.Error("getVideoOperInfo s.dao.VideoOpers(%d) error(%v)", vid, err)
  33. return
  34. }
  35. if users, err = s.dao.GetUsernameAndDepartment(ctx, uids); err != nil {
  36. log.Error("getVideoOperInfo s.dao.GetUsernameAndRol(%d) error(%v) uids(%v)", vid, err, uids)
  37. return
  38. }
  39. for _, op := range vopers {
  40. u := users[op.UID]
  41. if u == nil {
  42. u = &model.UserDepart{UID: op.UID}
  43. }
  44. info := &model.VideoOperInfo{
  45. VOper: *op,
  46. UserDepart: *u,
  47. }
  48. list = append(list, info)
  49. }
  50. return
  51. }