cygx_yanxuan_special_follow.go 3.2 KB

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