article_comment.go 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 CygxArticleComment struct {
  8. Id int `orm:"column(id);pk" description:"留言id"`
  9. UserId int `description:"用户id"`
  10. RealName string `description:"用户姓名"`
  11. ArticleId int `description:"文章id"`
  12. ActivityId int `description:"活动id"`
  13. VideoId int `description:"视频id"`
  14. ActivityVoiceId int `description:"活动音频ID"`
  15. AskserieVideoId int `description:" 系列问答视频ID askserie_video_id"`
  16. IndustryId int `description:"产业id"`
  17. CreateTime time.Time `description:"创建时间"`
  18. Mobile string `description:"手机号"`
  19. Email string `description:"邮箱"`
  20. CompanyId int `description:"公司id"`
  21. CompanyName string `description:"公司名称"`
  22. Content string `description:"内容"`
  23. Title string `description:"标题"`
  24. }
  25. // 添加留言
  26. func AddArticleComment(item *CygxArticleComment) (lastId int64, err error) {
  27. o := orm.NewOrm()
  28. lastId, err = o.Insert(item)
  29. return
  30. }
  31. type AddCygxArticleCommentReq struct {
  32. ArticleId int `description:"文章id"`
  33. Content string `description:"内容"`
  34. }
  35. // 我的留言列表
  36. func GetCommentList(userId, startSize, pageSize int) (items []*CygxArticleComment, err error) {
  37. o := orm.NewOrm()
  38. sql := `SELECT
  39. c.*
  40. FROM
  41. cygx_article_comment AS c
  42. INNER JOIN cygx_article as a ON c.article_id = a.article_id
  43. WHERE
  44. user_id = ? AND a.article_type_id > 0 ORDER BY c.create_time DESC LIMIT ?,? `
  45. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  46. return
  47. }
  48. // 我的留言列表
  49. func GetCommentListCount(userId int) (count int, err error) {
  50. o := orm.NewOrm()
  51. sql := `SELECT
  52. COUNT( 1 ) as count
  53. FROM
  54. cygx_article_comment AS c
  55. INNER JOIN cygx_article as a ON c.article_id = a.article_id
  56. WHERE
  57. user_id = ? AND a.article_type_id > 0 `
  58. err = o.Raw(sql, userId).QueryRow(&count)
  59. return
  60. }
  61. type CygxArticleCommentResp struct {
  62. Id int `orm:"column(id);pk" description:"留言id"`
  63. UserId int `description:"用户id"`
  64. ArticleId int `description:"文章id"`
  65. IndustryId int `description:"产业id"`
  66. ActivityId int `description:"活动id"`
  67. ChartPermissionId int `description:"权限id"`
  68. VideoId int `description:"视频id"`
  69. CreateTime string `description:"创建时间"`
  70. Mobile string `description:"手机号"`
  71. Email string `description:"邮箱"`
  72. CompanyId int `description:"公司id"`
  73. CompanyName string `description:"公司名称"`
  74. Content string `description:"内容"`
  75. Title string `description:"标题"`
  76. RedirectType int `description:"跳转类型 1文章 2活动音频 3产业视频 4活动视频"`
  77. }
  78. type CygxCommentListResp struct {
  79. List []*CygxArticleCommentResp
  80. Paging *paging.PagingItem
  81. }