fix: Fix image sorting anomalies (#10159)

This commit is contained in:
ssongliu 2025-08-27 13:41:37 +08:00 committed by GitHub
parent c0a0f4c801
commit 8663ed129d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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 {