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

分页查询的情况下怎样全量导出(有接口获取全量数据)? #307

Closed
aFlappyPig opened this issue Jan 17, 2018 · 2 comments

Comments

@aFlappyPig
Copy link

No description provided.

@occultskyrong
Copy link
Collaborator

occultskyrong commented Apr 14, 2018

提供一个解决思路

前端

  1. 把对应的“导出”按钮做成一个链接
  2. 点击按钮,跳转到对应链接 /source/download ,其为静态资源地址,此时浏览器会自动开启下载

后端

  1. 后端拦截到 /source/download 的路由请求后,
    将链接对应的数据(链接中可以带一定的参数来完成查询SQL的拼接,诸如offset/limit等)整合成一个所需格式(excelxls等)的文件 /public/download/xxx.xls
  2. 然后转发(redirect) /source/download 链接请求到 /public/download/xxx.xls

几点说明:

1、 一定、不要在前端完成全量数据的拼接,数据拉取过程中极有可能timeout
2、因为是分页服务端server-side模式,每次的数据量都是小量,一旦全量下载,后端拼装完成后的excel文件大小和传输方式(文件流)比前端使用ajax或其他下载方式美好太多。。。

@occultskyrong
Copy link
Collaborator

已归档到#356

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