search_table_data_logic.go
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package table
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway/bytelib"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type SearchTableDataLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSearchTableDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchTableDataLogic {
return &SearchTableDataLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SearchTableDataLogic) SearchTableData(req *types.SearchTableDataRequest) (resp interface{}, err error) {
tableDataPreviewRequest := &bytelib.TableDataPreviewRequest{
Token: req.Token,
ObjectType: bytelib.ObjectMetaTable,
ObjectId: int64(req.ObjectId),
Where: newWhere(req.Condition).WithPageSize(req.PageNumber, req.PageSize),
}
var (
response bytelib.TablePreviewResponse
)
response, err = l.svcCtx.ByteMetadataService.TableDataPreview(l.ctx, tableDataPreviewRequest)
if err != nil {
return resp, xerr.NewErr(err)
}
resp = map[string]interface{}{
"objectId": response.ObjectId,
"fields": response.Fields,
"total": response.Grid.Total,
"data": response.Grid.List,
}
return
}