lijikun 5 months ago
parent
commit
d1edd491fc
  1. 11
      link_homework/internal/logic/homework/homework.go

11
link_homework/internal/logic/homework/homework.go

@ -71,9 +71,18 @@ func UpdateHomework(ctx context.Context, homeworkList []*entity.ActivityInteract
} }
} }
// 对 homeworkList 按 Status 升序排序
// 对 homeworkList 进行排序
sort.Slice(homeworkList, func(i, j int) bool { sort.Slice(homeworkList, func(i, j int) bool {
if homeworkList[i].Status != homeworkList[j].Status {
return homeworkList[i].Status < homeworkList[j].Status return homeworkList[i].Status < homeworkList[j].Status
}
if homeworkList[i].Status == 0 {
return homeworkList[i].StartDate.Before(homeworkList[j].StartDate)
}
if homeworkList[i].Status == 1 {
return homeworkList[i].EndDate.Before(homeworkList[j].EndDate)
}
return false
}) })
return homeworkList return homeworkList

Loading…
Cancel
Save