商城c端前端

This commit is contained in:
richjohnrambo
2026-10-12 23:26:36 +08:00
parent 8f3a97a54d
commit dd729cb679
17 changed files with 744 additions and 41 deletions
+40
View File
@@ -117,6 +117,46 @@ func (a *API) memberLevels(w http.ResponseWriter, r *http.Request) {
writeSuccess(w, r, items)
}
func (a *API) leaderboard(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
methodNotAllowed(w, r, http.MethodGet)
return
}
if !a.ensurePortal(w, r) {
return
}
principal, ok := a.authenticateMember(w, r)
if !ok {
return
}
items, err := a.portal.Leaderboard(r.Context(), principal.TenantID)
if err != nil {
writePortalError(w, r, err)
return
}
writeSuccess(w, r, items)
}
func (a *API) customerServices(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
methodNotAllowed(w, r, http.MethodGet)
return
}
if !a.ensurePortal(w, r) {
return
}
principal, ok := a.authenticateMember(w, r)
if !ok {
return
}
items, err := a.portal.CustomerServices(r.Context(), principal.TenantID)
if err != nil {
writePortalError(w, r, err)
return
}
writeSuccess(w, r, items)
}
func (a *API) ensurePortal(w http.ResponseWriter, r *http.Request) bool {
if a.portal != nil {
return true