list.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package http
  2. import (
  3. "go-common/app/interface/openplatform/article/model"
  4. "go-common/library/ecode"
  5. bm "go-common/library/net/http/blademaster"
  6. "strconv"
  7. )
  8. func listArticles(c *bm.Context) {
  9. var (
  10. id, mid int64
  11. )
  12. id, _ = strconv.ParseInt(c.Request.Form.Get("id"), 10, 64)
  13. if id <= 0 {
  14. c.JSON(nil, ecode.RequestErr)
  15. return
  16. }
  17. // get mid
  18. if midInter, ok := c.Get("mid"); ok {
  19. mid = midInter.(int64)
  20. }
  21. c.JSON(artSrv.ListArticles(c, id, mid))
  22. }
  23. func webListArticles(c *bm.Context) {
  24. var (
  25. id, mid int64
  26. )
  27. id, _ = strconv.ParseInt(c.Request.Form.Get("id"), 10, 64)
  28. if id <= 0 {
  29. c.JSON(nil, ecode.RequestErr)
  30. return
  31. }
  32. // get mid
  33. if midInter, ok := c.Get("mid"); ok {
  34. mid = midInter.(int64)
  35. }
  36. c.JSON(artSrv.WebListArticles(c, id, mid))
  37. }
  38. func listInfo(c *bm.Context) {
  39. var (
  40. aid int64
  41. )
  42. aid, _ = strconv.ParseInt(c.Request.Form.Get("id"), 10, 64)
  43. if aid <= 0 {
  44. c.JSON(nil, ecode.RequestErr)
  45. return
  46. }
  47. c.JSON(artSrv.ListInfo(c, aid))
  48. }
  49. func upLists(c *bm.Context) {
  50. var (
  51. upMid, sort int64
  52. err error
  53. lists model.UpLists
  54. )
  55. upMid, _ = strconv.ParseInt(c.Request.Form.Get("mid"), 10, 64)
  56. if upMid <= 0 {
  57. c.JSON(nil, ecode.RequestErr)
  58. return
  59. }
  60. sort, _ = strconv.ParseInt(c.Request.Form.Get("sort"), 10, 64)
  61. if lists, err = artSrv.UpLists(c, upMid, int8(sort)); err != nil {
  62. c.JSON(nil, err)
  63. return
  64. }
  65. if lists.Lists == nil {
  66. lists.Lists = []*model.List{}
  67. }
  68. c.JSON(lists, err)
  69. }
  70. func refreshLists(c *bm.Context) {
  71. var (
  72. id int64
  73. )
  74. id, _ = strconv.ParseInt(c.Request.Form.Get("id"), 10, 64)
  75. if id <= 0 {
  76. c.JSON(nil, ecode.RequestErr)
  77. return
  78. }
  79. c.JSON(nil, artSrv.RefreshList(c, id))
  80. }
  81. func rebuildAllListReadCount(c *bm.Context) {
  82. artSrv.RebuildAllListReadCount(c)
  83. c.JSON(nil, nil)
  84. }