order by cate and name

This commit is contained in:
Ulric Qin 2022-04-07 11:37:49 +08:00
parent d0efb206d9
commit e8c0d6b987
2 changed files with 6 additions and 0 deletions

View File

@ -108,6 +108,9 @@ func AlertAggrViewGets(createBy interface{}) ([]AlertAggrView, error) {
err := DB().Where("create_by = ? or cate = 0", createBy).Find(&lst).Error
if err == nil && len(lst) > 0 {
sort.Slice(lst, func(i, j int) bool {
if lst[i].Cate < lst[j].Cate {
return true
}
return lst[i].Name < lst[j].Name
})
}

View File

@ -74,6 +74,9 @@ func MetricViewGets(createBy interface{}) ([]MetricView, error) {
err := DB().Where("create_by = ? or cate = 0", createBy).Find(&lst).Error
if err == nil && len(lst) > 0 {
sort.Slice(lst, func(i, j int) bool {
if lst[i].Cate < lst[j].Cate {
return true
}
return lst[i].Name < lst[j].Name
})
}