activity_mirror_word.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type CygxActivityMirrorWord struct {
  6. Id int `description:"id"`
  7. KeyWord string `description:"关键词"`
  8. MirrorKeyWord string `description:"关键词"`
  9. }
  10. type ActivityMirrorWordListResp struct {
  11. List []*CygxActivityMirrorWord
  12. }
  13. //列表
  14. func GetActivityMirrorWordList() (items []*ActivityFastsearchKeywords, err error) {
  15. o := orm.NewOrm()
  16. sql := `SELECT * FROM cygx_activity_mirror_word ORDER BY sort DESC`
  17. _, err = o.Raw(sql).QueryRows(&items)
  18. return
  19. }
  20. //获取镜像词数量
  21. func GetActivityMirrorWordCount(keyWord string) (count int, err error) {
  22. o := orm.NewOrm()
  23. sqlCount := ` SELECT COUNT( 1 ) AS count FROM cygx_activity_mirror_word WHERE key_word IN (` + keyWord + `) `
  24. err = o.Raw(sqlCount).QueryRow(&count)
  25. return
  26. }
  27. func GetMirrorWord(keyWord string) (mirrorword string, err error) {
  28. sql := ` SELECT GROUP_CONCAT( DISTINCT m.mirror_key_word SEPARATOR ',' ) AS mirrorword
  29. FROM
  30. cygx_activity_mirror_word AS m
  31. WHERE m.key_word IN (` + keyWord + `)`
  32. o := orm.NewOrm()
  33. err = o.Raw(sql).QueryRow(&mirrorword)
  34. return
  35. }