feat(ECR-011): 昵称、首页贴士与档案 Self 唯一/合盘交叉校验
ci / h5 (push) Canceled after 0s
ci / api (push) Canceled after 0s
ci / ess-docs (push) Canceled after 0s

每账号仅一条 self(migration 40902);合盘只选 TA;账号昵称可改;首页穿衣/颜色/养生贴士。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-12 22:05:00 +08:00
co-authored by Cursor
parent 5ceb3ce749
commit 13860bf1ef
67 changed files with 1936 additions and 275 deletions
+25
View File
@@ -23,6 +23,7 @@ func (h *AuthHandler) Register(api *gin.RouterGroup) {
g.POST("/login", h.Login)
g.POST("/logout", h.Logout)
g.GET("/me", h.Me)
g.PATCH("/me", h.PatchMe)
}
type authBody struct {
@@ -97,6 +98,30 @@ func (h *AuthHandler) Me(c *gin.Context) {
response.OK(c, me)
}
type patchMeBody struct {
Nickname string `json:"nickname"`
}
// PatchMe handles PATCH /auth/me (update nickname).
func (h *AuthHandler) PatchMe(c *gin.Context) {
userID, ok := middleware.UserIDFromContext(c)
if !ok {
response.Fail(c, http.StatusUnauthorized, 40100, "unauthorized")
return
}
var body patchMeBody
if err := c.ShouldBindJSON(&body); err != nil {
response.Fail(c, http.StatusBadRequest, 10000, "invalid request")
return
}
me, err := h.Svc.UpdateNickname(c.Request.Context(), userID, body.Nickname)
if err != nil {
response.Fail(c, http.StatusBadRequest, 40113, err.Error())
return
}
response.OK(c, me)
}
func bearerToken(c *gin.Context) string {
h := c.GetHeader("Authorization")
if strings.HasPrefix(strings.ToLower(h), "bearer ") {