feat: 配置列表分页与钉钉机器人分钟级排队限流
统一 sources/templates/channels/rules 列表为分页响应,避免配置增多时全量返回;按钉钉 access_token 限制每分钟发送并在超限时等待下一分钟,降低触发官方封禁风险。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package store
|
||||
|
||||
// PageFilter is the shared pagination query for list endpoints.
|
||||
type PageFilter struct {
|
||||
Page int `form:"page"`
|
||||
PageSize int `form:"page_size"`
|
||||
}
|
||||
|
||||
// Normalize applies defaults: page=1, page_size=20.
|
||||
func (p *PageFilter) Normalize() {
|
||||
if p.Page <= 0 {
|
||||
p.Page = 1
|
||||
}
|
||||
if p.PageSize <= 0 {
|
||||
p.PageSize = 20
|
||||
}
|
||||
}
|
||||
|
||||
// Offset returns the SQL OFFSET for the current page.
|
||||
func (p PageFilter) Offset() int {
|
||||
return (p.Page - 1) * p.PageSize
|
||||
}
|
||||
Reference in New Issue
Block a user