fix order metric_view

This commit is contained in:
Ulric Qin 2022-04-07 12:01:16 +08:00
parent 14b1bc3710
commit 30ba544f35
2 changed files with 12 additions and 2 deletions

View File

@ -106,11 +106,16 @@ func AlertAggrViewDel(ids []int64, createBy interface{}) error {
func AlertAggrViewGets(createBy interface{}) ([]AlertAggrView, error) {
var lst []AlertAggrView
err := DB().Where("create_by = ? or cate = 0", createBy).Find(&lst).Error
if err == nil && len(lst) > 0 {
if err == nil && len(lst) > 1 {
sort.Slice(lst, func(i, j int) bool {
if lst[i].Cate < lst[j].Cate {
return true
}
if lst[i].Cate > lst[j].Cate {
return false
}
return lst[i].Name < lst[j].Name
})
}

View File

@ -72,11 +72,16 @@ func MetricViewDel(ids []int64, createBy interface{}) error {
func MetricViewGets(createBy interface{}) ([]MetricView, error) {
var lst []MetricView
err := DB().Where("create_by = ? or cate = 0", createBy).Find(&lst).Error
if err == nil && len(lst) > 0 {
if err == nil && len(lst) > 1 {
sort.Slice(lst, func(i, j int) bool {
if lst[i].Cate < lst[j].Cate {
return true
}
if lst[i].Cate > lst[j].Cate {
return false
}
return lst[i].Name < lst[j].Name
})
}