package cygx import ( "errors" "fmt" "hongze/hz_crm_api/models/cygx" "hongze/hz_crm_api/services/alarm_msg" ) func GetCygxBannerTypeMap() (mapResp map[int]string) { mapResp = make(map[int]string, 0) mapResp[1] = "现有报告" mapResp[2] = "自拟报告" mapResp[3] = "视频" mapResp[4] = "音频" mapResp[5] = "活动" return } //func init() { // UpdateBannerSort("B") //} // 批量更新某一列的数据 func UpdateBannerSort(listType string) (err error) { defer func() { if err != nil { fmt.Println(err) go alarm_msg.SendAlarmMsg("获取产品内测的阅读数据,信息失败,Err:"+err.Error(), 3) } }() var condition string var pars []interface{} condition = ` AND list_type =? AND status = 1 ` pars = append(pars, listType) condition += " ORDER BY art.sort ASC " list, e := cygx.GetCygxBannerList(condition, pars, 0, 9999) if e != nil { err = errors.New("GetCygxBannerList" + e.Error()) return } var itemsUpdate []*cygx.CygxBanner for k, v := range list { item := new(cygx.CygxBanner) item.BannerId = v.BannerId item.Sort = (k + 1) * 10 itemsUpdate = append(itemsUpdate, item) } err = cygx.UpdateCygxBannerMulti(itemsUpdate) return }