This commit is contained in:
wyh 2023-12-29 13:31:00 +08:00
parent 78cc0d848e
commit e7378b882b
3 changed files with 9 additions and 14 deletions

View File

@ -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和什么字段改什么 覆盖式
}
}

View File

@ -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())

View File

@ -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