From 72c53082148a7b4af689c5e81a4ecd58aeb467cb Mon Sep 17 00:00:00 2001 From: Blizzard Date: Fri, 31 Jul 2026 16:08:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(be):=20=E6=B5=B7=E6=8A=A5=20pet=5Favatar=5F?= =?UTF-8?q?url=20=E4=B8=80=E7=9B=B4=E4=B8=BA=E7=A9=BA=E2=80=94=E2=80=94own?= =?UTF-8?q?edPet=20=E4=B8=8D=E8=A7=A3=E6=9E=90=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GetPoster 用 ownedPet 只填了 Age,头像 URL 没解析,导致 pet_avatar_url 恒为空、海报总是退回 emoji。改成显式 s.fileURL(pet.AvatarFileID)。 Co-Authored-By: Claude Opus 5 --- pets-be/internal/service/report.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pets-be/internal/service/report.go b/pets-be/internal/service/report.go index 5a8287d..4f53507 100644 --- a/pets-be/internal/service/report.go +++ b/pets-be/internal/service/report.go @@ -229,8 +229,9 @@ func (s *Service) GetPoster(userID, petID string) (*Poster, error) { s.db.Model(&model.HealthRecord{}).Where("pet_id = ? AND type = ? AND occurred_at >= ?", petID, model.RecordVaccine, weekAgo).Count(&vaccineRecs) s.db.Model(&model.HealthRecord{}).Where("pet_id = ? AND type = ? AND category = ? AND occurred_at >= ?", petID, model.RecordSymptom, "高", weekAgo).Count(&highRisk) + // ownedPet 只填了 Age,头像 URL 得在这里从 file id 解析(否则是空的) return &Poster{ - PetName: pet.Name, PetEmoji: pet.Emoji, PetAvatarURL: pet.AvatarURL, + PetName: pet.Name, PetEmoji: pet.Emoji, PetAvatarURL: s.fileURL(pet.AvatarFileID), Age: pet.Age, Weight: pet.Weight, Stage: pet.Stage, Period: weekAgo.Format("01.02") + " - " + now.Format("01.02"), TasksCompleted: tasksDone, WeightRecords: weightRecs, VaccineRecords: vaccineRecs,