activity_help_ask.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 CygxActivityHelpAsk struct {
  8. AskId int `orm:"column(ask_id);pk" description:"带问id"`
  9. UserId int `description:"用户id"`
  10. ActivityId int `description:"活动id"`
  11. CreateTime time.Time `description:"创建时间"`
  12. Mobile string `description:"手机号"`
  13. Email string `description:"邮箱"`
  14. CompanyId int `description:"公司id"`
  15. CompanyName string `description:"公司名称"`
  16. Content string `description:"内容"`
  17. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  18. }
  19. // 添加优化建议
  20. func AddActivityHelpAsk(item *CygxActivityHelpAsk) (lastId int64, err error) {
  21. o := orm.NewOrm()
  22. lastId, err = o.Insert(item)
  23. return
  24. }
  25. type AddCygxActivityHelpAsk struct {
  26. ActivityId int `description:"活动id"`
  27. Content string `description:"内容"`
  28. }
  29. type CygxAskList struct {
  30. ReportOrActivityId int ` description:"对应的文章或者活动Id"`
  31. Title string `description:"标题"`
  32. Content string `description:"内容"`
  33. AskType string `description:"类型 Activity 活动 、Report 文章报告"`
  34. CreateTime string `description:"创建时间"`
  35. }
  36. type CygxAskListResp struct {
  37. List []*CygxAskList
  38. Paging *paging.PagingItem
  39. }
  40. //report_or_activity_id
  41. // 主题列表
  42. func GetActivityAskList(userId, startSize, pageSize int) (items []*CygxAskList, err error) {
  43. o := orm.NewOrm()
  44. sql := `SELECT
  45. k.activity_id as report_or_activity_id,
  46. k.content,
  47. k.create_time,
  48. a.activity_name as title
  49. FROM
  50. cygx_activity_help_ask AS k
  51. INNER JOIN cygx_activity AS a ON a.activity_id = k.activity_id
  52. WHERE
  53. user_id = ? AND a.publish_status = 1 AND a.chart_permission_id = 31 ORDER BY k.ask_id DESC LIMIT ?,? `
  54. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  55. return
  56. }
  57. // 主题列表
  58. func GetActivityAskCount(userId int) (count int, err error) {
  59. o := orm.NewOrm()
  60. sql := `SELECT
  61. COUNT( 1 ) as count
  62. FROM
  63. cygx_activity_help_ask AS k
  64. INNER JOIN cygx_activity AS a ON a.activity_id = k.activity_id
  65. WHERE
  66. user_id = ? AND a.publish_status = 1 AND a.chart_permission_id = 31 ORDER BY k.ask_id DESC `
  67. err = o.Raw(sql, userId).QueryRow(&count)
  68. return
  69. }
  70. // 列表
  71. func GetArticleAskList(userId int) (items []*CygxAskList, err error) {
  72. o := orm.NewOrm()
  73. sql := `SELECT
  74. k.article_id as report_or_activity_id,
  75. k.content,
  76. k.create_time,
  77. a.title as title
  78. FROM
  79. cygx_article_ask AS k
  80. INNER JOIN cygx_article AS a ON a.article_id = k.article_id
  81. WHERE
  82. user_id = ? AND a.publish_status = 1 AND a.article_type_id > 0 ORDER BY k.ask_id DESC`
  83. _, err = o.Raw(sql, userId).QueryRows(&items)
  84. return
  85. }
  86. type AskEmailRep struct {
  87. Name string `description:"姓名"`
  88. Email string `description:"邮箱"`
  89. Mobile string `description:"手机号"`
  90. }
  91. func GetAskEmail() (item []*AskEmailRep, err error) {
  92. o := orm.NewOrm()
  93. sql := `SELECT * FROM cygx_activity_ask_email`
  94. _, err = o.Raw(sql).QueryRows(&item)
  95. return
  96. }