feat: 部署初版测试
Some checks failed
Extension Build & Release / build (push) Failing after 1m5s
Backend Deploy (Go + Docker) / deploy (push) Failing after 1m40s
Web Console Deploy (Vue 3 + Vite) / deploy (push) Has been cancelled

This commit is contained in:
zs
2026-03-02 21:25:21 +08:00
parent db3abb3174
commit 8cf6cb944b
97 changed files with 10250 additions and 209 deletions

View File

@@ -34,3 +34,38 @@ func (h *UserHandler) Register(w http.ResponseWriter, r *http.Request) {
SendSuccess(w, user)
}
func (h *UserHandler) GetProfile(w http.ResponseWriter, r *http.Request) {
// Assumes JWTAuth middleware has placed userID in context
userID := r.Context().Value("userID").(string)
user, err := h.svc.GetUserByID(userID)
if err != nil {
SendError(w, http.StatusNotFound, 4004, "User not found")
return
}
SendSuccess(w, user)
}
func (h *UserHandler) UpdatePreferences(w http.ResponseWriter, r *http.Request) {
userID := r.Context().Value("userID").(string)
var body struct {
IdentityLabel string `json:"identity_label"`
LanguagePreference string `json:"language_preference"`
}
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
SendError(w, http.StatusBadRequest, 4001, "Invalid request body")
return
}
user, err := h.svc.UpdatePreferences(userID, body.IdentityLabel, body.LanguagePreference)
if err != nil {
SendError(w, http.StatusInternalServerError, 5001, "Failed to update preferences")
return
}
SendSuccess(w, user)
}