fix(be): 海报 pet_avatar_url 一直为空——ownedPet 不解析头像

GetPoster 用 ownedPet 只填了 Age,头像 URL 没解析,导致 pet_avatar_url
恒为空、海报总是退回 emoji。改成显式 s.fileURL(pet.AvatarFileID)。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Blizzard
2026-07-31 16:08:23 +08:00
parent c890732410
commit 72c5308214
+2 -1
View File
@@ -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,