- 移除未使用的DTO类型(ChangePasswordRequest/DeleteAccountRequest) - 移除service层未引用的错误重导出(auth_service/audit_service) - 删除未使用的SiteSettingRepo(数据访问由config.SiteSettings直接处理) - 删除未使用的FindByStatus方法(user_repo) - 删除未使用的AutoMigrate方法(audit_repo/notification_repo) - 删除未使用的PaginatedResult/NewPaginatedResult(pagination.go) - 修复接口注释:notifProvider(5→4)、auditUseCase(4→3)、siteSettingUseCase(3→4) - 移除auditStatusProvider未使用的FindByUsername方法 - 统一使用common.ErrXxx直接引用,消除跨service错误重导出耦合
28 lines
594 B
Go
28 lines
594 B
Go
package common
|
|
|
|
import "time"
|
|
|
|
// Pagination 分页请求参数
|
|
type Pagination struct {
|
|
Page int `form:"page" json:"page" binding:"min=1"`
|
|
PageSize int `form:"page_size" json:"page_size" binding:"min=1,max=100"`
|
|
}
|
|
|
|
// DefaultPagination 默认分页(未传参时使用)
|
|
func (p *Pagination) DefaultPagination() {
|
|
if p.Page < 1 {
|
|
p.Page = 1
|
|
}
|
|
if p.PageSize < 1 || p.PageSize > 100 {
|
|
p.PageSize = 20
|
|
}
|
|
}
|
|
|
|
// Offset 计算 SQL offset
|
|
func (p *Pagination) Offset() int {
|
|
return (p.Page - 1) * p.PageSize
|
|
}
|
|
|
|
// 固定时间格式,前后端统一
|
|
const TimeFormat = time.RFC3339
|