|
@@ -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(¶m); 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,
|