activity_help_ask.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type ActivityHelpAsk struct {
  6. AskId int `orm:"column(ask_id);主键ID"`
  7. ActivityId int `description:"活动ID"`
  8. UserId int `description:"用户ID"`
  9. CreateTime string `description:"创建时间"`
  10. Mobile string `description:"手机号"`
  11. CompanyName string `description:"公司名称"`
  12. CompanyId int `description:"公司ID"`
  13. RealName string `description:"姓名"`
  14. Content string `description:"内容"`
  15. }
  16. type ActivityHelpAskListResp struct {
  17. List []*ActivityHelpAsk
  18. }
  19. // 列表
  20. func GetActivityHelpAskList(activityId int) (items []*ActivityHelpAsk, err error) {
  21. o := orm.NewOrmUsingDB("hz_cygx")
  22. sql := `SELECT k.*
  23. FROM cygx_activity_help_ask as k
  24. WHERE activity_id = ? ORDER BY create_time DESC`
  25. _, err = o.Raw(sql, activityId).QueryRows(&items)
  26. return
  27. }
  28. // 获取活动带问的用户的openID
  29. func GetActivityHelpAskOpenIdList(activityId int) (items []*OpenIdList, err error) {
  30. o := orm.NewOrmUsingDB("hz_cygx")
  31. var sql string
  32. sql = `SELECT DISTINCT
  33. u.open_id,
  34. u.cygx_user_id AS user_id
  35. FROM
  36. cygx_activity_help_ask AS m
  37. INNER JOIN cygx_user_record AS u ON u.cygx_bind_account = m.mobile
  38. AND u.cygx_user_id = m.user_id
  39. WHERE
  40. m.activity_id = ? `
  41. _, err = o.Raw(sql, activityId).QueryRows(&items)
  42. return
  43. }
  44. // 获取活动带问的用户的openID
  45. func GetMfyxActivityHelpAskOpenIdList(activityId int) (items []*OpenIdList, err error) {
  46. o := orm.NewOrmUsingDB("hz_cygx")
  47. var sql string
  48. sql = `SELECT DISTINCT
  49. u.open_id,
  50. u.cygx_user_id AS user_id
  51. FROM
  52. cygx_activity_help_ask AS m
  53. INNER JOIN cygx_mfyx_gzh_user_record AS u ON u.cygx_bind_account = m.mobile
  54. AND u.cygx_user_id = m.user_id
  55. WHERE
  56. m.activity_id = ? `
  57. _, err = o.Raw(sql, activityId).QueryRows(&items)
  58. return
  59. }