LingxinMeng 1 년 전
부모
커밋
e3ff1bc373
2개의 변경된 파일16개의 추가작업 그리고 17개의 파일을 삭제
  1. 14 15
      amd64/report-server/handler/h_report.go
  2. 2 2
      common/entity/e_page.go

+ 14 - 15
amd64/report-server/handler/h_report.go

@@ -2,6 +2,7 @@ package handler
 
 import (
 	"cicv-data-closedloop/amd64/report-server/entity"
+	"cicv-data-closedloop/common/config/c_log"
 	commonEntity "cicv-data-closedloop/common/entity"
 	"cicv-data-closedloop/common/util"
 	"github.com/gin-gonic/gin"
@@ -15,23 +16,21 @@ type testStruct struct {
 
 // Page 分页查询
 func Page(c *gin.Context) {
-	//// 获取请求参数
-	//param := c.Query("param")
-	//c_log.GlobalLogger.Info("接受到请求参数:", param)
-	//var tests []testStruct
-	//// 查询数据库
-	//var testSql string
-	//if err := c_db.MysqlDb.Select(&tests, testSql); err != nil {
-	//	c_log.GlobalLogger.Error("数据库查询报错:", err)
-	//	c.JSON(http.StatusInternalServerError, entity.DefaultFailHttpResult)
-	//	return
-	//}
-	//c_log.GlobalLogger.Info("数据库查询成功:", tests)
+	param := new(commonEntity.PageRequest)
+	// 映射到结构体
+	if err := c.ShouldBindJSON(&param); err != nil {
+		c_log.GlobalLogger.Error("项目启动接收请求参数报错:", err)
+		c.JSON(http.StatusBadRequest, commonEntity.Response{
+			Code: 500,
+			Msg:  "请求体解析失败。",
+		})
+		return
+	}
 	var result []entity.Record
-	for i := 0; i < 100; i++ {
+	for i := 0; i < param.PageSize; i++ {
 		result = append(result, entity.Record{
-			Team:         "test" + util.NewShortUUID(),
-			Topic:        "team" + util.NewShortUUID(),
+			Team:         "team" + util.NewShortUUID(),
+			Topic:        "topic" + util.NewShortUUID(),
 			ScoreOnline:  100.0,
 			ScoreOffline: 100.0,
 			ScoreFinal:   100.0,

+ 2 - 2
common/entity/e_page.go

@@ -1,6 +1,6 @@
 package entity
 
 type PageRequest struct {
-	CurrentPage string `json:"currentPage"`
-	PageSize    string `json:"pageSize"`
+	CurrentPage int `json:"currentPage"`
+	PageSize    int `json:"pageSize"`
 }