From e8c0d6b987bcc3116b82eb861929b21a8a21b824 Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Thu, 7 Apr 2022 11:37:49 +0800 Subject: [PATCH] order by cate and name --- src/models/alert_aggr_view.go | 3 +++ src/models/metric_view.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/models/alert_aggr_view.go b/src/models/alert_aggr_view.go index b5d83794..837faa23 100644 --- a/src/models/alert_aggr_view.go +++ b/src/models/alert_aggr_view.go @@ -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 }) } diff --git a/src/models/metric_view.go b/src/models/metric_view.go index 91d9d815..95f58648 100644 --- a/src/models/metric_view.go +++ b/src/models/metric_view.go @@ -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 }) }