http.go 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. package http
  2. import (
  3. "go-common/app/admin/main/creative/conf"
  4. "go-common/app/admin/main/creative/service"
  5. "go-common/library/log"
  6. bm "go-common/library/net/http/blademaster"
  7. "go-common/library/net/http/blademaster/middleware/permit"
  8. )
  9. var (
  10. svc *service.Service
  11. authSrc *permit.Permit
  12. )
  13. // Init http server
  14. func Init(c *conf.Config) {
  15. svc = service.New(c)
  16. authSrc = permit.New(c.Auth)
  17. engine := bm.DefaultServer(c.BM)
  18. innerRouter(engine)
  19. if err := engine.Start(); err != nil {
  20. log.Error("engine.Start error(%v)", err)
  21. panic(err)
  22. }
  23. }
  24. func innerRouter(e *bm.Engine) {
  25. e.GET("/monitor/ping", moPing)
  26. b := e.Group("/x/admin/creative")
  27. {
  28. innerMusicRouter(e, b)
  29. innerMaterialRouter(e, b)
  30. app := b.Group("/app")
  31. {
  32. app.GET("/portal", viewPortal)
  33. app.POST("/portal/add", addPortal)
  34. app.POST("/portal/update", upPortal)
  35. app.POST("/portal/down", downPortal)
  36. app.GET("/portal/list", portalList)
  37. }
  38. notice := b.Group("/notice")
  39. {
  40. notice.GET("/view", viewNotice)
  41. notice.GET("/list", listNotice)
  42. notice.POST("/add", addNotice)
  43. notice.POST("/update", upNotice)
  44. notice.POST("/delete", delNotice)
  45. }
  46. arc := b.Group("/oper/col_arc", authSrc.Verify())
  47. {
  48. arc.GET("/list", listCollectArcOper)
  49. arc.POST("/add", addCollectArcOper)
  50. // blew is copy from notice for support
  51. arc.GET("/view", viewNotice)
  52. arc.POST("/update", upNotice)
  53. arc.POST("/delete", delNotice)
  54. }
  55. whitelist := b.Group("/whitelist")
  56. {
  57. whitelist.GET("/view", viewWhiteList)
  58. whitelist.GET("/list", listWhiteList)
  59. whitelist.GET("/export.so", exportWhiteList)
  60. whitelist.POST("/add", addWhiteList)
  61. whitelist.POST("/add/batch", addBatchWhiteList)
  62. whitelist.POST("/update", upWhiteList)
  63. whitelist.POST("/delete", delWhiteList)
  64. }
  65. academy := b.Group("/academy", authSrc.Verify(), authSrc.Permit("ACADEMY_MANAGER")) //创作学院
  66. // academy := b.Group("/academy") //创作学院
  67. {
  68. academy.POST("/tag/update/fix", fixTag) //清理脏数据
  69. academy.POST("/archive/update/fix", fixArchive) //清理脏数据
  70. //tag
  71. academy.POST("/tag/add", addTag)
  72. academy.POST("/tag/update", upTag)
  73. academy.POST("/tag/bind", bindTag)
  74. academy.GET("/tag/view", viewTag)
  75. academy.GET("/tag/list", listTag)
  76. academy.POST("/tag/order", orderTag)
  77. //archive
  78. academy.POST("/archive/add", addArc)
  79. academy.POST("/archive/update", upArcTag)
  80. academy.POST("/archive/remove", removeArcTag)
  81. academy.POST("/archive/batch/add", batchAddArc)
  82. academy.POST("/archive/batch/update", batchUpArc)
  83. academy.POST("/archive/batch/remove", batchRemoveArc)
  84. academy.GET("/archive/view", viewArc)
  85. academy.GET("/archive/list", listArc)
  86. //occupation & skill
  87. academy.POST("/occupation/add", addOccupation)
  88. academy.POST("/occupation/update", upOccupation)
  89. academy.POST("/occupation/bind", bindOccupation)
  90. academy.POST("/occupation/order", orderOccupation)
  91. academy.GET("/occupation/list", listOccupation)
  92. academy.POST("/skill/add", addSkill)
  93. academy.POST("/skill/update", upSkill)
  94. academy.POST("/skill/bind", bindSkill)
  95. academy.POST("/software/add", addSoftware)
  96. academy.POST("/software/update", upSoftware)
  97. academy.POST("/software/bind", bindSoftware)
  98. //arc & skill
  99. academy.GET("/skill/archive/view", viewSkillArc)
  100. academy.GET("/skill/archive/list", skillArcList)
  101. academy.POST("/skill/archive/add", addSkillArc)
  102. academy.POST("/skill/archive/update", upSkillArc)
  103. academy.POST("/skill/archive/bind", bindSkillArc)
  104. //search keywords
  105. academy.GET("/search/keywords", searchKeywords)
  106. academy.POST("/search/keywords/sub", subSearchKeywords)
  107. }
  108. task := b.Group("/task", authSrc.Verify(), authSrc.Permit("CREATIVE_TASK_MANAGER")) //任务系统
  109. // task := b.Group("/task") //任务系统
  110. {
  111. //task list
  112. task.GET("/pre", taskPre)
  113. task.GET("/list", taskList)
  114. task.POST("/online", batchOnline)
  115. //group
  116. task.GET("/group/view", viewGroup)
  117. task.POST("/group/add", addGroup)
  118. task.POST("/group/edit", editGroup)
  119. task.POST("/group/order", orderGroup)
  120. task.POST("/group/upstate", upStateGroup)
  121. //sub
  122. task.GET("/sub/view", viewSubtask)
  123. task.POST("/sub/add", addSubtask)
  124. task.POST("/sub/edit", editSubtask)
  125. task.POST("/sub/order", orderSubtask)
  126. task.POST("/sub/upstate", upStateSubtask)
  127. task.POST("/sub/transfer", transferSubtask)
  128. //reward
  129. task.GET("/reward/list", rewardTree)
  130. task.GET("/reward/view", viewReward)
  131. task.POST("/reward/add", addReward)
  132. task.POST("/reward/edit", editReward)
  133. task.POST("/reward/upstate", upStateReward)
  134. //gift
  135. task.GET("/gift/list", listGiftReward)
  136. task.GET("/gift/view", viewGiftReward)
  137. task.POST("/gift/add", addGiftReward)
  138. task.POST("/gift/edit", editGiftReward)
  139. task.POST("/gift/upstate", upStateGiftReward)
  140. }
  141. }
  142. }
  143. //素材库 db creative
  144. func innerMaterialRouter(e *bm.Engine, group *bm.RouterGroup) {
  145. if group == nil {
  146. return
  147. }
  148. //字幕库 字体库 滤镜库
  149. material := group.Group("/material", authSrc.Verify())
  150. {
  151. material.GET("", authSrc.Permit("MATERIAL_READ"), infoMaterial)
  152. material.GET("/search", authSrc.Permit("MATERIAL_READ"), searchMaterialDb)
  153. //支持新增和修改
  154. material.POST("/add", authSrc.Permit("MATERIAL_WRITE"), syncMaterial)
  155. //支持批量修改
  156. material.POST("/state", authSrc.Permit("MATERIAL_WRITE"), stateMaterial)
  157. //仅支持 image/ zip 上传
  158. material.POST("/upload", upload)
  159. //素材库分类
  160. material.GET("/category", authSrc.Permit("MATERIAL_READ"), category)
  161. material.POST("/category/add", authSrc.Permit("MATERIAL_WRITE"), addMCategory)
  162. material.POST("/category/edit", authSrc.Permit("MATERIAL_WRITE"), editMCategory)
  163. material.POST("/category/index", authSrc.Permit("MATERIAL_WRITE"), indexMCategory)
  164. material.POST("/category/delete", authSrc.Permit("MATERIAL_WRITE"), delMCategory)
  165. material.GET("/category/search", authSrc.Permit("MATERIAL_READ"), searchMCategory)
  166. }
  167. }
  168. //音频库 db archive
  169. func innerMusicRouter(e *bm.Engine, group *bm.RouterGroup) {
  170. if group == nil {
  171. return
  172. }
  173. groupMusic := group.Group("/music")
  174. {
  175. //音乐管理及同步
  176. groupMusic.POST("/add", authSrc.Permit("MUSIC_UPDATE"), syncMusic)
  177. groupMusic.POST("/up/frontname", authSrc.Permit("MUSIC_UPDATE"), editMusicFrontName)
  178. groupMusic.POST("/up/tags", authSrc.Permit("MUSIC_UPDATE"), editMusicTags)
  179. groupMusic.POST("/edit", authSrc.Permit("MUSIC_UPDATE"), editMusic)
  180. groupMusic.POST("/batch/tags", authSrc.Permit("MUSIC_UPDATE"), batchEditMusicTags)
  181. groupMusic.POST("/up/timeline", authSrc.Permit("MUSIC_UPDATE"), editMusicTimeline)
  182. groupMusic.GET("/search", authSrc.Permit("MUSIC_READ"), searchMusic)
  183. //音乐分类
  184. groupMusic.GET("/category", authSrc.Permit("MUSIC_CATEGORY_READ"), categoryInfo)
  185. groupMusic.POST("/category/add", authSrc.Permit("MUSIC_CATEGORY_UPDATE"), addCategory)
  186. groupMusic.POST("/category/edit", authSrc.Permit("MUSIC_CATEGORY_UPDATE"), editCategory)
  187. groupMusic.POST("/category/index", authSrc.Permit("MUSIC_CATEGORY_UPDATE"), indexCategory)
  188. groupMusic.POST("/category/delete", authSrc.Permit("MUSIC_CATEGORY_UPDATE"), delCategory)
  189. groupMusic.GET("/category/search", authSrc.Permit("MUSIC_CATEGORY_READ"), searchCategory)
  190. //素材分类
  191. groupMusic.GET("/material", authSrc.Permit("MUSIC_MATERIAL_READ"), materialInfo)
  192. groupMusic.POST("/material/add", authSrc.Permit("MUSIC_MATERIAL_UPDATE"), addMaterial)
  193. groupMusic.POST("/material/edit", authSrc.Permit("MUSIC_MATERIAL_UPDATE"), editMaterial)
  194. groupMusic.POST("/material/delete", authSrc.Permit("MUSIC_MATERIAL_UPDATE"), delMaterial)
  195. groupMusic.POST("/material/batch/delete", authSrc.Permit("MUSIC_MATERIAL_UPDATE"), batchDeleteMaterial)
  196. groupMusic.GET("/material/search", authSrc.Permit("MUSIC_MATERIAL_READ"), searchMaterial)
  197. //音乐及素材 管理端
  198. groupMusic.GET("/material/relation", authSrc.Permit("MUSIC_WITH_MATERIAL_READ"), musicMaterialRelationInfo)
  199. groupMusic.POST("/material/relation/add", authSrc.Permit("MUSIC_WITH_MATERIAL_UPDATE"), addMaterialRelation)
  200. groupMusic.POST("/material/relation/batch/add", authSrc.Permit("MUSIC_WITH_MATERIAL_UPDATE"), batchAddMaterialRelation)
  201. groupMusic.POST("/material/relation/edit", authSrc.Permit("MUSIC_WITH_MATERIAL_UPDATE"), editMaterialRelation)
  202. //音乐及分类 app端
  203. groupMusic.GET("/category/relation", authSrc.Permit("MUSIC_WITH_CATEGORY_READ"), musicCategoryRelationInfo)
  204. groupMusic.POST("/category/relation/add", authSrc.Permit("MUSIC_WITH_CATEGORY_UPDATE"), addCategoryRelation)
  205. groupMusic.POST("/category/relation/batch/add", authSrc.Permit("MUSIC_WITH_CATEGORY_UPDATE"), batchAddCategoryRelation)
  206. groupMusic.POST("/category/relation/index", authSrc.Permit("MUSIC_WITH_CATEGORY_UPDATE"), indexCategoryRelation)
  207. groupMusic.POST("/category/relation/edit", authSrc.Permit("MUSIC_WITH_CATEGORY_UPDATE"), editCategoryRelation)
  208. groupMusic.POST("/category/relation/batch/delete", authSrc.Permit("MUSIC_WITH_CATEGORY_UPDATE"), batchDeleteCategoryRelation)
  209. groupMusic.POST("/category/relation/delete", authSrc.Permit("MUSIC_WITH_CATEGORY_UPDATE"), delCategoryRelation)
  210. groupMusic.GET("/category/relation/search", authSrc.Permit("MUSIC_WITH_CATEGORY_READ"), searchCategoryRelation)
  211. }
  212. }