h_report.go 1.1 KB

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