search_key_word.go 684 B

12345678910111213141516171819202122232425262728
  1. package models
  2. import (
  3. "rdluck_tools/orm"
  4. "time"
  5. )
  6. type CygxSearchKeyWord struct {
  7. Id int `orm:"column(id);" description:"id"`
  8. KeyWord string
  9. UserId int
  10. CreateTime time.Time
  11. }
  12. //新增文章
  13. func AddSearchKeyWord(item *CygxSearchKeyWord) (lastId int64, err error) {
  14. o := orm.NewOrm()
  15. lastId, err = o.Insert(item)
  16. return
  17. }
  18. //获取用户搜索这个关键词的最新时间
  19. func GetNewSearchKeyWordByThisUser(uid int, keyWord string) (item *CygxSearchKeyWord, err error) {
  20. o := orm.NewOrm()
  21. sql := `SELECT * FROM cygx_search_key_word WHERE user_id = ? AND key_word = ? ORDER BY id DESC LIMIT 1 `
  22. err = o.Raw(sql, uid, keyWord).QueryRow(&item)
  23. return
  24. }