diff --git a/gin/router.go b/gin/router.go index 4f1ccad..835e2a5 100644 --- a/gin/router.go +++ b/gin/router.go @@ -11,11 +11,11 @@ func routerSetup(router *gin.Engine, rootpath *string) { r := router.Group(*rootpath) { - r.POST("/add", handler.SuperAdd) //json输入 返回id - r.GET("/list") //分页形式数据库数据 - r.GET("/detail") //返回json - r.POST("/del") //删除数据 - r.POST("/save") //给你id和什么字段改什么 覆盖式 + r.POST("/add", handler.SuperAdd) //json输入 返回id + r.GET("/list", handler.SuperList) //分页形式数据库数据 + r.GET("/detail", handler.SuperDetail) //返回json + r.POST("/del", handler.SuperDetele) //删除数据 + r.POST("/save", handler.SuperSave) //给你id和什么字段改什么 覆盖式 } } diff --git a/service/super-service.go b/service/super-service.go index 701c9e5..6d8d5d9 100644 --- a/service/super-service.go +++ b/service/super-service.go @@ -27,7 +27,7 @@ func SuperList(index, row int) ([]*model.Super, error) { db, _ := mysql.NewInstance() var count int64 supers := make([]*model.Super, 0) - if err := db.Count(&count).Offset((index - 1) * row).Limit(row).Find(&supers).Error; err != nil { + if err := db.Model(&model.Super{}).Count(&count).Offset((index - 1) * row).Limit(row).Find(&supers).Error; err != nil { logrus.WithFields(logrus.Fields{ "func": "SuperList", }).Warningf("err: %s", err.Error()) diff --git a/test.http b/test.http index 8ac9b1e..0d3d8ac 100644 --- a/test.http +++ b/test.http @@ -11,7 +11,7 @@ Content-Type: application/json } ### list -GET {{url}}/add HTTP/1.1 +GET {{url}}/list HTTP/1.1 Content-Type: application/json { @@ -20,21 +20,16 @@ Content-Type: application/json } ### detail -GET {{url}}/detail HTTP/1.1 +GET {{url}}/detail?id=1 HTTP/1.1 Content-Type: application/json -{ - "NIHAO":"SHFD", - "DFHFS":"fff" -} ### delete POST {{url}}/delete HTTP/1.1 Content-Type: application/json { - "NIHAO":"SHFD", - "DFHFS":"fff" + "ID":2 } ### save