xzs_choose_category_zhouqi.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxXzsChooseCategoryZhouqi struct {
  7. Id int `orm:"column(id);pk"`
  8. UserId int `description:"用户ID"`
  9. Mobile string `description:"手机号"`
  10. Email string `description:"邮箱"`
  11. CompanyId int `description:"公司id"`
  12. CompanyName string `description:"公司名称"`
  13. RealName string `description:"用户实际名称"`
  14. CategoryId int `description:"cygx_zhouqi_article_map 表主键"`
  15. CreateTime time.Time `description:"创建时间"`
  16. ModifyTime time.Time `description:"更新时间"`
  17. }
  18. // 根据手机号获取用户关注的产业
  19. func GetCygxXzsChooseCategoryZhouqiList(mobile string) (items []*CygxXzsChooseCategoryZhouqi, err error) {
  20. o := orm.NewOrm()
  21. sql := `SELECT * FROM cygx_xzs_choose_category_zhouqi WHERE mobile = ?`
  22. _, err = o.Raw(sql, mobile).QueryRows(&items)
  23. return
  24. }
  25. // 添加
  26. func AddCygxCategoryFllowZhouqi(item *CygxXzsChooseCategoryZhouqi) (lastId int64, err error) {
  27. o := orm.NewOrm()
  28. lastId, err = o.Insert(item)
  29. return
  30. }
  31. // 删除
  32. func RemoveCygxCategoryFllowZhouqi(mobile string, CategoryId int) (err error) {
  33. o := orm.NewOrm()
  34. sql := `DELETE FROM cygx_xzs_choose_category_zhouqi WHERE mobile=? AND category_id=? `
  35. _, err = o.Raw(sql, mobile, CategoryId).Exec()
  36. return
  37. }
  38. // 获取关注数量
  39. func GetCountCategoryFllowZhouqi(categoryId int, mobile string) (count int, err error) {
  40. sql := `SELECT COUNT(1) AS count FROM cygx_xzs_choose_category_zhouqi WHERE mobile=? AND category_id=? `
  41. err = orm.NewOrm().Raw(sql, mobile, categoryId).QueryRow(&count)
  42. return
  43. }
  44. type XzsChooseMapZhouqiResp struct {
  45. Id int `description:"id"`
  46. CategoryId int `description:"权益文章对应分类,cygx_article"`
  47. CharPpermissionName string `description:"权限名称"`
  48. MatchTypeName string `description:"分类名称"`
  49. }