refactor: upgrade to Go 1.26 and modernize code idioms
- Replace `interface{}` with `any` type alias across all packages
- Use built-in `min()`/`max()` for parameter clamping
- Use `slices.SortFunc`, `slices.Min`, `slices.Max` for cleaner code
- Use `strings.Cut()` for simpler string parsing in auth middleware
- Use `errors.Is()` for proper error comparison in handlers
- Update dependencies: golang.org/x/image 0.37.0 -> 0.38.0
- Add Wire code generation guidelines to ARCHITECTURE.md
- Disable Go cache in CI build workflow
This commit is contained in:
@@ -36,14 +36,9 @@ func (h *AdminDashboardHandler) GetStats(c *gin.Context) {
|
||||
// GetUserActivityTrend 获取用户活跃度趋势
|
||||
// GET /api/v1/admin/dashboard/user-activity
|
||||
func (h *AdminDashboardHandler) GetUserActivityTrend(c *gin.Context) {
|
||||
// 解析天数参数,默认7天
|
||||
// 解析天数参数,默认7天,限制在1-30天
|
||||
days, _ := strconv.Atoi(c.DefaultQuery("days", "7"))
|
||||
if days <= 0 {
|
||||
days = 7
|
||||
}
|
||||
if days > 30 {
|
||||
days = 30
|
||||
}
|
||||
days = min(max(days, 1), 30)
|
||||
|
||||
trend, err := h.dashboardService.GetUserActivityTrend(c.Request.Context(), days)
|
||||
if err != nil {
|
||||
@@ -69,14 +64,9 @@ func (h *AdminDashboardHandler) GetContentStats(c *gin.Context) {
|
||||
// GetPendingContent 获取待审核内容
|
||||
// GET /api/v1/admin/dashboard/pending-content
|
||||
func (h *AdminDashboardHandler) GetPendingContent(c *gin.Context) {
|
||||
// 解析limit参数,默认10条
|
||||
// 解析limit参数,默认10条,限制在1-50条
|
||||
limit, _ := strconv.Atoi(c.DefaultQuery("limit", "10"))
|
||||
if limit <= 0 {
|
||||
limit = 10
|
||||
}
|
||||
if limit > 50 {
|
||||
limit = 50
|
||||
}
|
||||
limit = min(max(limit, 1), 50)
|
||||
|
||||
content, err := h.dashboardService.GetPendingContent(c.Request.Context(), limit)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user