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

分页迭代器 #211

Open
guonaihong opened this issue Apr 11, 2020 · 4 comments
Open

分页迭代器 #211

guonaihong opened this issue Apr 11, 2020 · 4 comments

Comments

@guonaihong
Copy link
Owner

guonaihong commented Apr 11, 2020

背景

分页是现在API里面很常见的一个用法,但是有个问题 分页的是非标准化的技术。本issue尝试在非标准化和实用性之间取得平衡点。

伪代码如下,可能会改变

  • 默认
gout.GET("url").F().
     Page().Range(0/*从零页开始*/, 20/*每页数据条目*/, -1/*取多少页数据, -1表示一直循环下去*/, func(c *gout.Context){

}).Do()
  • 特殊(如果分页所需的page和size不是常见的单词,可以使用Custom重新设定)
gout.GET("url").F().
     Page().
     Custom(gout.Page, "p", gout.Size, "S").
     Range(0/*从零页开始*/, 20/*每页数据条目*/, -1/*取多少页数据, -1表示一直循环下去*/, func(c *gout.Context){

}).Do()

对于form data和别的数据,需要思考是否提供支持。

@yinheli
Copy link

yinheli commented May 18, 2020

感觉是一个伪需求,不如支持 clone
先创建一个 base gout 实例,然后可以 clone 出来一个新的实例,修改参数
这样的好处是它还能支持并发

@guonaihong
Copy link
Owner Author

hi @yinheli ,一般访问分页数据,你那边是怎么处理的?

@yinheli
Copy link

yinheli commented May 18, 2020

因为业务太复杂了,建议基础库不要做这样的事情,交给业务层代码去自行二次封装就行

@guonaihong
Copy link
Owner Author

有道理。

@guonaihong guonaihong removed v0.1.0 enhancement New feature or request labels May 18, 2020
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