feat: 宠物加性格/过敏/备注字段 + 身份卡照护信息 + 微信取手机号

- Pet 增 personality/allergy/notes;建档表单加「性格标签(多选)/过敏/备注」
- IDCard 增 color/personality/owner/phone(脱敏)/allergy/notes/疫苗驱虫状态/发证机构
- 微信取手机号:POST /api/user/phone 用 getPhoneNumber 的 code 换手机号存库
  (BindPhoneByCode 走 getuserphonenumber,复用 access_token)

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-31 17:12:56 +08:00
parent 93fc9bc5da
commit ef172f4e4a
9 changed files with 169 additions and 2 deletions
+17
View File
@@ -210,3 +210,20 @@ func (h *Handler) UpdateProfile(c *gin.Context) {
}
response.OK(c, user)
}
// BindPhone POST /api/user/phone 用小程序 getPhoneNumber 的 code 绑定手机号
func (h *Handler) BindPhone(c *gin.Context) {
var req struct {
Code string `json:"code"`
}
if err := c.ShouldBindJSON(&req); err != nil || req.Code == "" {
response.FailParams(c, "缺少 code")
return
}
phone, err := h.svc.BindPhoneByCode(middleware.UserID(c), req.Code)
if err != nil {
response.FailErr(c, err)
return
}
response.OK(c, gin.H{"phone": phone})
}
+15
View File
@@ -26,6 +26,9 @@ type petReq struct {
Breed string `json:"breed"`
AvatarFileID string `json:"avatar_file_id"`
Goals []string `json:"goals"`
Personality string `json:"personality"`
Allergy string `json:"allergy"`
Notes string `json:"notes"`
}
func (r petReq) toInput() service.PetInput {
@@ -33,6 +36,7 @@ func (r petReq) toInput() service.PetInput {
Name: r.Name, Emoji: r.Emoji, Type: r.Type, Gender: r.Gender,
Weight: r.Weight, Stage: r.Stage, Age: r.Age, Color: r.Color, Breed: r.Breed,
AvatarFileID: r.AvatarFileID,
Personality: r.Personality, Allergy: r.Allergy, Notes: r.Notes,
}
if r.Birthday != "" {
if t, err := time.ParseInLocation("2006-01-02", r.Birthday, time.Local); err == nil {
@@ -123,6 +127,17 @@ func (h *Handler) UpdatePet(c *gin.Context) {
if req.Color != "" {
fields["color"] = req.Color
}
// 性格/过敏/备注:空串也允许写(用户可能想清空),用指针语义太重,
// 这里约定前端总是回传当前值,非空才更新;清空场景暂用「无」占位
if req.Personality != "" {
fields["personality"] = req.Personality
}
if req.Allergy != "" {
fields["allergy"] = req.Allergy
}
if req.Notes != "" {
fields["notes"] = req.Notes
}
if req.Breed != "" {
fields["breed"] = req.Breed
}