Add bio field and daily streak check-in for gamification
- User.Bio: a short (300 char) freeform profile bio, editable via PATCH /profile/bio, shown on discover cards and candidate detail (richer profiles beyond the fixed onboarding fields). - User.StreakCount/LastActiveDate: POST /profile/checkin increments the streak on consecutive days, resets after a gap, no-ops if already checked in today. Backs a daily-return hook on the frontend.
This commit is contained in:
@@ -43,6 +43,8 @@ func toUserProfile(u *models.User) dto.UserProfile {
|
||||
State: string(u.State),
|
||||
BlockedReason: u.BlockedReason,
|
||||
BlockedAt: u.BlockedAt,
|
||||
Bio: u.Bio,
|
||||
StreakCount: u.StreakCount,
|
||||
}
|
||||
if u.Gender != nil {
|
||||
g := string(*u.Gender)
|
||||
|
||||
@@ -138,3 +138,35 @@ func (h *ProfileHandler) UpdateLocation(c *gin.Context) {
|
||||
}
|
||||
utils.Success(c, http.StatusOK, "موقعیت مکانی ثبت شد", nil)
|
||||
}
|
||||
|
||||
// UpdateBio PATCH /profile/bio body: {bio}
|
||||
func (h *ProfileHandler) UpdateBio(c *gin.Context) {
|
||||
user, ok := currentUser(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
var req dto.UpdateBioRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
utils.Fail(c, http.StatusBadRequest, "بیوگرافی نباید بیشتر از ۳۰۰ کاراکتر باشه", err.Error())
|
||||
return
|
||||
}
|
||||
if err := h.profileService.UpdateBio(user, req.Bio); err != nil {
|
||||
utils.Fail(c, http.StatusInternalServerError, "خطا در ذخیرهی بیوگرافی", nil)
|
||||
return
|
||||
}
|
||||
utils.Success(c, http.StatusOK, "بیوگرافی ذخیره شد", nil)
|
||||
}
|
||||
|
||||
// CheckIn POST /profile/checkin — ثبت ورود روزانه برای استریک گیمیفیکیشن
|
||||
func (h *ProfileHandler) CheckIn(c *gin.Context) {
|
||||
user, ok := currentUser(c)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
result, err := h.profileService.CheckIn(user)
|
||||
if err != nil {
|
||||
utils.Fail(c, http.StatusInternalServerError, "خطا در ثبت ورود روزانه", nil)
|
||||
return
|
||||
}
|
||||
utils.Success(c, http.StatusOK, "", result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user