article_comment.go 2.8 KB

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