package models import ( "github.com/beego/beego/v2/client/orm" ) type CygxActivityMirrorWord struct { Id int `description:"id"` KeyWord string `description:"关键词"` MirrorKeyWord string `description:"关键词"` } type ActivityMirrorWordListResp struct { List []*CygxActivityMirrorWord } //列表 func GetActivityMirrorWordList() (items []*ActivityFastsearchKeywords, err error) { o := orm.NewOrm() sql := `SELECT * FROM cygx_activity_mirror_word ORDER BY sort DESC` _, err = o.Raw(sql).QueryRows(&items) return } //获取镜像词数量 func GetActivityMirrorWordCount(keyWord string) (count int, err error) { o := orm.NewOrm() sqlCount := ` SELECT COUNT( 1 ) AS count FROM cygx_activity_mirror_word WHERE key_word IN (` + keyWord + `) ` err = o.Raw(sqlCount).QueryRow(&count) return } func GetMirrorWord(keyWord string) (mirrorword string, err error) { sql := ` SELECT GROUP_CONCAT( DISTINCT m.mirror_key_word SEPARATOR ',' ) AS mirrorword FROM cygx_activity_mirror_word AS m WHERE m.key_word IN (` + keyWord + `)` o := orm.NewOrm() err = o.Raw(sql).QueryRow(&mirrorword) return }