|
@@ -17,14 +17,14 @@ type CygxSearchKeyWord struct {
|
|
|
RealName string `description:"用户实际名称"`
|
|
|
}
|
|
|
|
|
|
-//新增搜索
|
|
|
+// 新增搜索
|
|
|
func AddSearchKeyWord(item *CygxSearchKeyWord) (lastId int64, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
lastId, err = o.Insert(item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取用户搜索这个关键词的最新时间
|
|
|
+// 获取用户搜索这个关键词的最新时间
|
|
|
func GetNewSearchKeyWordByThisUser(uid int, keyWord string) (item *CygxSearchKeyWord, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
sql := `SELECT * FROM cygx_search_key_word WHERE user_id = ? AND key_word = ? ORDER BY id DESC LIMIT 1 `
|
|
@@ -32,11 +32,11 @@ func GetNewSearchKeyWordByThisUser(uid int, keyWord string) (item *CygxSearchKey
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//获取用户搜索词汇频率较高的词
|
|
|
-func GetSearchKeyWordTop() (items []*CygxSearchKeyWord, err error) {
|
|
|
+// 获取用户搜索词汇频率较高的词
|
|
|
+func GetSearchKeyWordTop(condition string, pars []interface{}) (items []*CygxSearchKeyWord, err error) {
|
|
|
o := orm.NewOrm()
|
|
|
- sql := `SELECT key_word, COUNT(*) AS num FROM cygx_search_key_word GROUP BY key_word ORDER BY num DESC LIMIT 8 `
|
|
|
- _, err = o.Raw(sql).QueryRows(&items)
|
|
|
+ sql := `SELECT key_word, COUNT(*) AS num FROM cygx_search_key_word WHERE 1=1 ` + condition + ` GROUP BY key_word ORDER BY num DESC LIMIT 12 `
|
|
|
+ _, err = o.Raw(sql, pars).QueryRows(&items)
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -47,7 +47,7 @@ func GetCygxSearchKeyWordList(condition string) (items []*CygxSearchKeyWord, err
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-//修改用户搜索的相关信息
|
|
|
+// 修改用户搜索的相关信息
|
|
|
func UpdateCygxSearchKeyWord(wxUser *WxUserItem) (err error) {
|
|
|
o := orm.NewOrm()
|
|
|
var sql string
|