banner.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package cygx
  2. import (
  3. "errors"
  4. "fmt"
  5. "hongze/hz_crm_api/models/cygx"
  6. "hongze/hz_crm_api/services/alarm_msg"
  7. )
  8. func GetCygxBannerTypeMap() (mapResp map[int]string) {
  9. mapResp = make(map[int]string, 0)
  10. mapResp[1] = "现有报告"
  11. mapResp[2] = "自拟报告"
  12. mapResp[3] = "视频"
  13. mapResp[4] = "音频"
  14. mapResp[5] = "活动"
  15. return
  16. }
  17. //func init() {
  18. // UpdateBannerSort("B")
  19. //}
  20. // 批量更新某一列的数据
  21. func UpdateBannerSort(listType string) (err error) {
  22. defer func() {
  23. if err != nil {
  24. fmt.Println(err)
  25. go alarm_msg.SendAlarmMsg("获取产品内测的阅读数据,信息失败,Err:"+err.Error(), 3)
  26. }
  27. }()
  28. var condition string
  29. var pars []interface{}
  30. condition = ` AND list_type =? AND status = 1 `
  31. pars = append(pars, listType)
  32. condition += " ORDER BY art.sort ASC "
  33. list, e := cygx.GetCygxBannerList(condition, pars, 0, 9999)
  34. if e != nil {
  35. err = errors.New("GetCygxBannerList" + e.Error())
  36. return
  37. }
  38. var itemsUpdate []*cygx.CygxBanner
  39. for k, v := range list {
  40. item := new(cygx.CygxBanner)
  41. item.BannerId = v.BannerId
  42. item.Sort = (k + 1) * 10
  43. itemsUpdate = append(itemsUpdate, item)
  44. }
  45. err = cygx.UpdateCygxBannerMulti(itemsUpdate)
  46. return
  47. }