cygx_yanxuan_special_message_like.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // 留言点赞
  7. type CygxYanxuanSpecialMessageLike struct {
  8. MessageLikeId int `orm:"column(message_like_id);pk"`
  9. MessageId int `comment:"留言消息ID"`
  10. UserId int `comment:"用户ID"`
  11. Mobile string `comment:"手机号"`
  12. Email string `comment:"邮箱"`
  13. CompanyId int `comment:"公司ID"`
  14. CompanyName string `comment:"公司名称"`
  15. RealName string `comment:"用户实际名称"`
  16. RegisterPlatform int `comment:"来源 1小程序,2:网页,5买方研选小程序,6:买方研选网页版"`
  17. CreateTime time.Time `comment:"创建时间"`
  18. ModifyTime time.Time `comment:"修改时间"`
  19. }
  20. // 新增
  21. func AddCygxYanxuanSpecialMessageLike(item *CygxYanxuanSpecialMessageLike) (err error) {
  22. o := orm.NewOrm()
  23. _, err = o.Insert(item)
  24. return
  25. }
  26. // 删除
  27. func DeleteCygxYanxuanSpecialMessageLike(userId, messageId int) (err error) {
  28. o := orm.NewOrm()
  29. sql := ` DELETE FROM cygx_yanxuan_special_message WHERE WHERE user_id = ? AND message_id = ? `
  30. _, err = o.Raw(sql, userId, messageId).Exec()
  31. return
  32. }
  33. // 获取数量
  34. func GetCygxYanxuanSpecialMessageLikeCountByUidMid(userId, messageId int) (count int, err error) {
  35. o := orm.NewOrm()
  36. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_message_like WHERE user_id = ? AND message_id = ? `
  37. err = o.Raw(sqlCount, userId, messageId).QueryRow(&count)
  38. return
  39. }
  40. func GetCygxYanxuanSpecialMessageLikeList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialMessageLike, err error) {
  41. o := orm.NewOrm()
  42. sql := `SELECT *
  43. FROM
  44. cygx_yanxuan_special_message_like
  45. WHERE 1 = 1 ` + condition
  46. sql += ` LIMIT ?,? `
  47. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  48. return
  49. }
  50. // GetCygxYanxuanSpecialMessageLikeByUser 根据用户ID获取所有点赞留言
  51. func GetCygxYanxuanSpecialMessageLikeByUser(userId int) (items []*CygxYanxuanSpecialMessageLike, err error) {
  52. o := orm.NewOrm()
  53. sql := `SELECT message_id FROM cygx_yanxuan_special_message_like WHERE 1 =1 AND user_id =? `
  54. _, err = o.Raw(sql, userId).QueryRows(&items)
  55. return
  56. }