feat: support shared pet care tasks and smooth daily page return
ci-cd / verify (push) Successful in 2m18s
ci-cd / deploy (push) Skipped

This commit is contained in:
2026-10-05 20:20:05 +08:00
parent fbc1eda561
commit 3175936266
16 changed files with 196 additions and 119 deletions
+8 -2
View File
@@ -360,7 +360,9 @@ func (a *API) adminTasks(c *gin.Context) {
ids, petIDs, taskIDs := []string{}, []string{}, []string{}
for _, t := range rows {
ids = append(ids, t.UserID)
petIDs = append(petIDs, t.PetID)
if t.PetID != nil {
petIDs = append(petIDs, *t.PetID)
}
taskIDs = append(taskIDs, t.ID)
}
names, err := a.userNames(ids)
@@ -388,7 +390,11 @@ func (a *API) adminTasks(c *gin.Context) {
}
items := make([]gin.H, 0, len(rows))
for _, t := range rows {
items = append(items, gin.H{"id": t.ID, "user_id": t.UserID, "user_name": names[t.UserID], "pet_id": t.PetID, "pet_name": petNames[t.PetID], "title": t.Title, "category": t.Category, "time_of_day": t.TimeOfDay, "repeat_rule": t.RepeatRule, "reminder_enabled": t.ReminderEnabled, "completed": done[t.ID], "created_at": t.CreatedAt})
petName := "全部宠物"
if t.PetID != nil {
petName = petNames[*t.PetID]
}
items = append(items, gin.H{"id": t.ID, "user_id": t.UserID, "user_name": names[t.UserID], "pet_id": t.PetID, "all_pets": t.PetID == nil, "pet_name": petName, "title": t.Title, "category": t.Category, "time_of_day": t.TimeOfDay, "repeat_rule": t.RepeatRule, "reminder_enabled": t.ReminderEnabled, "completed": done[t.ID], "created_at": t.CreatedAt})
}
page.Items = items
ok(c, page)