Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

列表分页在空数据情况下,能否约束一下 list 返回为 [] #85

Open
ycrao opened this issue Aug 24, 2023 · 1 comment
Open

Comments

@ycrao
Copy link

ycrao commented Aug 24, 2023

return db.page(
"""
    SELECT 
        *
    FROM `article`
"""
)

data.list 的结构应该为数组,但是目前在查询条件下空数据返回 null,并不合理。在与某些外部第三方对接过程中,可能造成困扰。

image

期望返回:

{
    "code": 200,
    "message": "success",
    "data": {
        "total": 0,
        "list": []
    },
    "timestamp": 1692847569273,
    "executeTime": 1691
}

另外期望 data 里可额外配置返回 pagesize 等参数,某些情况下为了反爬虫,可能会对最大分页大小做出限制(比如如果 size > 100 则默认设置 size = 100 ,如果结果里返回 size 则可以拿到当前接口真实使用的 size

@javamxd
Copy link
Collaborator

javamxd commented Aug 24, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants