xzs_choose_category.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxXzsChooseCategory 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_article"`
  15. CreateTime time.Time `description:"创建时间"`
  16. ModifyTime time.Time `description:"更新时间"`
  17. IdCygx int `description:"cygx_report_mapping_cygx 表主键ID"`
  18. }
  19. // 根据手机号获取用户关注的产业
  20. func GetCygxXzsChooseCategoryList(mobile string) (items []*CygxXzsChooseCategory, err error) {
  21. o := orm.NewOrm()
  22. sql := `SELECT * FROM cygx_xzs_choose_category WHERE mobile = ?`
  23. _, err = o.Raw(sql, mobile).QueryRows(&items)
  24. return
  25. }
  26. // 添加
  27. func AddCygxCategoryFllow(item *CygxXzsChooseCategory) (lastId int64, err error) {
  28. o := orm.NewOrm()
  29. lastId, err = o.Insert(item)
  30. return
  31. }
  32. // 删除
  33. func RemoveCygxCategoryFllow(mobile string, CategoryId int) (err error) {
  34. o := orm.NewOrm()
  35. sql := `DELETE FROM cygx_xzs_choose_category WHERE mobile=? AND category_id=? `
  36. _, err = o.Raw(sql, mobile, CategoryId).Exec()
  37. return
  38. }
  39. // 根据手机号获取用户关注的产业
  40. func GetCygxXzsChooseCategoryWhithIdCygxList() (items []*CygxXzsChooseCategory, err error) {
  41. o := orm.NewOrm()
  42. sql := `SELECT * FROM cygx_xzs_choose_category WHERE id_cygx = 0`
  43. _, err = o.Raw(sql).QueryRows(&items)
  44. return
  45. }
  46. type XzsChooseMapResp struct {
  47. Id int `description:"id"`
  48. CategoryId int `description:"权益文章对应分类,cygx_article"`
  49. CharPpermissionName string `description:"权限名称"`
  50. MatchTypeName string `description:"分类名称"`
  51. }
  52. // 根据手机号获取用户关注的产业
  53. func GetCygxXzsChooseCategoryMapList() (items []*XzsChooseMapResp, err error) {
  54. o := orm.NewOrm()
  55. sql := `SELECT
  56. r.id,
  57. r.chart_permission_name,
  58. r.match_type_name,
  59. c.category_id
  60. FROM
  61. cygx_report_mapping_cygx AS r
  62. INNER JOIN cygx_report_mapping_group AS p ON p.id_cygx = r.id
  63. INNER JOIN cygx_report_mapping_celue AS c ON c.category_id = p.category_id_celue
  64. WHERE
  65. r.chart_permission_id IN (23,100000)`
  66. _, err = o.Raw(sql).QueryRows(&items)
  67. return
  68. }
  69. // 修改数据
  70. func UpdateCygxXzsChooseCategory(idCygx, id int) (err error) {
  71. o := orm.NewOrm()
  72. sql := `UPDATE cygx_xzs_choose_category SET id_cygx=? WHERE id=? `
  73. _, err = o.Raw(sql, idCygx, id).Exec()
  74. return
  75. }