package services

import (
	"errors"
	"fmt"
	"hongze/hongze_clpt/models"
	"hongze/hongze_clpt/utils"
)

// GetXzsChooseCategoryZhouqiMapByMobile 根据手机号获取周期分类的关注信息
func GetXzsChooseCategoryZhouqiMapByMobile(mobile string) (mapResp map[int]bool, mapFollowResp map[int]int) {
	if mobile == "" {
		return
	}
	var err error
	defer func() {
		if err != nil {
			fmt.Println("err:", err)
			go utils.SendAlarmMsg(fmt.Sprint("更新周期对应分类下所管理文章的更新时间 失败,GetXzsChooseCategoryZhouqiMapByMobile Err:"+err.Error()+"mobile", mobile), 3)
		}
	}()

	listFollw, e := models.GetCygxXzsChooseCategoryZhouqiList(mobile)
	if e != nil {
		err = errors.New("GetCygxZhouqiArticleMapByParentId, Err: " + err.Error())
		return
	}
	mapResp = make(map[int]bool, 0)
	mapFollowResp = make(map[int]int, 0)
	for _, v := range listFollw {
		mapResp[v.CategoryId] = true
		mapFollowResp[v.CategoryId] = v.FollowType
	}
	return
}