report.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package http
  2. import (
  3. "strconv"
  4. "go-common/app/admin/ep/melloi/model"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. bm "go-common/library/net/http/blademaster"
  8. "go-common/library/net/http/blademaster/binding"
  9. )
  10. func updateReportSummary(c *bm.Context) {
  11. reportSummary := model.ReportSummary{}
  12. if err := c.BindWith(&reportSummary, binding.JSON); nil != err {
  13. c.JSON(nil, err)
  14. return
  15. }
  16. var ResultMap = make(map[string]string)
  17. status, err := srv.UpdateReportSummary(&reportSummary)
  18. ResultMap["status"] = status
  19. c.JSON(ResultMap, err)
  20. }
  21. func queryReportSummarys(c *bm.Context) {
  22. qrsr := model.QueryReportSuRequest{}
  23. if err := c.BindWith(&qrsr, binding.Form); err != nil {
  24. c.JSON(nil, err)
  25. return
  26. }
  27. if err := qrsr.Verify(); err != nil {
  28. c.JSON(nil, err)
  29. return
  30. }
  31. sessionID, err := c.Request.Cookie("_AJSESSIONID")
  32. if err != nil {
  33. c.JSON(nil, err)
  34. return
  35. }
  36. res, err := srv.QueryReportSummarys(c, sessionID.Value, &qrsr)
  37. if err != nil {
  38. log.Error("queryScripts Error", err)
  39. return
  40. }
  41. c.JSON(res, err)
  42. }
  43. func queryReportByID(c *bm.Context) {
  44. v := new(struct {
  45. ID int `form:"id"`
  46. })
  47. if err := c.Bind(v); err != nil {
  48. c.JSON(nil, ecode.RequestErr)
  49. return
  50. }
  51. c.JSON(srv.QueryReportByID(v.ID))
  52. }
  53. func queryReGraph(c *bm.Context) {
  54. reGraphParam := model.QueryReGraphParam{}
  55. if err := c.BindWith(&reGraphParam, binding.JSON); err != nil {
  56. c.JSON(nil, err)
  57. return
  58. }
  59. log.Info("TestNameNicks:(%s)", reGraphParam.TestNameNicks)
  60. reportGraphs, err := srv.QueryReGraph(reGraphParam.TestNameNicks)
  61. var resultGraphMap = make(map[string][][]model.ReportGraph)
  62. resultGraphMap["reportGraphs"] = reportGraphs
  63. c.JSON(resultGraphMap, err)
  64. }
  65. func queryReGraphAvg(c *bm.Context) {
  66. reGraphParam := model.QueryReGraphParam{}
  67. if err := c.BindWith(&reGraphParam, binding.JSON); err != nil {
  68. c.JSON(nil, err)
  69. return
  70. }
  71. log.Info("TestNameNicks:(%s)", reGraphParam.TestNameNicks)
  72. reportGraphs, err := srv.QueryReGraphAvg(reGraphParam.TestNameNicks)
  73. var resultGraphMap = make(map[string][]model.ReportGraph)
  74. resultGraphMap["reportGraphs"] = reportGraphs
  75. c.JSON(resultGraphMap, err)
  76. }
  77. func updateReportStatus(c *bm.Context) {
  78. testStatus := c.Request.Form.Get("test_status")
  79. status, err := strconv.Atoi(testStatus)
  80. if err != nil {
  81. log.Error("test_status 输入错误,(%s)", err)
  82. return
  83. }
  84. c.JSON(srv.UpdateReportStatus(status), nil)
  85. }
  86. func delReport(c *bm.Context) {
  87. v := new(struct {
  88. ID int `form:"id"`
  89. })
  90. if err := c.Bind(v); err != nil {
  91. c.JSON(nil, ecode.RequestErr)
  92. return
  93. }
  94. c.JSON(nil, srv.DelReportSummary(v.ID))
  95. }