report_pc.go 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 ResearchReportList struct {
  8. Id int `orm:"column(id);pk"`
  9. ClassifyName string `description:"分类名称"`
  10. Sort int `json:"-"`
  11. ParentId int `description:"父级分类id"`
  12. CreateTime time.Time `description:"创建时间"`
  13. ModifyTime time.Time `description:"修改时间"`
  14. Abstract string `description:"栏目简介"`
  15. Descript string `description:"分享描述"`
  16. ReportAuthor string `description:"栏目作者"`
  17. AuthorDescript string `description:"作者简介"`
  18. ColumnImgUrl string `description:"栏目配图"`
  19. HeadImgUrl string `description:"头部banner"`
  20. AvatarImgUrl string `description:"头像"`
  21. }
  22. func GetResearchReportList(classifyId int) (list []*ResearchReportList, err error) {
  23. o := orm.NewOrmUsingDB("rddp")
  24. sql := `SELECT * FROM classify WHERE parent_id=? ORDER BY sort ASC `
  25. _, err = o.Raw(sql, classifyId).QueryRows(&list)
  26. return
  27. }
  28. type ResearchReportListResp struct {
  29. List []*ResearchReportList
  30. }
  31. func GetSearchReportListCount(condition string) (count int, err error) {
  32. o := orm.NewOrmUsingDB("rddp")
  33. sql := ` SELECT COUNT(1) AS count FROM report WHERE 1=1 AND state=2 `
  34. if condition != "" {
  35. sql += condition
  36. }
  37. err = o.Raw(sql).QueryRow(&count)
  38. return
  39. }
  40. func GetSearchReportList(condition string) (items []*ReportList, err error) {
  41. o := orm.NewOrmUsingDB("rddp")
  42. sql := ` SELECT a.id,a.add_type,a.classify_id_first,a.classify_name_first,a.classify_id_second,a.classify_name_second,a.title,a.abstract,a.author,a.frequency,
  43. a.create_time,a.modify_time,a.state,a.publish_time,a.stage,a.msg_is_send,b.id AS classify_id,b.classify_name,b.descript,b.report_author,b.author_descript,
  44. b.report_img_url,b.head_img_url,b.avatar_img_url,b.column_img_url,b.home_img_url,a.video_url,a.video_name,a.video_play_seconds,a.video_size
  45. FROM report AS a
  46. INNER JOIN classify AS b ON a.classify_id_second=b.id
  47. WHERE a.state=2 `
  48. if condition != "" {
  49. sql += condition
  50. }
  51. sql += `ORDER BY a.publish_time DESC `
  52. _, err = o.Raw(sql).QueryRows(&items)
  53. return
  54. }
  55. type PcSearchReportListResp struct {
  56. List []*ReportList
  57. Paging *paging.PagingItem
  58. }