feat: add private and profile
This commit is contained in:
@@ -138,6 +138,44 @@ func (h *Handler) Purchase(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
// Stats — GET /api/stats (آمار پروفایل؛ نمایشِ کامل ویژهی کاربران VIP)
|
||||
func (h *Handler) Stats(w http.ResponseWriter, r *http.Request) {
|
||||
id, ok := uid(r)
|
||||
if !ok {
|
||||
httpx.Error(w, http.StatusUnauthorized, "unauthorized")
|
||||
return
|
||||
}
|
||||
p, err := h.svc.GetProfile(r.Context(), id)
|
||||
if err != nil {
|
||||
httpx.Error(w, http.StatusNotFound, "user not found")
|
||||
return
|
||||
}
|
||||
resp := map[string]any{"vip": p.VIP}
|
||||
if p.VIP {
|
||||
st, err := h.svc.GetStats(r.Context(), id)
|
||||
if err != nil {
|
||||
httpx.Error(w, http.StatusInternalServerError, "server error")
|
||||
return
|
||||
}
|
||||
resp["stats"] = st
|
||||
}
|
||||
httpx.JSON(w, http.StatusOK, resp)
|
||||
}
|
||||
|
||||
// TablesInfo — GET /api/tables/info (باقیماندهی میزهای خصوصیِ رایگان)
|
||||
func (h *Handler) TablesInfo(w http.ResponseWriter, r *http.Request) {
|
||||
id, ok := uid(r)
|
||||
if !ok {
|
||||
httpx.Error(w, http.StatusUnauthorized, "unauthorized")
|
||||
return
|
||||
}
|
||||
remaining, unlimited := h.svc.PrivateTableInfo(r.Context(), id)
|
||||
httpx.JSON(w, http.StatusOK, map[string]any{
|
||||
"remaining": remaining,
|
||||
"unlimited": unlimited,
|
||||
})
|
||||
}
|
||||
|
||||
// Daily — POST /api/rewards/daily
|
||||
func (h *Handler) Daily(w http.ResponseWriter, r *http.Request) {
|
||||
id, ok := uid(r)
|
||||
|
||||
Reference in New Issue
Block a user