cygx_yanxuan_special_collect.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxYanxuanSpecialCollect struct {
  7. CygxYanxuanSpecialCollectId int `orm:"column(cygx_yanxuan_special_collect_id);pk"`
  8. UserId int // 用户ID
  9. Mobile string // 手机号
  10. Email string // 邮箱
  11. CompanyId int // 公司ID
  12. CompanyName string // 公司名称
  13. RealName string // 用户实际名称
  14. SellerName string // 所属销售
  15. CreateTime time.Time // 创建时间
  16. ModifyTime time.Time // 修改时间
  17. RegisterPlatform int // 来源 1小程序,2:网页
  18. YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
  19. }
  20. func AddCygxYanxuanSpecialCollect(item *CygxYanxuanSpecialCollect) (lastId int64, err error) {
  21. o := orm.NewOrm()
  22. lastId, err = o.Insert(item)
  23. return
  24. }
  25. type CollectCygxYanxuanSpecialReq struct {
  26. Id int // 文章id
  27. Status int // 1收藏2取消收藏
  28. }
  29. func DelCygxYanxuanSpecialCollect(userId, articleId int) (err error) {
  30. o := orm.NewOrm()
  31. sql := `DELETE FROM cygx_yanxuan_special_collect WHERE user_id=? AND yanxuan_special_id=? `
  32. _, err = o.Raw(sql, userId, articleId).Exec()
  33. return
  34. }
  35. // 获取数量
  36. func GetCygxYanxuanSpecialCollectCount(condition string, pars []interface{}) (count int, err error) {
  37. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_collect as a WHERE 1= 1 `
  38. if condition != "" {
  39. sqlCount += condition
  40. }
  41. o := orm.NewOrm()
  42. err = o.Raw(sqlCount, pars).QueryRow(&count)
  43. return
  44. }