h_report.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package handler
  2. import (
  3. "cicv-data-closedloop/amd64/web-server/entity"
  4. "cicv-data-closedloop/common/config/c_log"
  5. commonEntity "cicv-data-closedloop/common/entity"
  6. "cicv-data-closedloop/common/util"
  7. "github.com/gin-gonic/gin"
  8. "net/http"
  9. )
  10. type ReportRequest struct {
  11. Page commonEntity.PageRequest
  12. Team string `json:"team"`
  13. Topic string `json:"topic"`
  14. }
  15. // Page 分页查询
  16. func Page(c *gin.Context) {
  17. param := new(commonEntity.PageRequest)
  18. // 映射到结构体
  19. if err := c.ShouldBindJSON(&param); err != nil {
  20. c_log.GlobalLogger.Error("项目启动接收请求参数报错:", err)
  21. c.JSON(http.StatusBadRequest, commonEntity.Response{
  22. Code: 500,
  23. Msg: "请求体解析失败。",
  24. })
  25. return
  26. }
  27. var result []entity.Record
  28. for i := 0; i < param.PageSize; i++ {
  29. result = append(result, entity.Record{
  30. Team: "team" + util.NewShortUUID(),
  31. Topic: "topic" + util.NewShortUUID(),
  32. ScoreOnline: 100.0,
  33. ScoreOffline: 100.0,
  34. ScoreFinal: 100.0,
  35. Details: "sdlkfjsaljfldsakjfkls",
  36. })
  37. }
  38. c.JSON(http.StatusOK, commonEntity.Response{
  39. Code: 200,
  40. Msg: "分页查询成功。",
  41. Data: result,
  42. })
  43. }