article_comment.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. )
  5. type ArticleComment struct {
  6. Id int `description:"主键ID"`
  7. ArticleId int `description:"活动ID"`
  8. UserId int `description:"用户ID"`
  9. CreateTime string `description:"创建时间"`
  10. Mobile string `description:"手机号"`
  11. CompanyName string `description:"公司名称"`
  12. RealName string `description:"姓名"`
  13. Content string `description:"内容"`
  14. }
  15. type ArticleCommentListResp struct {
  16. List []*ArticleComment
  17. }
  18. //列表
  19. func GetArticleCommentList(articleId int) (items []*ArticleComment, err error) {
  20. o := orm.NewOrm()
  21. sql := `SELECT k.*,u.real_name
  22. FROM cygx_article_comment as k
  23. LEFT JOIN wx_user as u ON u.mobile = k.mobile
  24. WHERE article_id = ? ORDER BY create_time DESC`
  25. _, err = o.Raw(sql, articleId).QueryRows(&items)
  26. return
  27. }
  28. //列表
  29. func GetArticleCommentListByVideoId(videoId int) (items []*ArticleComment, err error) {
  30. o := orm.NewOrm()
  31. sql := `SELECT k.*,u.real_name
  32. FROM cygx_article_comment as k
  33. LEFT JOIN wx_user as u ON u.mobile = k.mobile
  34. WHERE video_id = ? ORDER BY create_time DESC`
  35. _, err = o.Raw(sql, videoId).QueryRows(&items)
  36. return
  37. }
  38. //列表
  39. func GetArticleCommentListByActivityVideoId(videoId int) (items []*ArticleComment, err error) {
  40. o := orm.NewOrm()
  41. sql := `SELECT k.*,u.real_name
  42. FROM cygx_article_comment as k
  43. LEFT JOIN wx_user as u ON u.mobile = k.mobile
  44. WHERE video_id = ? ORDER BY create_time DESC`
  45. _, err = o.Raw(sql, videoId).QueryRows(&items)
  46. return
  47. }
  48. //留言列表
  49. func GetArticleCommentListSearch(condition string, pars []interface{}) (items []*ArticleComment, err error) {
  50. o := orm.NewOrm()
  51. sql := ` SELECT k.*,u.real_name
  52. FROM cygx_article_comment as k
  53. LEFT JOIN wx_user as u ON u.mobile = k.mobile
  54. WHERE 1= 1 ` + condition + ` ORDER BY create_time DESC `
  55. _, err = o.Raw(sql, pars).QueryRows(&items)
  56. return
  57. }