package handler import ( "errors" "net/http" "github.com/freefire/jiang13-bbs/middleware" "github.com/freefire/jiang13-bbs/service" "github.com/gin-gonic/gin" ) // GetCheckin 当前用户签到状态 func (h *Handlers) GetCheckin(c *gin.Context) { claims := middleware.CurrentUser(c) status, err := h.Checkin.Status(claims.ID) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "获取签到状态失败"}) return } c.JSON(http.StatusOK, status) } // DoCheckin 执行今日签到 func (h *Handlers) DoCheckin(c *gin.Context) { claims := middleware.CurrentUser(c) status, err := h.Checkin.CheckIn(claims.ID) if err != nil { if errors.Is(err, service.ErrAlreadyCheckedIn) { c.JSON(http.StatusConflict, gin.H{"error": err.Error()}) return } c.JSON(http.StatusInternalServerError, gin.H{"error": "签到失败"}) return } c.JSON(http.StatusOK, status) }