|
@@ -2,13 +2,13 @@ package table |
|
@@ -2,13 +2,13 @@ package table |
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
4
|
"context"
|
4
|
"context"
|
5
|
- "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway/bytelib"
|
|
|
6
|
- "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/xerr"
|
|
|
7
|
-
|
5
|
+ "github.com/zeromicro/go-zero/core/logx"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types"
|
10
|
-
|
|
|
11
|
- "github.com/zeromicro/go-zero/core/logx"
|
8
|
+ "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway/bytelib"
|
|
|
9
|
+ "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/xerr"
|
|
|
10
|
+ "sort"
|
|
|
11
|
+ "strings"
|
12
|
)
|
12
|
)
|
13
|
|
13
|
|
14
|
type SearchTableDataLogic struct {
|
14
|
type SearchTableDataLogic struct {
|
|
@@ -48,6 +48,28 @@ func (l *SearchTableDataLogic) SearchTableData(req *types.SearchTableDataRequest |
|
@@ -48,6 +48,28 @@ func (l *SearchTableDataLogic) SearchTableData(req *types.SearchTableDataRequest |
48
|
if err != nil {
|
48
|
if err != nil {
|
49
|
return resp, xerr.NewErr(err)
|
49
|
return resp, xerr.NewErr(err)
|
50
|
}
|
50
|
}
|
|
|
51
|
+ //排序
|
|
|
52
|
+ orderField := ""
|
|
|
53
|
+ orderBy := ""
|
|
|
54
|
+ for _, item := range req.Condition {
|
|
|
55
|
+ if item.Order != "" {
|
|
|
56
|
+ orderField = item.FieldName
|
|
|
57
|
+ orderBy = item.Order
|
|
|
58
|
+ break
|
|
|
59
|
+ }
|
|
|
60
|
+ }
|
|
|
61
|
+ sort.Slice(response.Grid.List, func(i, j int) bool {
|
|
|
62
|
+ if _, ok := response.Grid.List[i][orderField]; ok {
|
|
|
63
|
+ if _, ok := response.Grid.List[j][orderField]; ok {
|
|
|
64
|
+ if strings.ToLower(orderBy) == "asc" {
|
|
|
65
|
+ return response.Grid.List[i][orderField] < response.Grid.List[j][orderField]
|
|
|
66
|
+ } else {
|
|
|
67
|
+ return response.Grid.List[i][orderField] > response.Grid.List[j][orderField]
|
|
|
68
|
+ }
|
|
|
69
|
+ }
|
|
|
70
|
+ }
|
|
|
71
|
+ return true
|
|
|
72
|
+ })
|
51
|
resp = map[string]interface{}{
|
73
|
resp = map[string]interface{}{
|
52
|
"objectId": response.ObjectId,
|
74
|
"objectId": response.ObjectId,
|
53
|
"fields": removeIdField(response.Fields),
|
75
|
"fields": removeIdField(response.Fields),
|