package services

import (
	"errors"
	"fmt"
	"hongze/hongze_cygx/models"
	"hongze/hongze_cygx/utils"
	"time"
)

//func init() {
//	fmt.Println(GetQuestionnaireButtonIsShow())
//}

// 获取研选问卷调查按钮是否展示
func GetQuestionnaireButtonIsShow() (isShow bool) {
	var err error
	defer func() {
		if err != nil {
			fmt.Println(err)
			go utils.SendAlarmMsg("约访专家的请求失败"+err.Error(), 2)
		}
	}()
	var condition string
	var pars []interface{}
	condition += ` AND end_time >= ? `
	pars = append(pars, time.Now().Format(utils.FormatDate))
	total, e := models.GetCygxQuestionnaireCount(condition, pars)
	if e != nil {
		err = errors.New("GetCygxQuestionnaireCount, Err: " + e.Error())
		return
	}
	if total > 0 {
		isShow = true
	}
	return
}
