|
|
|
@@ -0,0 +1,32 @@ |
|
|
|
package models |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
|
|
|
|
"code.gitea.io/gitea/modules/log" |
|
|
|
"code.gitea.io/gitea/modules/timeutil" |
|
|
|
) |
|
|
|
|
|
|
|
type SearchRecord struct { |
|
|
|
ID int64 `xorm:"pk"` |
|
|
|
//user |
|
|
|
Keyword string `xorm:"NOT NULL"` |
|
|
|
// |
|
|
|
CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"` |
|
|
|
} |
|
|
|
|
|
|
|
func SaveSearchKeywordToDb(keyword string) error { |
|
|
|
record := &SearchRecord{ |
|
|
|
Keyword: keyword, |
|
|
|
} |
|
|
|
sess := x.NewSession() |
|
|
|
defer sess.Close() |
|
|
|
|
|
|
|
re, err := sess.Insert(record) |
|
|
|
if err != nil { |
|
|
|
log.Info("insert error." + err.Error()) |
|
|
|
return err |
|
|
|
} |
|
|
|
log.Info("success to save db.re=" + fmt.Sprint((re))) |
|
|
|
return nil |
|
|
|
} |