scene.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. package http
  2. import (
  3. "go-common/app/admin/ep/melloi/model"
  4. bm "go-common/library/net/http/blademaster"
  5. "go-common/library/net/http/blademaster/binding"
  6. )
  7. // AddAndExecuScene Add And Execu Scene
  8. func AddAndExecuScene(c *bm.Context) {
  9. scene := model.Scene{}
  10. if err := c.BindWith(&scene, binding.JSON); err != nil {
  11. c.JSON(nil, err)
  12. return
  13. }
  14. cookie := c.Request.Header.Get("Cookie")
  15. c.JSON(srv.AddAndExecuScene(c, scene, cookie))
  16. }
  17. func queryDraft(c *bm.Context) {
  18. scene := model.Scene{}
  19. if err := c.BindWith(&scene, binding.Form); err != nil {
  20. c.JSON(nil, err)
  21. return
  22. }
  23. c.JSON(srv.QueryDraft(&scene))
  24. }
  25. func updateScene(c *bm.Context) {
  26. scene := model.Scene{}
  27. if err := c.BindWith(&scene, binding.JSON); err != nil {
  28. c.JSON(nil, err)
  29. return
  30. }
  31. c.JSON(srv.UpdateScene(&scene))
  32. }
  33. func addScene(c *bm.Context) {
  34. scene := model.Scene{}
  35. if err := c.BindWith(&scene, binding.JSON); err != nil {
  36. c.JSON(nil, err)
  37. return
  38. }
  39. id, _ := srv.AddScene(&scene)
  40. c.JSON(id, nil)
  41. }
  42. func saveScene(c *bm.Context) {
  43. scene := model.Scene{}
  44. if err := c.BindWith(&scene, binding.JSON); err != nil {
  45. c.JSON(nil, err)
  46. return
  47. }
  48. c.JSON(nil, srv.SaveScene(&scene))
  49. }
  50. func saveOrder(c *bm.Context) {
  51. scene := model.Scene{}
  52. if err := c.BindWith(&scene, binding.Form); err != nil {
  53. c.JSON(nil, err)
  54. return
  55. }
  56. var req model.SaveOrderReq
  57. if err := c.BindWith(&req, binding.JSON); err != nil {
  58. c.JSON(nil, err)
  59. return
  60. }
  61. c.JSON(nil, srv.SaveOrder(req, &scene))
  62. }
  63. func queryRelation(c *bm.Context) {
  64. script := model.Script{}
  65. if err := c.BindWith(&script, binding.Form); err != nil {
  66. c.JSON(nil, err)
  67. return
  68. }
  69. c.JSON(srv.QueryRelation(&script))
  70. }
  71. func queryAPI(c *bm.Context) {
  72. scene := model.Scene{}
  73. if err := c.BindWith(&scene, binding.Form); err != nil {
  74. c.JSON(nil, err)
  75. return
  76. }
  77. c.JSON(srv.QueryAPI(&scene))
  78. }
  79. func deleteAPI(c *bm.Context) {
  80. script := model.Script{}
  81. if err := c.BindWith(&script, binding.JSON); err != nil {
  82. c.JSON(nil, err)
  83. return
  84. }
  85. c.JSON(nil, srv.DeleteAPI(&script))
  86. }
  87. func addConfig(c *bm.Context) {
  88. script := model.Script{}
  89. if err := c.BindWith(&script, binding.JSON); err != nil {
  90. c.JSON(nil, err)
  91. return
  92. }
  93. c.JSON(nil, srv.AddConfig(&script))
  94. }
  95. func queryTree(c *bm.Context) {
  96. script := model.Script{}
  97. if err := c.BindWith(&script, binding.Form); err != nil {
  98. c.JSON(nil, err)
  99. return
  100. }
  101. c.JSON(srv.QueryTree(&script))
  102. }
  103. func queryScenes(c *bm.Context) {
  104. qsr := model.QuerySceneRequest{}
  105. if err := c.BindWith(&qsr, binding.Form); err != nil {
  106. c.JSON(nil, err)
  107. return
  108. }
  109. if err := qsr.Verify(); err != nil {
  110. c.JSON(nil, err)
  111. return
  112. }
  113. sessionID, err := c.Request.Cookie("_AJSESSIONID")
  114. if err != nil {
  115. c.JSON(nil, err)
  116. return
  117. }
  118. res, err := srv.QueryScenesByPage(c, sessionID.Value, &qsr)
  119. if err != nil {
  120. return
  121. }
  122. c.JSON(res, err)
  123. }
  124. func doScenePtest(c *bm.Context) {
  125. ptestScene := model.DoPtestSceneParam{}
  126. if err := c.BindWith(&ptestScene, binding.JSON); err != nil {
  127. c.JSON(nil, err)
  128. return
  129. }
  130. cookie := c.Request.Header.Get("Cookie")
  131. c.JSON(srv.DoScenePtest(c, ptestScene, false, cookie))
  132. }
  133. func doScenePtestBatch(c *bm.Context) {
  134. ptestScenes := model.DoPtestSceneParams{}
  135. if err := c.BindWith(&ptestScenes, binding.JSON); err != nil {
  136. c.JSON(nil, err)
  137. return
  138. }
  139. cookie := c.Request.Header.Get("Cookie")
  140. c.JSON(nil, srv.DoScenePtestBatch(c, ptestScenes, cookie))
  141. }
  142. func queryExistAPI(c *bm.Context) {
  143. apiInfoReq := model.APIInfoRequest{}
  144. if err := c.BindWith(&apiInfoReq, binding.Form); err != nil {
  145. c.JSON(nil, err)
  146. return
  147. }
  148. sessionID, err := c.Request.Cookie("_AJSESSIONID")
  149. if err != nil {
  150. c.JSON(nil, err)
  151. return
  152. }
  153. c.JSON(srv.QueryExistAPI(c, sessionID.Value, &apiInfoReq))
  154. }
  155. func queryPreview(c *bm.Context) {
  156. script := model.Script{}
  157. if err := c.BindWith(&script, binding.Form); err != nil {
  158. c.JSON(nil, err)
  159. }
  160. c.JSON(srv.QueryPreview(&script))
  161. }
  162. func queryParams(c *bm.Context) {
  163. script := model.Script{}
  164. if err := c.BindWith(&script, binding.Form); err != nil {
  165. c.JSON(nil, err)
  166. }
  167. res, _, err := srv.QueryParams(&script)
  168. c.JSON(res, err)
  169. }
  170. func updateBindScene(c *bm.Context) {
  171. bindScene := model.BindScene{}
  172. if err := c.BindWith(&bindScene, binding.JSON); err != nil {
  173. c.JSON(nil, err)
  174. return
  175. }
  176. c.JSON(nil, srv.UpdateBindScene(&bindScene))
  177. }
  178. func queryDrawRelation(c *bm.Context) {
  179. scene := model.Scene{}
  180. if err := c.BindWith(&scene, binding.Form); err != nil {
  181. c.JSON(nil, err)
  182. }
  183. res, _, err := srv.QueryDrawRelation(&scene)
  184. c.JSON(res, err)
  185. }
  186. func addSceneScript(c *bm.Context) {
  187. script := model.Script{}
  188. if err := c.BindWith(&script, binding.JSON); err != nil {
  189. c.JSON(nil, err)
  190. return
  191. }
  192. scene := model.Scene{}
  193. if err := c.BindWith(&scene, binding.Form); err != nil {
  194. c.JSON(nil, err)
  195. return
  196. }
  197. cookie := c.Request.Header.Get("Cookie")
  198. c.JSON(srv.AddAndExcuScript(c, &script, cookie, &scene, false, false))
  199. }
  200. func deleteDraft(c *bm.Context) {
  201. scene := model.Scene{}
  202. if err := c.BindWith(&scene, binding.JSON); err != nil {
  203. c.JSON(nil, err)
  204. return
  205. }
  206. c.JSON(nil, srv.DeleteDraft(&scene))
  207. }
  208. func queryConfig(c *bm.Context) {
  209. script := model.Script{}
  210. if err := c.BindWith(&script, binding.Form); err != nil {
  211. c.JSON(nil, err)
  212. return
  213. }
  214. c.JSON(srv.QueryConfig(&script))
  215. }
  216. func deleteScene(c *bm.Context) {
  217. scene := model.Scene{}
  218. if err := c.BindWith(&scene, binding.Form); err != nil {
  219. c.JSON(nil, err)
  220. return
  221. }
  222. c.JSON(nil, srv.DeleteScene(&scene))
  223. }
  224. func copyScene(c *bm.Context) {
  225. scene := model.Scene{}
  226. if err := c.BindWith(&scene, binding.JSON); err != nil {
  227. c.JSON(nil, err)
  228. return
  229. }
  230. cookie := c.Request.Header.Get("Cookie")
  231. c.JSON(srv.CopyScene(c, &scene, cookie))
  232. }
  233. func queryFusing(c *bm.Context) {
  234. script := model.Script{}
  235. if err := c.BindWith(&script, binding.Form); err != nil {
  236. c.JSON(nil, err)
  237. return
  238. }
  239. c.JSON(srv.QueryFusing(&script))
  240. }