article_comment.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxArticleComment struct {
  7. Id int `orm:"column(id);pk" description:"留言id"`
  8. UserId int `description:"用户id"`
  9. RealName string `description:"用户姓名"`
  10. ArticleId int `description:"文章id"`
  11. ActivityId int `description:"活动id"`
  12. VideoId int `description:"视频id"`
  13. ActivityVoiceId int `description:"活动音频ID"`
  14. AskserieVideoId int `description:" 系列问答视频ID askserie_video_id"`
  15. IndustryId int `description:"产业id"`
  16. CreateTime time.Time `description:"创建时间"`
  17. Mobile string `description:"手机号"`
  18. Email string `description:"邮箱"`
  19. CompanyId int `description:"公司id"`
  20. CompanyName string `description:"公司名称"`
  21. Content string `description:"内容"`
  22. Title string `description:"标题"`
  23. }
  24. // 添加留言
  25. func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
  26. o := orm.NewOrm()
  27. lastId, err = o.Insert(item)
  28. return
  29. }
  30. type AddCygxArticleCommentReq struct {
  31. ArticleId int `description:"文章id"`
  32. Content string `description:"内容"`
  33. }
  34. // 我的留言列表
  35. func GetCommentList(userId int) (items []*CygxArticleComment, err error) {
  36. o := orm.NewOrm()
  37. sql := `SELECT
  38. c.*
  39. FROM
  40. cygx_article_comment AS c
  41. INNER JOIN cygx_article as a ON c.article_id = a.article_id
  42. WHERE
  43. user_id = ? AND a.article_type_id > 0 ORDER BY c.create_time DESC`
  44. _, err = o.Raw(sql, userId).QueryRows(&items)
  45. return
  46. }
  47. type CygxArticleCommentResp struct {
  48. Id int `orm:"column(id);pk" description:"留言id"`
  49. UserId int `description:"用户id"`
  50. ArticleId int `description:"文章id"`
  51. IndustryId int `description:"产业id"`
  52. ActivityId int `description:"活动id"`
  53. CreateTime time.Time `description:"创建时间"`
  54. Mobile string `description:"手机号"`
  55. Email string `description:"邮箱"`
  56. CompanyId int `description:"公司id"`
  57. CompanyName string `description:"公司名称"`
  58. Content string `description:"内容"`
  59. Title string `description:"标题"`
  60. RedirectType int `description:"跳转类型 1文章 2活动 3产业资源包"`
  61. IsCollect bool `description:"是否收藏:true,已收藏,false:未收藏"`
  62. IsRoadShow bool `description:"是否是路演精华"`
  63. }
  64. type CygxCommentListResp struct {
  65. List []*CygxArticleCommentResp
  66. }
  67. // 通过ID获取详情
  68. func GetArticleCommentById(id int) (item *CygxArticleCommentResp, err error) {
  69. sql := `SELECT * FROM cygx_article_comment WHERE id=? `
  70. err = orm.NewOrm().Raw(sql, id).QueryRow(&item)
  71. return
  72. }
  73. type CygxArticleCommentWxResp struct {
  74. Content string `description:"内容"`
  75. SourceId int `description:"跳转ID"`
  76. RedirectType int `description:"跳转类型 1文章 2活动 3产业资源包"`
  77. }