提交 30ba544f 编写于 作者: U Ulric Qin

fix order metric_view

上级 14b1bc37
......@@ -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
})
}
......
......@@ -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
})
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册