http.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. package http
  2. import (
  3. "go-common/app/admin/main/feed/conf"
  4. bfssvr "go-common/app/admin/main/feed/service/bfs"
  5. "go-common/app/admin/main/feed/service/channel"
  6. "go-common/app/admin/main/feed/service/common"
  7. "go-common/app/admin/main/feed/service/egg"
  8. pgcsvr "go-common/app/admin/main/feed/service/pgc"
  9. "go-common/app/admin/main/feed/service/popular"
  10. "go-common/app/admin/main/feed/service/search"
  11. "go-common/library/log"
  12. bm "go-common/library/net/http/blademaster"
  13. "go-common/library/net/http/blademaster/middleware/permit"
  14. )
  15. var (
  16. authSvc *permit.Permit
  17. eggSvc *egg.Service
  18. bfsSvc *bfssvr.Service
  19. searchSvc *search.Service
  20. pgcSvr *pgcsvr.Service
  21. chanelSvc *channel.Service
  22. popularSvc *popular.Service
  23. cardSvc *channel.Service
  24. commonSvc *common.Service
  25. )
  26. // initService init service
  27. func initService(c *conf.Config) {
  28. authSvc = permit.New(c.Auth)
  29. eggSvc = egg.New(c)
  30. bfsSvc = bfssvr.New(c)
  31. searchSvc = search.New(c)
  32. pgcSvr = pgcsvr.New(c)
  33. chanelSvc = channel.New(c)
  34. cardSvc = channel.New(c)
  35. popularSvc = popular.New(c)
  36. commonSvc = common.New(c)
  37. }
  38. // Init init http sever instance.
  39. func Init(c *conf.Config) {
  40. initService(c)
  41. engine := bm.DefaultServer(c.HTTPServer)
  42. innerRouter(engine)
  43. // init internal server
  44. if err := engine.Start(); err != nil {
  45. log.Error("httpx.Serve error(%v)", err)
  46. panic(err)
  47. }
  48. }
  49. // innerRouter
  50. func innerRouter(e *bm.Engine) {
  51. // ping monitor
  52. e.GET("/monitor/ping", ping)
  53. //modules color eggs
  54. feed := e.Group("/x/admin/feed")
  55. {
  56. feed.POST("/upload", clientUpload)
  57. //对外 搜索
  58. feed.GET("/eggSearch", searchEgg)
  59. //对外 web
  60. feed.GET("/eggSearchWeb", SearchEggWeb)
  61. common := feed.Group("/common")
  62. {
  63. common.GET("/card/titlePreview", cardPreview2)
  64. common.GET("/log/action", actionLog)
  65. common.GET("/pgc/season", getPgcSeason)
  66. common.GET("/pgc/seasons", getPgcSeasons)
  67. common.GET("/pgc/ep", getPgcEp)
  68. common.GET("/card/type", cardType)
  69. }
  70. egg := feed.Group("/egg")
  71. {
  72. egg.POST("/add", addEgg)
  73. egg.GET("/index", indexEgg)
  74. egg.POST("/update", updateEgg)
  75. egg.POST("/publish", pubEgg)
  76. egg.POST("/delete", delEgg)
  77. }
  78. //对外
  79. open := feed.Group("/open")
  80. {
  81. //search
  82. open.POST("/search/addHotword", openAddHotword) //搜索 添加热词
  83. open.POST("/search/addDarkword", openAddDarkword) //搜索 添加黑马词
  84. open.GET("/search/blackList", openBlacklist) //搜索 黑名单
  85. open.GET("/search/hotwords", openHotList) //搜索 热词
  86. open.GET("/search/darkword", openDarkword) //搜索 获取黑马词
  87. open.GET("/search/webSearch", openSearchWeb) //web 搜索
  88. open.POST("/ai/addPopStars", aiAddPopularStars) //AI 添加新星卡片
  89. }
  90. search := feed.Group("/search", authSvc.Permit("SEARCH_HOTWORD"))
  91. {
  92. search.GET("/blackList", blackList)
  93. search.POST("/addBlack", addBlack)
  94. search.POST("/delBlack", delBlack)
  95. search.GET("/hot", HotList)
  96. search.POST("/addInter", addInter)
  97. search.POST("/updateInter", updateInter)
  98. search.POST("/deleteHot", deleteHot)
  99. search.POST("/updateSearch", updateSearch)
  100. search.POST("/publishHot", publishHotWord)
  101. search.POST("/publishDark", publishDarkWord)
  102. search.GET("/dark", darkList)
  103. search.POST("/delDark", deleteDark)
  104. }
  105. searchWeb := feed.Group("/search/web")
  106. {
  107. searchWeb.GET("/card/list", searchWebCardList)
  108. searchWeb.POST("/card/add", addSearchWebCard)
  109. searchWeb.POST("/card/update", upSearchWebCard)
  110. searchWeb.POST("/card/delete", delSearchWebCard)
  111. searchWeb.GET("/list", searchWebList)
  112. searchWeb.POST("/add", addSearchWeb)
  113. searchWeb.POST("/update", upSearchWeb)
  114. searchWeb.POST("/delete", delSearchWeb)
  115. searchWeb.POST("/opt", optSearchWeb)
  116. }
  117. cardsetup := feed.Group("/cardsetup")
  118. {
  119. cardsetup.POST("/add", addCardSetup)
  120. cardsetup.GET("/list", cardSetupList)
  121. cardsetup.POST("/delete", delCardSetup)
  122. cardsetup.POST("/update", updateCardSetup)
  123. }
  124. channel := feed.Group("/channel")
  125. {
  126. tab := channel.Group("/tab")
  127. {
  128. tab.GET("/list", tabList)
  129. tab.POST("/add", addTab)
  130. tab.POST("/update", updateTab)
  131. tab.POST("/delete", deleteTab)
  132. tab.POST("/offline", offlineTab)
  133. }
  134. }
  135. popular := feed.Group("/popular")
  136. {
  137. eventTopic := popular.Group("/event_topic")
  138. {
  139. eventTopic.GET("/list", eventTopicList)
  140. eventTopic.POST("/add", addEventTopic)
  141. eventTopic.POST("/update", upEventTopic)
  142. eventTopic.GET("/delete", delEventTopic)
  143. }
  144. stars := popular.Group("/stars")
  145. {
  146. stars.GET("/list", popularStarsList)
  147. stars.POST("/add", addPopularStars)
  148. stars.POST("/update", updatePopularStars)
  149. stars.POST("/delete", deletePopularStars)
  150. stars.POST("/reject", rejectPopularStars)
  151. }
  152. }
  153. }
  154. }
  155. // ping check server ok.
  156. func ping(c *bm.Context) {
  157. }