report_pc.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package models
  2. import (
  3. "rdluck_tools/orm"
  4. "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.NewOrm()
  24. o.Using("rddp")
  25. sql := `SELECT * FROM classify WHERE parent_id=? ORDER BY sort ASC `
  26. _, err = o.Raw(sql, classifyId).QueryRows(&list)
  27. return
  28. }
  29. type ResearchReportListResp struct {
  30. List []*ResearchReportList
  31. }
  32. func GetSearchReportListCount(condition string) (count int, err error) {
  33. o := orm.NewOrm()
  34. o.Using("rddp")
  35. sql := ` SELECT COUNT(1) AS count FROM report WHERE 1=1 AND state=2 `
  36. if condition != "" {
  37. sql += condition
  38. }
  39. err = o.Raw(sql).QueryRow(&count)
  40. return
  41. }
  42. func GetSearchReportList(condition string) (items []*ReportList, err error) {
  43. o := orm.NewOrm()
  44. o.Using("rddp")
  45. 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,
  46. 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,
  47. 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
  48. FROM report AS a
  49. INNER JOIN classify AS b ON a.classify_id_second=b.id
  50. WHERE a.state=2 `
  51. if condition != "" {
  52. sql += condition
  53. }
  54. sql += `ORDER BY a.publish_time DESC `
  55. _, err = o.Raw(sql).QueryRows(&items)
  56. return
  57. }
  58. type PcSearchReportListResp struct {
  59. List []*ReportList
  60. Paging *paging.PagingItem
  61. }