mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 20:27:23 +00:00
Initial commit
This commit is contained in:
22
server/dao/statistic.go
Normal file
22
server/dao/statistic.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package dao
|
||||
|
||||
import "nysoure/server/model"
|
||||
|
||||
func SetStatistic(key string, value int64) error {
|
||||
statistic := &model.Statistic{
|
||||
Key: key,
|
||||
Value: value,
|
||||
}
|
||||
if err := db.Save(statistic).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetStatistic(key string) int64 {
|
||||
statistic := &model.Statistic{}
|
||||
if err := db.Where("key = ?", key).First(statistic).Error; err != nil {
|
||||
return 0
|
||||
}
|
||||
return statistic.Value
|
||||
}
|
Reference in New Issue
Block a user