cygx_yanxuan_special_follow.go 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxYanxuanSpecialFollow struct {
  7. CygxYanxuanSpecialFollowId int `orm:"column(cygx_yanxuan_special_follow_id);pk"`
  8. UserId int // 用户ID
  9. FollowUserId int // 被关注用户ID
  10. Mobile string // 手机号
  11. Email string // 邮箱
  12. CompanyId int // 公司ID
  13. CompanyName string // 公司名称
  14. RealName string // 用户实际名称
  15. SellerName string // 所属销售
  16. CreateTime time.Time // 创建时间
  17. ModifyTime time.Time // 修改时间
  18. RegisterPlatform int // 来源 1小程序,2:网页
  19. YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
  20. }
  21. type FollowCygxYanxuanSpecialReq struct {
  22. FollowSpecialColumnId int // 被关注的专栏栏目id
  23. Status int // 1关注2取消关注
  24. SpecialId int // 研选专栏Id
  25. }
  26. func AddCygxYanxuanSpecialFollow(item *CygxYanxuanSpecialFollow) (err error) {
  27. o := orm.NewOrm()
  28. _, err = o.Insert(item)
  29. return
  30. }
  31. func DelCygxYanxuanSpecialFollow(userId, followUserId int) (err error) {
  32. o := orm.NewOrm()
  33. sql := `DELETE FROM cygx_yanxuan_special_follow WHERE user_id=? AND follow_user_id=? `
  34. _, err = o.Raw(sql, userId, followUserId).Exec()
  35. return
  36. }
  37. func GetCygxYanxuanSpecialFollowOpenIdList(followUserId int) (items []*OpenIdList, err error) {
  38. o := orm.NewOrm()
  39. sql := `SELECT
  40. cr.*,
  41. c.user_id
  42. FROM
  43. user_record AS c
  44. INNER JOIN cygx_user_record AS cr ON cr.union_id = c.union_id
  45. INNER JOIN cygx_yanxuan_special_follow AS cf ON cf.user_id = c.user_id
  46. AND cf.follow_user_id = ?
  47. WHERE
  48. create_platform = 4 `
  49. _, err = o.Raw(sql, followUserId).QueryRows(&items)
  50. return
  51. }
  52. // 获取数量
  53. func GetCygxYanxuanSpecialFollowCount(condition string, pars []interface{}) (count int, err error) {
  54. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_follow as a WHERE 1= 1 `
  55. if condition != "" {
  56. sqlCount += condition
  57. }
  58. o := orm.NewOrm()
  59. err = o.Raw(sqlCount, pars).QueryRow(&count)
  60. return
  61. }
  62. // 获取数量判断用户是否关注专栏
  63. func GetCygxYanxuanSpecialFollowCountByUser(userId, followUserId int) (count int, err error) {
  64. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_follow as a WHERE user_id=? AND follow_user_id=? `
  65. o := orm.NewOrm()
  66. err = o.Raw(sqlCount, userId, followUserId).QueryRow(&count)
  67. return
  68. }