user_freee_button.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxUserFreeeButton struct {
  7. Id int `orm:"column(id);pk"`
  8. UserId int `description:"用户id"`
  9. CompanyId int `description:"公司id"`
  10. CreateTime time.Time `description:"创建时间"`
  11. ModifyTime time.Time `description:"修改时间"`
  12. EffectiveTime string `description:"有效隐藏时间"`
  13. }
  14. //添加历史信息
  15. func AddCygxUserFreeeButton(item *CygxUserFreeeButton) (lastId int64, err error) {
  16. o := orm.NewOrm()
  17. item.ModifyTime = time.Now()
  18. lastId, err = o.Insert(item)
  19. return
  20. }
  21. //更新当天隐藏时间
  22. func UpdateCygxUserFreeeButton(userId int) (err error) {
  23. o := orm.NewOrm()
  24. msql := ` UPDATE cygx_user_freee_button SET effective_time = NOW() ,modify_time = NOW() WHERE user_id = ? `
  25. _, err = o.Raw(msql, userId).Exec()
  26. return
  27. }
  28. func CountCygxUserFreeeButton(userId int) (count int, err error) {
  29. o := orm.NewOrm()
  30. sql := `SELECT COUNT(1) AS count FROM cygx_user_freee_button WHERE user_id = ? AND effective_time = date_format(now(),'%Y-%m-%d')`
  31. err = o.Raw(sql, userId).QueryRow(&count)
  32. return
  33. }
  34. func CountCygxUserFreeeButtonByUser(userId int) (count int, err error) {
  35. o := orm.NewOrm()
  36. sql := `SELECT COUNT(1) AS count FROM cygx_user_freee_button WHERE user_id = ? `
  37. err = o.Raw(sql, userId).QueryRow(&count)
  38. return
  39. }