123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- package services
- import (
- "errors"
- "fmt"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/utils"
- )
- // GetActivityPlayBackActivityIds 获取带有回放的所有的活动ID
- func GetActivityPlayBackActivityIds() (activityIds string, err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("GetActivityPlayBackActivityIds,获取带有回放的所有的活动ID失败"+err.Error(), 2)
- }
- }()
- //获取所有活动视频ID
- vidoeActivityIds, e := models.GetActivityVideoActivityIds()
- if e != nil {
- err = errors.New("GetActivityVideoActivityIds, Err: " + e.Error())
- return
- }
- //如果没有就赋值为0,避免空查询报错
- if vidoeActivityIds == "" {
- vidoeActivityIds = "0"
- }
- //获取所有活动视频ID
- voiceActivityIds, e := models.GetActivityVoiceActivityIds()
- if e != nil {
- err = errors.New("GetActivityVoiceActivityIds, Err: " + e.Error())
- return
- }
- if voiceActivityIds == "" {
- voiceActivityIds = "0"
- }
- activityIds = vidoeActivityIds + "," + voiceActivityIds
- return
- }
- // GetActivityVideoOrVoiceActivityIds 获取音频或者视频的活动ID
- func GetActivityVideoOrVoiceActivityIds(filter int) (activityIds string, err error) {
- defer func() {
- if err != nil {
- go utils.SendAlarmMsg("GetActivityPlayBackActivityIds,获取带有回放的所有的活动ID失败"+err.Error(), 2)
- }
- }()
- if filter == 1 {
- //获取所有活动视频ID
- vidoeActivityIds, e := models.GetActivityVideoActivityIds()
- if e != nil {
- err = errors.New("GetActivityVideoActivityIds, Err: " + e.Error())
- return
- }
- //如果没有就赋值为0,避免空查询报错
- if vidoeActivityIds == "" {
- vidoeActivityIds = "0"
- }
- activityIds = vidoeActivityIds
- } else {
- //获取所有活动视频ID
- voiceActivityIds, e := models.GetActivityVoiceActivityIds()
- if e != nil {
- err = errors.New("GetActivityVoiceActivityIds, Err: " + e.Error())
- return
- }
- if voiceActivityIds == "" {
- voiceActivityIds = "0"
- }
- activityIds = voiceActivityIds
- }
- return
- }
- func init12312() {
- ActivityVideoAndVoiceDef()
- }
- func ActivityVideoAndVoiceDef() {
- var condition string
- var pars []interface{}
- // 获取默认图配置
- audioMap, videoMap, audioShareMap, videoShareMap, e := GetMicroRoadShowDefaultImgConfig()
- if e != nil {
- fmt.Println(e)
- return
- }
- list, err := models.GetActivityVoiceList(condition, pars, 0, 100000)
- if err != nil {
- fmt.Println(err)
- return
- }
- for _, v := range list {
- if v.BackgroundImg != "" {
- continue
- }
- item := new(models.CygxActivityVoice)
- item.ActivityId = v.ActivityId
- item.BackgroundImg = audioMap[v.ChartPermissionId]
- item.ShareImg = audioShareMap[v.ChartPermissionId]
- err = models.UpdateCygxActivityVoice(item)
- if err != nil {
- fmt.Println(err)
- return
- }
- fmt.Println(item)
- }
- listVidoe, err := models.GetActivityVideoList(condition, pars, 0, 100000)
- if err != nil {
- fmt.Println(err)
- return
- }
- for _, v := range listVidoe {
- if v.BackgroundImg != "" {
- continue
- }
- item := new(models.CygxActivityVideo)
- item.ActivityId = v.ActivityId
- item.BackgroundImg = videoMap[v.ChartPermissionId]
- item.ShareImg = videoShareMap[v.ChartPermissionId]
- err = models.UpdateCygxActivityVideo(item)
- if err != nil {
- fmt.Println(err)
- return
- }
- fmt.Println(item)
- }
- }
|