refactor: 提取分页魔法数字为 pagination 常量
- handler 层: device/log/webhook/user handler 使用 pagination.DefaultPageSize/MaxPageSize - service 层: device/login_log/operation_log service 使用 pagination.DefaultPageSize - repository 层: user repository 使用 pagination.DefaultPageSize/MaxPageSize - 消除 8 处硬编码的 20/100 分页魔法数字
This commit is contained in:
@@ -362,10 +362,10 @@ func (r *UserRepository) AdvancedSearch(ctx context.Context, filter *AdvancedFil
|
||||
// 分页
|
||||
limit := filter.Limit
|
||||
if limit <= 0 {
|
||||
limit = 20
|
||||
limit = pagination.DefaultPageSize
|
||||
}
|
||||
if limit > 200 {
|
||||
limit = 200
|
||||
if limit > pagination.MaxPageSize {
|
||||
limit = pagination.MaxPageSize
|
||||
}
|
||||
query = query.Offset(filter.Offset).Limit(limit)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user