feat: 优化批量匹配和分页默认值 (#244)
This commit is contained in:
@@ -14,9 +14,9 @@ import (
|
||||
|
||||
// DefaultPageSize 是主列表没有指定 page_size 时使用的每页条数。
|
||||
//
|
||||
// 20 行在 1366×768 上通常不需要滚动,因此继续作为默认值;实际页面请求必须
|
||||
// 通过 ParsePageSize 白名单解析。
|
||||
const DefaultPageSize = 20
|
||||
// 采购员通常需要在同一页批量勾选较多记录,因此默认显示白名单中的最大值 100;
|
||||
// 实际页面请求仍必须通过 ParsePageSize 白名单解析,不能把任意输入交给 SQL。
|
||||
const DefaultPageSize = 100
|
||||
|
||||
var allowedPageSizes = [...]int{20, 50, 100}
|
||||
|
||||
@@ -34,7 +34,7 @@ func ParsePage(s string) int {
|
||||
}
|
||||
|
||||
// ParsePageSize 解析 URL 上的 page_size,只接受界面提供的三个白名单值。
|
||||
// 非法值回退为 20,避免有人手改 URL 造成一次读取过多数据。
|
||||
// 非法值回退为默认 100;SQL 查询仍只可能使用固定白名单值。
|
||||
func ParsePageSize(s string) int {
|
||||
n, err := strconv.Atoi(strings.TrimSpace(s))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user