fix: Fix image sorting anomalies

This commit is contained in:
ssongliu 2025-08-27 10:34:17 +08:00
parent 6f45b90520
commit 72febca669

View file

@ -102,6 +102,13 @@ func (u *ImageService) Page(req dto.PageImage) (int64, interface{}, error) {
}
return records[i].Size > records[j].Size
})
case "isUsed":
sort.Slice(records, func(i, j int) bool {
if req.Order == constant.OrderAsc {
return !records[i].IsUsed
}
return records[i].IsUsed
})
case "tags":
sort.Slice(records, func(i, j int) bool {
if len(records[i].Tags) == 0 || len(records[j].Tags) == 0 {