feat: 添加用户记账连击(streak)功能,包括服务、处理器、模型和仓库层。
This commit is contained in:
@@ -66,8 +66,27 @@ func (h *StreakHandler) RecalculateStreak(c *gin.Context) {
|
||||
api.Success(c, streakInfo)
|
||||
}
|
||||
|
||||
// GetContributionData handles GET /api/v1/user/streak/contribution
|
||||
// Returns daily contribution data for heat map
|
||||
func (h *StreakHandler) GetContributionData(c *gin.Context) {
|
||||
userID, exists := c.Get("user_id")
|
||||
if !exists {
|
||||
api.Unauthorized(c, "User not authenticated")
|
||||
return
|
||||
}
|
||||
|
||||
contributionData, err := h.streakService.GetContributionData(userID.(uint))
|
||||
if err != nil {
|
||||
api.InternalError(c, "Failed to get contribution data: "+err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
api.Success(c, contributionData)
|
||||
}
|
||||
|
||||
// RegisterRoutes registers streak-related routes
|
||||
func (h *StreakHandler) RegisterRoutes(rg *gin.RouterGroup) {
|
||||
rg.GET("/user/streak", h.GetStreak)
|
||||
rg.POST("/user/streak/recalculate", h.RecalculateStreak)
|
||||
rg.GET("/user/streak/contribution", h.GetContributionData)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user