bugly.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. package http
  2. import (
  3. "go-common/app/admin/ep/marthe/model"
  4. bm "go-common/library/net/http/blademaster"
  5. "go-common/library/net/http/blademaster/binding"
  6. )
  7. // bugly version
  8. func updateVersion(c *bm.Context) {
  9. var (
  10. req = &model.AddVersionRequest{}
  11. err error
  12. username string
  13. )
  14. if err = c.BindWith(req, binding.JSON); err != nil {
  15. return
  16. }
  17. if username, err = getUsername(c); err != nil {
  18. return
  19. }
  20. c.JSON(srv.UpdateBuglyVersion(c, username, req))
  21. }
  22. func getVersionAndProjectList(c *bm.Context) {
  23. c.JSON(srv.BuglyVersionAndProjectList(c))
  24. }
  25. func queryVersions(c *bm.Context) {
  26. var (
  27. req = &model.QueryBuglyVersionRequest{}
  28. err error
  29. )
  30. if err = req.Verify(); err != nil {
  31. c.JSON(nil, err)
  32. return
  33. }
  34. if err = c.BindWith(req, binding.JSON); err != nil {
  35. return
  36. }
  37. c.JSON(srv.QueryBuglyVersions(c, req))
  38. }
  39. func runVersions(c *bm.Context) {
  40. var (
  41. v = new(struct {
  42. ID int64 `form:"id"`
  43. })
  44. err error
  45. )
  46. if err = c.Bind(v); err != nil {
  47. return
  48. }
  49. c.JSON(srv.RunVersions(v.ID))
  50. }
  51. // bugly cookie
  52. func updateCookie(c *bm.Context) {
  53. var (
  54. req = &model.AddCookieRequest{}
  55. err error
  56. username string
  57. )
  58. if username, err = getUsername(c); err != nil {
  59. return
  60. }
  61. if err = c.BindWith(req, binding.JSON); err != nil {
  62. return
  63. }
  64. c.JSON(srv.UpdateCookie(c, username, req))
  65. }
  66. func queryCookies(c *bm.Context) {
  67. var (
  68. req = &model.QueryBuglyCookiesRequest{}
  69. err error
  70. )
  71. if err = req.Verify(); err != nil {
  72. c.JSON(nil, err)
  73. return
  74. }
  75. if err = c.BindWith(req, binding.JSON); err != nil {
  76. return
  77. }
  78. c.JSON(srv.QueryCookies(c, req))
  79. }
  80. func updateCookieStatus(c *bm.Context) {
  81. var (
  82. v = new(struct {
  83. ID int64 `form:"id"`
  84. Status int `form:"status"`
  85. })
  86. err error
  87. )
  88. if err = c.Bind(v); err != nil {
  89. return
  90. }
  91. c.JSON(nil, srv.UpdateCookieStatus(c, v.ID, v.Status))
  92. }
  93. // bugly issue
  94. func queryBuglyIssue(c *bm.Context) {
  95. var (
  96. err error
  97. v = &model.QueryBuglyIssueRequest{}
  98. )
  99. if err = c.BindWith(v, binding.JSON); err != nil {
  100. return
  101. }
  102. c.JSON(srv.QueryBuglyIssueRecords(c, v))
  103. }
  104. func queryBatchRun(c *bm.Context) {
  105. var (
  106. err error
  107. v = &model.QueryBuglyBatchRunsRequest{}
  108. )
  109. if err = c.BindWith(v, binding.JSON); err != nil {
  110. return
  111. }
  112. c.JSON(srv.QueryBatchRuns(c, v))
  113. }
  114. // bugly project
  115. func updateProject(c *bm.Context) {
  116. var (
  117. req = &model.AddProjectRequest{}
  118. err error
  119. username string
  120. )
  121. if err = c.BindWith(req, binding.JSON); err != nil {
  122. return
  123. }
  124. if username, err = getUsername(c); err != nil {
  125. return
  126. }
  127. c.JSON(srv.UpdateBuglyProject(c, username, req))
  128. }
  129. func queryProjects(c *bm.Context) {
  130. var (
  131. req = &model.QueryBuglyProjectRequest{}
  132. err error
  133. )
  134. if err = req.Verify(); err != nil {
  135. c.JSON(nil, err)
  136. return
  137. }
  138. if err = c.BindWith(req, binding.JSON); err != nil {
  139. return
  140. }
  141. c.JSON(srv.QueryBuglyProjects(c, req))
  142. }
  143. func queryProjectVersions(c *bm.Context) {
  144. var (
  145. v = new(struct {
  146. ID int64 `form:"id"`
  147. })
  148. err error
  149. )
  150. if err = c.Bind(v); err != nil {
  151. return
  152. }
  153. c.JSON(srv.QueryBuglyProjectVersions(c, v.ID))
  154. }
  155. func queryProject(c *bm.Context) {
  156. var (
  157. v = new(struct {
  158. ID int64 `form:"id"`
  159. })
  160. err error
  161. )
  162. if err = c.Bind(v); err != nil {
  163. return
  164. }
  165. c.JSON(srv.QueryBuglyProject(c, v.ID))
  166. }
  167. func queryAllProjects(c *bm.Context) {
  168. c.JSON(srv.QueryAllBuglyProjects(c))
  169. }
  170. //test
  171. func test(c *bm.Context) {
  172. srv.BatchRunTask(model.TaskBatchRunUpdateBugInTapd, srv.BatchRunUpdateBugInTapd)
  173. c.JSON(nil, nil)
  174. }