package cygx

import (
	"github.com/beego/beego/v2/client/orm"
)

type ActivityFastsearchKeywords struct {
	Id      int    `description:"活动类型id"`
	KeyWord string `description:"关键词"`
}

type ActivityFastsearchKeywordsResp struct {
	KeyWord    string            `description:"关键词(标签)"`
	MirrorWord string            `description:"关键词的镜像词"`
	ListWords  []*MirrorWordResp `description:"关键词的镜像词列表(公司)"`
}

type MirrorWordResp struct {
	MirrorWord string `description:"关键词的镜像词(公司)"`
}

type FastsearchKeyType struct {
	KeyType string `description:"关键词类型 ‘活动:Activity’,’纪要:Summary'"`
}

type ActivityFastsearchKeywordsListResp struct {
	List []*ActivityFastsearchKeywordsResp
}

// 列表
func GetActivityFastsearchKeywordsList() (items []*ActivityFastsearchKeywordsResp, err error) {
	o := orm.NewOrmUsingDB("hz_cygx")
	sql := `SELECT f.*,
			GROUP_CONCAT( DISTINCT m.key_word SEPARATOR ',' ) AS mirror_word 
			FROM
			cygx_activity_fastsearch_keywords AS f
			LEFT JOIN cygx_activity_mirror_word AS m ON m.mirror_key_word = f.key_word 
			GROUP BY f.id 
			ORDER BY f.sort DESC`
	_, err = o.Raw(sql).QueryRows(&items)
	return
}