Files
nysoure/server/dao/statistic.go
2025-05-15 12:40:27 +02:00

25 lines
443 B
Go

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(&model.Statistic{
Key: key,
}).First(statistic).Error; err != nil {
return 0
}
return statistic.Value
}