article_comment.go 2.8 KB

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