activity_help_ask.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxActivityHelpAsk struct {
  7. AskId int `orm:"column(ask_id);pk" description:"带问id"`
  8. UserId int `description:"用户id"`
  9. ActivityId int `description:"活动id"`
  10. CreateTime time.Time `description:"创建时间"`
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司id"`
  14. CompanyName string `description:"公司名称"`
  15. Content string `description:"内容"`
  16. }
  17. // 添加优化建议
  18. func AddActivityHelpAsk(item *CygxActivityHelpAsk) (lastId int64, err error) {
  19. o := orm.NewOrm()
  20. lastId, err = o.Insert(item)
  21. return
  22. }
  23. type AddCygxActivityHelpAsk struct {
  24. ActivityId int `description:"活动id"`
  25. Content string `description:"内容"`
  26. }
  27. type CygxAskList struct {
  28. ReportOrActivityId int ` description:"对应的文章或者活动Id"`
  29. Title string `description:"标题"`
  30. Content string `description:"内容"`
  31. AskType string `description:"类型 Activity 活动 、Report 文章报告"`
  32. CreateTime string `description:"创建时间"`
  33. }
  34. type CygxAskListResp struct {
  35. List []*CygxAskList
  36. }
  37. //report_or_activity_id
  38. // 主题列表
  39. func GetActivityAskList(userId int) (items []*CygxAskList, err error) {
  40. o := orm.NewOrm()
  41. sql := `SELECT
  42. k.activity_id as report_or_activity_id,
  43. k.content,
  44. k.create_time,
  45. a.activity_name as title
  46. FROM
  47. cygx_activity_help_ask AS k
  48. INNER JOIN cygx_activity AS a ON a.activity_id = k.activity_id
  49. WHERE
  50. user_id = ? AND a.publish_status = 1 AND a.chart_permission_id = 31 ORDER BY k.ask_id DESC`
  51. _, err = o.Raw(sql, userId).QueryRows(&items)
  52. return
  53. }
  54. // 列表
  55. func GetArticleAskList(userId int) (items []*CygxAskList, err error) {
  56. o := orm.NewOrm()
  57. sql := `SELECT
  58. k.article_id as report_or_activity_id,
  59. k.content,
  60. k.create_time,
  61. a.title as title
  62. FROM
  63. cygx_article_ask AS k
  64. INNER JOIN cygx_article AS a ON a.article_id = k.article_id
  65. WHERE
  66. user_id = ? AND a.publish_status = 1 AND a.article_type_id > 0 ORDER BY k.ask_id DESC`
  67. _, err = o.Raw(sql, userId).QueryRows(&items)
  68. return
  69. }
  70. // 通过ID获取详情
  71. func GetCygxActivityHelpAskById(id int) (item *CygxActivityHelpAsk, err error) {
  72. sql := `SELECT * FROM cygx_activity_help_ask WHERE ask_id=? `
  73. err = orm.NewOrm().Raw(sql, id).QueryRow(&item)
  74. return
  75. }