Browse Source

优化查询逻辑

dev_ljk
majun 5 months ago
parent
commit
08530b80f0
  1. 13
      link_homework/internal/logic/homework/homework.go

13
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 {
return homeworkList[i].Status < homeworkList[j].Status
if 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