statistics.go 840 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package models
  2. import (
  3. "html/template"
  4. "strconv"
  5. "time"
  6. )
  7. type Statistics struct {
  8. ID uint `gorm:"primary_key,column:cpu"`
  9. CPU uint `gorm:"column:cpu"`
  10. Likes uint `gorm:"column:likes"`
  11. Sales uint `gorm:"column:sales"`
  12. NewMembers uint `gorm:"column:new_members"`
  13. CreatedAt time.Time
  14. UpdatedAt time.Time
  15. }
  16. func FirstStatics() *Statistics {
  17. s := new(Statistics)
  18. orm.First(s)
  19. return s
  20. }
  21. func (s *Statistics) CPUTmpl() template.HTML {
  22. return template.HTML(strconv.Itoa(int(s.CPU)))
  23. }
  24. func (s *Statistics) LikesTmpl() template.HTML {
  25. return template.HTML(strconv.Itoa(int(s.Likes)))
  26. }
  27. func (s *Statistics) SalesTmpl() template.HTML {
  28. return template.HTML(strconv.Itoa(int(s.Sales)))
  29. }
  30. func (s *Statistics) NewMembersTmpl() template.HTML {
  31. return template.HTML(strconv.Itoa(int(s.NewMembers)))
  32. }