activity_video.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. package services
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hongze_cygx/models"
  6. "hongze/hongze_cygx/utils"
  7. )
  8. // GetActivityPlayBackActivityIds 获取带有回放的所有的活动ID
  9. func GetActivityPlayBackActivityIds() (activityIds string, err error) {
  10. defer func() {
  11. if err != nil {
  12. go utils.SendAlarmMsg("GetActivityPlayBackActivityIds,获取带有回放的所有的活动ID失败"+err.Error(), 2)
  13. }
  14. }()
  15. //获取所有活动视频ID
  16. vidoeActivityIds, e := models.GetActivityVideoActivityIds()
  17. if e != nil {
  18. err = errors.New("GetActivityVideoActivityIds, Err: " + e.Error())
  19. return
  20. }
  21. //如果没有就赋值为0,避免空查询报错
  22. if vidoeActivityIds == "" {
  23. vidoeActivityIds = "0"
  24. }
  25. //获取所有活动视频ID
  26. voiceActivityIds, e := models.GetActivityVoiceActivityIds()
  27. if e != nil {
  28. err = errors.New("GetActivityVoiceActivityIds, Err: " + e.Error())
  29. return
  30. }
  31. if voiceActivityIds == "" {
  32. voiceActivityIds = "0"
  33. }
  34. activityIds = vidoeActivityIds + "," + voiceActivityIds
  35. return
  36. }
  37. // GetActivityVideoOrVoiceActivityIds 获取音频或者视频的活动ID
  38. func GetActivityVideoOrVoiceActivityIds(filter int) (activityIds string, err error) {
  39. defer func() {
  40. if err != nil {
  41. go utils.SendAlarmMsg("GetActivityPlayBackActivityIds,获取带有回放的所有的活动ID失败"+err.Error(), 2)
  42. }
  43. }()
  44. if filter == 1 {
  45. //获取所有活动视频ID
  46. vidoeActivityIds, e := models.GetActivityVideoActivityIds()
  47. if e != nil {
  48. err = errors.New("GetActivityVideoActivityIds, Err: " + e.Error())
  49. return
  50. }
  51. //如果没有就赋值为0,避免空查询报错
  52. if vidoeActivityIds == "" {
  53. vidoeActivityIds = "0"
  54. }
  55. activityIds = vidoeActivityIds
  56. } else {
  57. //获取所有活动视频ID
  58. voiceActivityIds, e := models.GetActivityVoiceActivityIds()
  59. if e != nil {
  60. err = errors.New("GetActivityVoiceActivityIds, Err: " + e.Error())
  61. return
  62. }
  63. if voiceActivityIds == "" {
  64. voiceActivityIds = "0"
  65. }
  66. activityIds = voiceActivityIds
  67. }
  68. return
  69. }
  70. func init12312() {
  71. ActivityVideoAndVoiceDef()
  72. }
  73. func ActivityVideoAndVoiceDef() {
  74. var condition string
  75. var pars []interface{}
  76. // 获取默认图配置
  77. audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
  78. if e != nil {
  79. fmt.Println(e)
  80. return
  81. }
  82. list, err := models.GetActivityVoiceList(condition, pars, 0, 100000)
  83. if err != nil {
  84. fmt.Println(err)
  85. return
  86. }
  87. for _, v := range list {
  88. if v.BackgroundImg != "" {
  89. continue
  90. }
  91. item := new(models.CygxActivityVoice)
  92. item.ActivityId = v.ActivityId
  93. item.BackgroundImg = audioMap[v.ChartPermissionId]
  94. item.ShareImg = audioShareMap[v.ChartPermissionId]
  95. err = models.UpdateCygxActivityVoice(item)
  96. if err != nil {
  97. fmt.Println(err)
  98. return
  99. }
  100. fmt.Println(item)
  101. }
  102. listVidoe, err := models.GetActivityVideoList(condition, pars, 0, 100000)
  103. if err != nil {
  104. fmt.Println(err)
  105. return
  106. }
  107. for _, v := range listVidoe {
  108. if v.BackgroundImg != "" {
  109. continue
  110. }
  111. item := new(models.CygxActivityVideo)
  112. item.ActivityId = v.ActivityId
  113. item.BackgroundImg = videoMap[v.ChartPermissionId]
  114. item.ShareImg = videoShareMap[v.ChartPermissionId]
  115. err = models.UpdateCygxActivityVideo(item)
  116. if err != nil {
  117. fmt.Println(err)
  118. return
  119. }
  120. fmt.Println(item)
  121. }
  122. }