acmestack / gorm-plus

Gorm-plus是基于Gorm的增强版,类似Mybatis-plus语法。Gorm-plus is based on an enhanced version of Gorm, similar to Mybatis-plus syntax.
https://github.com/acmestack/gorm-plus/wiki
Apache License 2.0
285 stars 44 forks source link

分页JSON序列化字段可以改成小驼峰吗? #65

Closed VioletCoding closed 1 year ago

VioletCoding commented 1 year ago

Enviornment (please complete the following information):

Describe the bug A clear and concise description of what the bug is.

func page(c *gin.Context) {
    query := &QueryPage{}
    _ = c.ShouldBindQuery(query)
    page := gplus.NewPage[User](query.Current, query.PageSize)
    page, _ = gplus.SelectPage(page, gplus.BuildQuery[User](c.Request.URL.Query()))
    c.JSON(200, gin.H{
        "code": 0,
        "data": page,
    })
}
user.GET("/page", page)

返回

{
    "code": 0,
    "data": {
        "Current": 0,
        "Size": 0,
        "Total": 5,
        "Records": [
            {
                "id": 407,
                "username": "张三",
                "password": "password1",
                "address": "地址1",
                "age": 25,
                "phone": "12345678901",
                "score": 80,
                "dept": "部门1",
                "createdAt": "2023-08-12T07:03:05+08:00",
                "updatedAt": "2023-08-12T07:03:05+08:00"
            }
        ],
        "RecordsMap": null
    }
}

page的默认字段怎么改成小驼峰?

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

afumu commented 1 year ago

你感兴趣的话,可以提交代码,修改这个结构体就可以了

image