xzs_choose_category.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 GetCygxXzsChooseCategoryListByCon(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxXzsChooseCategory, err error) {
  28. o := orm.NewOrm()
  29. sql := `SELECT * FROM cygx_xzs_choose_category as art WHERE 1= 1 `
  30. if condition != "" {
  31. sql += condition
  32. }
  33. //sql += ` LIMIT ?,? `
  34. _, err = o.Raw(sql, pars).QueryRows(&items)
  35. return
  36. }
  37. // 添加
  38. func AddCygxCategoryFllow(item *CygxXzsChooseCategory) (lastId int64, err error) {
  39. o := orm.NewOrm()
  40. lastId, err = o.Insert(item)
  41. return
  42. }
  43. // 删除
  44. func RemoveCygxCategoryFllow(mobile string, CategoryId int) (err error) {
  45. o := orm.NewOrm()
  46. sql := `DELETE FROM cygx_xzs_choose_category WHERE mobile=? AND category_id=? `
  47. _, err = o.Raw(sql, mobile, CategoryId).Exec()
  48. return
  49. }
  50. // 根据手机号获取用户关注的产业
  51. func GetCygxXzsChooseCategoryWhithIdCygxList() (items []*CygxXzsChooseCategory, err error) {
  52. o := orm.NewOrm()
  53. sql := `SELECT * FROM cygx_xzs_choose_category WHERE id_cygx = 0`
  54. _, err = o.Raw(sql).QueryRows(&items)
  55. return
  56. }
  57. type XzsChooseMapResp struct {
  58. Id int `description:"id"`
  59. CategoryId int `description:"权益文章对应分类,cygx_article"`
  60. CharPpermissionName string `description:"权限名称"`
  61. MatchTypeName string `description:"分类名称"`
  62. }
  63. // 根据手机号获取用户关注的产业
  64. func GetCygxXzsChooseCategoryMapList() (items []*XzsChooseMapResp, err error) {
  65. o := orm.NewOrm()
  66. sql := `SELECT
  67. r.id,
  68. r.chart_permission_name,
  69. r.match_type_name,
  70. c.category_id
  71. FROM
  72. cygx_report_mapping_cygx AS r
  73. INNER JOIN cygx_report_mapping_group AS p ON p.id_cygx = r.id
  74. INNER JOIN cygx_report_mapping_celue AS c ON c.category_id = p.category_id_celue
  75. WHERE
  76. r.chart_permission_id IN (23,100000)`
  77. _, err = o.Raw(sql).QueryRows(&items)
  78. return
  79. }
  80. // 修改数据
  81. func UpdateCygxXzsChooseCategory(idCygx, id int) (err error) {
  82. o := orm.NewOrm()
  83. sql := `UPDATE cygx_xzs_choose_category SET id_cygx=? WHERE id=? `
  84. _, err = o.Raw(sql, idCygx, id).Exec()
  85. return
  86. }