package cygx

import (
	"errors"
	"fmt"
	"hongze/hz_crm_api/models/cygx"
	"hongze/hz_crm_api/services/alarm_msg"
	"hongze/hz_crm_api/utils"
)

//func init() {
//	fmt.Println(GetCygxMorningMeetingReviewChapterHistoryPvUvMap([]int{111}))
//}

// 根据ID获取pvUv
func GetCygxMorningMeetingReviewChapterHistoryPvUvMap(articleIdArr []int) (mapPvResp, mapUvResp map[int]int) {
	lenArr := len(articleIdArr)
	if lenArr == 0 {
		return
	}
	var err error
	defer func() {
		if err != nil {
			fmt.Println(err)
			go alarm_msg.SendAlarmMsg("根据文章ID获取文章行业分类，信息失败，GetCygxArticlePerssionNameListMap Err："+err.Error(), 3)
		}
	}()
	var condition string
	var pars []interface{}

	condition = ` AND  meeting_id IN (` + utils.GetOrmInReplace(lenArr) + `)`
	pars = append(pars, articleIdArr)
	list, e := cygx.GetCygxMorningMeetingReviewChapterHistoryPvUv(condition, pars)
	if e != nil && e.Error() != utils.ErrNoRow() {
		err = errors.New("GetArticlList, Err: " + e.Error())
		return
	}
	mapPvResp = make(map[int]int, 0)
	mapUvResp = make(map[int]int, 0)
	for _, v := range list {
		mapPvResp[v.ArticleId] = v.Pv
		mapUvResp[v.ArticleId] = v.Uv
	}
	return
}
