article_comment.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. *
  40. FROM
  41. cygx_article_comment AS c
  42. WHERE
  43. user_id = ? ORDER BY c.create_time DESC LIMIT ?,? `
  44. _, err = o.Raw(sql, userId, startSize, pageSize).QueryRows(&items)
  45. return
  46. }
  47. // 我的留言列表
  48. func GetCommentListCount(userId int) (count int, err error) {
  49. o := orm.NewOrm()
  50. sql := `SELECT
  51. COUNT( 1 ) as count
  52. FROM
  53. cygx_article_comment AS c
  54. WHERE
  55. user_id = ? ORDER BY c.create_time DESC `
  56. err = o.Raw(sql, userId).QueryRow(&count)
  57. return
  58. }
  59. type CygxArticleCommentResp struct {
  60. Id int `orm:"column(id);pk" description:"留言id"`
  61. UserId int `description:"用户id"`
  62. ArticleId int `description:"文章id"`
  63. IndustryId int `description:"产业id"`
  64. ActivityId int `description:"活动id"`
  65. ChartPermissionId int `description:"权限id"`
  66. VideoId int `description:"视频id"`
  67. CreateTime string `description:"创建时间"`
  68. Mobile string `description:"手机号"`
  69. Email string `description:"邮箱"`
  70. CompanyId int `description:"公司id"`
  71. CompanyName string `description:"公司名称"`
  72. Content string `description:"内容"`
  73. Title string `description:"标题"`
  74. RedirectType int `description:"跳转类型 1文章 2活动音频 3产业视频 4活动视频"`
  75. }
  76. type CygxCommentListResp struct {
  77. List []*CygxArticleCommentResp
  78. Paging *paging.PagingItem
  79. }