正在显示
29 个修改的文件
包含
1132 行增加
和
87 行删除
| 1 | -Name: Core | 1 | +Name: chart |
| 2 | Host: 0.0.0.0 | 2 | Host: 0.0.0.0 |
| 3 | -Port: 8080 | ||
| 4 | - | 3 | +Port: 8081 |
| 5 | Verbose: false | 4 | Verbose: false |
| 6 | 5 | ||
| 7 | JwtAuth: | 6 | JwtAuth: |
| @@ -14,3 +13,9 @@ Redis: | @@ -14,3 +13,9 @@ Redis: | ||
| 14 | Pass: | 13 | Pass: |
| 15 | DB: | 14 | DB: |
| 16 | DataSource: host=106.52.103.187 user=postgres password=UYXN134KUm8TeE7 dbname=skateboard-test port=25431 sslmode=disable TimeZone=Asia/Shanghai | 15 | DataSource: host=106.52.103.187 user=postgres password=UYXN134KUm8TeE7 dbname=skateboard-test port=25431 sslmode=disable TimeZone=Asia/Shanghai |
| 16 | + | ||
| 17 | +ByteMetadata: | ||
| 18 | + Name: ApiByteMetadata | ||
| 19 | + Host1: http://127.0.0.1:8080 | ||
| 20 | + Host: http://character-library-metadata-bastion-test.fjmaimaimai.com | ||
| 21 | + Timeout: 0s |
| @@ -4,10 +4,18 @@ import ( | @@ -4,10 +4,18 @@ import ( | ||
| 4 | "github.com/zeromicro/go-zero/core/stores/redis" | 4 | "github.com/zeromicro/go-zero/core/stores/redis" |
| 5 | "github.com/zeromicro/go-zero/rest" | 5 | "github.com/zeromicro/go-zero/rest" |
| 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/config" | 6 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/config" |
| 7 | + "time" | ||
| 7 | ) | 8 | ) |
| 8 | 9 | ||
| 9 | type Config struct { | 10 | type Config struct { |
| 10 | rest.RestConf | 11 | rest.RestConf |
| 11 | config.Config | 12 | config.Config |
| 12 | Redis redis.RedisConf `json:",optional"` | 13 | Redis redis.RedisConf `json:",optional"` |
| 14 | + ByteMetadata ApiService | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +type ApiService struct { | ||
| 18 | + Name string | ||
| 19 | + Host string | ||
| 20 | + Timeout time.Duration | ||
| 13 | } | 21 | } |
| 1 | +package chart | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/logic/chart" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SearchChartComponentsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ChartComponentSearchRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := chart.NewSearchChartComponentsLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SearchChartComponents(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| @@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
| 5 | "net/http" | 5 | "net/http" |
| 6 | 6 | ||
| 7 | chart "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/chart" | 7 | chart "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/chart" |
| 8 | + table "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/handler/table" | ||
| 8 | "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/svc" |
| 9 | 10 | ||
| 10 | "github.com/zeromicro/go-zero/rest" | 11 | "github.com/zeromicro/go-zero/rest" |
| @@ -48,6 +49,38 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -48,6 +49,38 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 48 | Path: "/chart/rename", | 49 | Path: "/chart/rename", |
| 49 | Handler: chart.RenameChartSortHandler(serverCtx), | 50 | Handler: chart.RenameChartSortHandler(serverCtx), |
| 50 | }, | 51 | }, |
| 52 | + { | ||
| 53 | + Method: http.MethodPost, | ||
| 54 | + Path: "/chart/components/search", | ||
| 55 | + Handler: chart.SearchChartComponentsHandler(serverCtx), | ||
| 56 | + }, | ||
| 57 | + }, | ||
| 58 | + rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret), | ||
| 59 | + rest.WithPrefix("/v1"), | ||
| 60 | + ) | ||
| 61 | + | ||
| 62 | + server.AddRoutes( | ||
| 63 | + []rest.Route{ | ||
| 64 | + { | ||
| 65 | + Method: http.MethodPost, | ||
| 66 | + Path: "/table/search-by-module", | ||
| 67 | + Handler: table.SearchTableByModuleHandler(serverCtx), | ||
| 68 | + }, | ||
| 69 | + { | ||
| 70 | + Method: http.MethodPost, | ||
| 71 | + Path: "/table/field-optional-values", | ||
| 72 | + Handler: table.SearchTableFieldOptionalValuesHandler(serverCtx), | ||
| 73 | + }, | ||
| 74 | + { | ||
| 75 | + Method: http.MethodGet, | ||
| 76 | + Path: "/table/:tableId", | ||
| 77 | + Handler: table.GetTableDetailHandler(serverCtx), | ||
| 78 | + }, | ||
| 79 | + { | ||
| 80 | + Method: http.MethodPost, | ||
| 81 | + Path: "/table/data", | ||
| 82 | + Handler: table.SearchTableDataHandler(serverCtx), | ||
| 83 | + }, | ||
| 51 | }, | 84 | }, |
| 52 | rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret), | 85 | rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret), |
| 53 | rest.WithPrefix("/v1"), | 86 | rest.WithPrefix("/v1"), |
| 1 | +package table | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/logic/table" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func GetTableDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.GetTableDetailRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := table.NewGetTableDetailLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.GetTableDetail(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package table | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/logic/table" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SearchTableByModuleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SearchTableByModuleRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := table.NewSearchTableByModuleLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SearchTableByModule(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package table | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/logic/table" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SearchTableDataHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SearchTableDataRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := table.NewSearchTableDataLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SearchTableData(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
cmd/chart-server/api/internal/handler/table/search_table_field_optional_values_handler.go
0 → 100644
| 1 | +package table | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/logic/table" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SearchTableFieldOptionalValuesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SearchTableFieldOptionalValuesRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := table.NewSearchTableFieldOptionalValuesLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SearchTableFieldOptionalValues(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package chart | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" | ||
| 6 | + "strings" | ||
| 7 | + | ||
| 8 | + "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" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SearchChartComponentsLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewSearchChartComponentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchChartComponentsLogic { | ||
| 21 | + return &SearchChartComponentsLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *SearchChartComponentsLogic) SearchChartComponents(req *types.ChartComponentSearchRequest) (resp *types.ChartComponentSearchResponse, err error) { | ||
| 29 | + var list = []types.ChartComponentItem{ | ||
| 30 | + { | ||
| 31 | + Name: "记录型表格", | ||
| 32 | + Code: domain.RecordTable1, | ||
| 33 | + Cover: "", | ||
| 34 | + }, | ||
| 35 | + { | ||
| 36 | + Name: "总体指标", | ||
| 37 | + Code: domain.MetricsCard1, | ||
| 38 | + Cover: "", | ||
| 39 | + }, | ||
| 40 | + { | ||
| 41 | + Name: "容器卡片", | ||
| 42 | + Code: domain.ContainerCard1, | ||
| 43 | + Cover: "", | ||
| 44 | + }, | ||
| 45 | + { | ||
| 46 | + Name: "四分图", | ||
| 47 | + Code: domain.QuarterChart1, | ||
| 48 | + Cover: "", | ||
| 49 | + }, | ||
| 50 | + } | ||
| 51 | + var result = make([]types.ChartComponentItem, 0) | ||
| 52 | + for _, com := range list { | ||
| 53 | + if req.Name != "" { | ||
| 54 | + if !strings.Contains(com.Name, req.Name) { | ||
| 55 | + continue | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + result = append(result, com) | ||
| 59 | + } | ||
| 60 | + resp = &types.ChartComponentSearchResponse{ | ||
| 61 | + List: result, | ||
| 62 | + Total: int64(len(result)), | ||
| 63 | + } | ||
| 64 | + return | ||
| 65 | +} |
| 1 | +package table | ||
| 2 | + | ||
| 3 | +import ( | ||
| 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 | + | ||
| 8 | + "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" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type GetTableDetailLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewGetTableDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTableDetailLogic { | ||
| 21 | + return &GetTableDetailLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *GetTableDetailLogic) GetTableDetail(req *types.GetTableDetailRequest) (resp interface{}, err error) { | ||
| 29 | + response, err := l.svcCtx.ByteMetadataService.TableInfo(l.ctx, &bytelib.TableInfoRequest{TableId: req.TableId}) | ||
| 30 | + if err != nil { | ||
| 31 | + logx.Error(err) | ||
| 32 | + return resp, xerr.NewErr(err) | ||
| 33 | + } | ||
| 34 | + resp = response | ||
| 35 | + return | ||
| 36 | +} |
| 1 | +package table | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/zeromicro/go-zero/core/errorx" | ||
| 6 | + "github.com/zeromicro/go-zero/core/fx" | ||
| 7 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 8 | + "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" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway/bytelib" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/xerr" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SearchTableByModuleLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewSearchTableByModuleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchTableByModuleLogic { | ||
| 21 | + return &SearchTableByModuleLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *SearchTableByModuleLogic) SearchTableByModule(req *types.SearchTableByModuleRequest) (resp interface{}, err error) { | ||
| 29 | + var result = make(map[string]interface{}) | ||
| 30 | + var batchError errorx.BatchError | ||
| 31 | + fx.Parallel(func() { | ||
| 32 | + list, err := l.svcCtx.ByteMetadataService.ObjectTableSearch(l.ctx, bytelib.ObjectTableSearchRequest{ | ||
| 33 | + TableTypes: []string{bytelib.MainTable, bytelib.SubTable, bytelib.SideTable}, | ||
| 34 | + Module: bytelib.ModuleDigitalCenter, | ||
| 35 | + }) | ||
| 36 | + if err != nil { | ||
| 37 | + batchError.Add(err) | ||
| 38 | + } | ||
| 39 | + result["导入模块"] = newList(list) | ||
| 40 | + }, func() { | ||
| 41 | + list, err := l.svcCtx.ByteMetadataService.ObjectTableSearch(l.ctx, bytelib.ObjectTableSearchRequest{ | ||
| 42 | + TableTypes: []string{bytelib.SchemaTable}, | ||
| 43 | + Module: bytelib.ModuleQuerySetCenter, | ||
| 44 | + }) | ||
| 45 | + if err != nil { | ||
| 46 | + batchError.Add(err) | ||
| 47 | + } | ||
| 48 | + result["拆解模块"] = newList(list) | ||
| 49 | + }, func() { | ||
| 50 | + list, err := l.svcCtx.ByteMetadataService.ObjectTableSearch(l.ctx, bytelib.ObjectTableSearchRequest{ | ||
| 51 | + TableTypes: []string{bytelib.CalculateItem, bytelib.CalculateSet}, | ||
| 52 | + Module: bytelib.ModuleCalculateCenter, | ||
| 53 | + }) | ||
| 54 | + if err != nil { | ||
| 55 | + batchError.Add(err) | ||
| 56 | + } | ||
| 57 | + result["计算模块"] = newList(list) | ||
| 58 | + }) | ||
| 59 | + if err = batchError.Err(); err != nil { | ||
| 60 | + logx.Error(err) | ||
| 61 | + return resp, xerr.NewErr(err) | ||
| 62 | + } | ||
| 63 | + resp = result | ||
| 64 | + return | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +func newList(r bytelib.ObjectTableSearchResponse) interface{} { | ||
| 68 | + return map[string]interface{}{ | ||
| 69 | + "count": r.Count, | ||
| 70 | + "list": r.List, | ||
| 71 | + } | ||
| 72 | +} |
| 1 | +package table | ||
| 2 | + | ||
| 3 | +import ( | ||
| 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 | + | ||
| 8 | + "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" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SearchTableDataLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewSearchTableDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchTableDataLogic { | ||
| 21 | + return &SearchTableDataLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *SearchTableDataLogic) SearchTableData(req *types.SearchTableDataRequest) (resp interface{}, err error) { | ||
| 29 | + tableDataPreviewRequest := &bytelib.TableDataPreviewRequest{ | ||
| 30 | + ObjectType: bytelib.ObjectMetaTable, | ||
| 31 | + ObjectId: int64(req.ObjectId), | ||
| 32 | + Where: newWhere(req.Condition).WithPageSize(req.PageNumber, req.PageSize), | ||
| 33 | + } | ||
| 34 | + var ( | ||
| 35 | + response bytelib.TablePreviewResponse | ||
| 36 | + ) | ||
| 37 | + response, err = l.svcCtx.ByteMetadataService.TableDataPreview(l.ctx, tableDataPreviewRequest) | ||
| 38 | + if err != nil { | ||
| 39 | + return resp, xerr.NewErr(err) | ||
| 40 | + } | ||
| 41 | + resp = map[string]interface{}{ | ||
| 42 | + "objectId": response.ObjectId, | ||
| 43 | + "fields": response.Fields, | ||
| 44 | + "total": response.Grid.Total, | ||
| 45 | + "data": response.Grid.List, | ||
| 46 | + } | ||
| 47 | + return | ||
| 48 | +} |
| 1 | +package table | ||
| 2 | + | ||
| 3 | +import ( | ||
| 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 | + | ||
| 8 | + "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" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SearchTableFieldOptionalValuesLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewSearchTableFieldOptionalValuesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchTableFieldOptionalValuesLogic { | ||
| 21 | + return &SearchTableFieldOptionalValuesLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *SearchTableFieldOptionalValuesLogic) SearchTableFieldOptionalValues(req *types.SearchTableFieldOptionalValuesRequest) (resp *types.SearchTableFieldOptionalValuesResponse, err error) { | ||
| 29 | + fieldOptionalValuesRequest := &bytelib.TableFieldOptionalValuesRequest{ | ||
| 30 | + ObjectType: bytelib.ObjectMetaTable, | ||
| 31 | + ObjectId: req.ObjectId, | ||
| 32 | + Field: bytelib.Field{ | ||
| 33 | + Name: req.Field, | ||
| 34 | + SQLName: req.SqlName, | ||
| 35 | + }, | ||
| 36 | + //PageSize: req.PageSize, | ||
| 37 | + //PageNumber: req.PageNumber, | ||
| 38 | + Where: newWhere(req.Condition), | ||
| 39 | + } | ||
| 40 | + var ( | ||
| 41 | + response bytelib.TableFieldOptionalValuesResponse | ||
| 42 | + ) | ||
| 43 | + response, err = l.svcCtx.ByteMetadataService.TableFieldOptionalValues(l.ctx, fieldOptionalValuesRequest) | ||
| 44 | + if err != nil { | ||
| 45 | + return resp, xerr.NewErr(err) | ||
| 46 | + } | ||
| 47 | + resp = &types.SearchTableFieldOptionalValuesResponse{ | ||
| 48 | + Values: response.Values, | ||
| 49 | + Total: response.Total, | ||
| 50 | + } | ||
| 51 | + return | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +func newWhere(conditions []*types.Condition) *bytelib.TableQueryWhere { | ||
| 55 | + where := &bytelib.TableQueryWhere{} | ||
| 56 | + for _, c := range conditions { | ||
| 57 | + order := c.Order | ||
| 58 | + if order == "" { | ||
| 59 | + order = "ASC" | ||
| 60 | + } | ||
| 61 | + where.Conditions = append(where.Conditions, &bytelib.TableQueryCondition{ | ||
| 62 | + Field: &bytelib.Field{ | ||
| 63 | + Name: c.FieldName, | ||
| 64 | + SQLName: c.SqlName, | ||
| 65 | + }, | ||
| 66 | + Like: c.Like, | ||
| 67 | + In: c.In, | ||
| 68 | + Order: order, | ||
| 69 | + }) | ||
| 70 | + } | ||
| 71 | + return where | ||
| 72 | +} |
| @@ -7,6 +7,8 @@ import ( | @@ -7,6 +7,8 @@ import ( | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/repository" | 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/repository" |
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/transaction" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/transaction" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain" |
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/gateway/bytelib" | ||
| 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/cache" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/cache" |
| 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/database" | 13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/database" |
| 12 | "gorm.io/gorm" | 14 | "gorm.io/gorm" |
| @@ -18,6 +20,8 @@ type ServiceContext struct { | @@ -18,6 +20,8 @@ type ServiceContext struct { | ||
| 18 | Redis *redis.Redis | 20 | Redis *redis.Redis |
| 19 | RedisCache gzcache.GZCache | 21 | RedisCache gzcache.GZCache |
| 20 | ChartRepository domain.ChartRepository | 22 | ChartRepository domain.ChartRepository |
| 23 | + | ||
| 24 | + ByteMetadataService bytelib.ByteMetadataService | ||
| 21 | } | 25 | } |
| 22 | 26 | ||
| 23 | func NewServiceContext(c config.Config) *ServiceContext { | 27 | func NewServiceContext(c config.Config) *ServiceContext { |
| @@ -32,6 +36,10 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -32,6 +36,10 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
| 32 | RedisCache: redisCache, | 36 | RedisCache: redisCache, |
| 33 | Redis: redis, | 37 | Redis: redis, |
| 34 | ChartRepository: repository.NewChartRepository(cache.NewCachedRepository(mlCache)), | 38 | ChartRepository: repository.NewChartRepository(cache.NewCachedRepository(mlCache)), |
| 39 | + | ||
| 40 | + ByteMetadataService: bytelib.ByteMetadataService{ | ||
| 41 | + Service: gateway.NewService(c.ByteMetadata.Name, c.ByteMetadata.Host, c.ByteMetadata.Timeout), | ||
| 42 | + }, | ||
| 35 | } | 43 | } |
| 36 | } | 44 | } |
| 37 | 45 |
cmd/chart-server/api/internal/types/table.go
0 → 100644
| 1 | +package types |
| @@ -46,7 +46,7 @@ type ChartSearchResponse struct { | @@ -46,7 +46,7 @@ type ChartSearchResponse struct { | ||
| 46 | type ChartUpdateSortRequest struct { | 46 | type ChartUpdateSortRequest struct { |
| 47 | Id int64 `json:"id"` | 47 | Id int64 `json:"id"` |
| 48 | Pid int64 `json:"pid"` | 48 | Pid int64 `json:"pid"` |
| 49 | - Index int `json:"index"` // 元素下标,从0开始 | 49 | + Index int `json:"index"` // 元素下标 |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | type ChartUpdateSortResponse struct { | 52 | type ChartUpdateSortResponse struct { |
| @@ -66,5 +66,64 @@ type ChartItem struct { | @@ -66,5 +66,64 @@ type ChartItem struct { | ||
| 66 | Type string `json:"type,optional"` // 类型 report:报表 group:分组 chart:图表 | 66 | Type string `json:"type,optional"` // 类型 report:报表 group:分组 chart:图表 |
| 67 | Sort int64 `json:"sort,optional"` // 排序 | 67 | Sort int64 `json:"sort,optional"` // 排序 |
| 68 | Name string `json:"name,optional"` // 名称 | 68 | Name string `json:"name,optional"` // 名称 |
| 69 | - //Charts []ChartItem `json:"charts,optional"` | 69 | + Charts []ChartItem `json:"charts,optional"` |
| 70 | +} | ||
| 71 | + | ||
| 72 | +type ChartComponentSearchRequest struct { | ||
| 73 | + Name string `json:"name"` | ||
| 74 | +} | ||
| 75 | + | ||
| 76 | +type ChartComponentSearchResponse struct { | ||
| 77 | + List []ChartComponentItem `json:"list"` | ||
| 78 | + Total int64 `json:"total"` | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +type ChartComponentItem struct { | ||
| 82 | + Name string `json:"name,optional"` // 名称 | ||
| 83 | + Code string `json:"code,optional"` // 编码 | ||
| 84 | + Cover string `json:"cover,optional"` // 封面 | ||
| 85 | + Desc string `json:"desc,optional"` // 描述 | ||
| 86 | +} | ||
| 87 | + | ||
| 88 | +type SearchTableByModuleRequest struct { | ||
| 89 | +} | ||
| 90 | + | ||
| 91 | +type SearchTableByModuleResponse struct { | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +type SearchTableFieldOptionalValuesRequest struct { | ||
| 95 | + ObjectId int `json:"objectId"` // 对象ID | ||
| 96 | + Field string `json:"field"` // 当前选择的字段 | ||
| 97 | + SqlName string `json:"sqlName"` // 字段SqlName | ||
| 98 | + Condition []*Condition `json:"conditions,optional"` // 条件 | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +type SearchTableFieldOptionalValuesResponse struct { | ||
| 102 | + Values []string `json:"values"` | ||
| 103 | + Total int64 `json:"total"` | ||
| 104 | +} | ||
| 105 | + | ||
| 106 | +type Condition struct { | ||
| 107 | + FieldName string `json:"field"` // 条件字段 | ||
| 108 | + SqlName string `json:"sqlName"` // 字段SqlName | ||
| 109 | + Like string `json:"like,optional"` // 模糊匹配 | ||
| 110 | + In []string `json:"in,optional"` // 匹配多个值 | ||
| 111 | + Order string `json:"order,optional,options=[ASC,DESC]"` // 排序 ASC DESC 默认ASC | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +type GetTableDetailRequest struct { | ||
| 115 | + TableId int `path:"tableId"` // 表ID | ||
| 116 | +} | ||
| 117 | + | ||
| 118 | +type GetTableDetailResponse struct { | ||
| 119 | +} | ||
| 120 | + | ||
| 121 | +type SearchTableDataRequest struct { | ||
| 122 | + ObjectId int `json:"objectId"` // 对象ID | ||
| 123 | + PageNumber int `json:"page,optional"` // 分页数 | ||
| 124 | + PageSize int `json:"size,optional"` // 页码 | ||
| 125 | + Condition []*Condition `json:"conditions,optional"` // 条件 | ||
| 126 | +} | ||
| 127 | + | ||
| 128 | +type SearchTableDataResponse struct { | ||
| 70 | } | 129 | } |
| 1 | package domain | 1 | package domain |
| 2 | 2 | ||
| 3 | +var ( | ||
| 4 | + RecordTable1 = "RecordTable1" | ||
| 5 | + MetricsCard1 = "MetricsCard1" | ||
| 6 | + ContainerCard1 = "ContainerCard1" | ||
| 7 | + QuarterChart1 = "QuarterChart1" | ||
| 8 | +) | ||
| 9 | + | ||
| 3 | type ChartProperty struct { | 10 | type ChartProperty struct { |
| 4 | Title *Title `json:"title,optional"` // 标题 | 11 | Title *Title `json:"title,optional"` // 标题 |
| 5 | FilterRule *FilterRule `json:"filterRule,optional"` // 过滤规则 | 12 | FilterRule *FilterRule `json:"filterRule,optional"` // 过滤规则 |
| @@ -11,7 +18,7 @@ type ChartProperty struct { | @@ -11,7 +18,7 @@ type ChartProperty struct { | ||
| 11 | } | 18 | } |
| 12 | 19 | ||
| 13 | type Series struct { | 20 | type Series struct { |
| 14 | - Type string `json:"type"` // 图表类型 (记录型表格:RecordTable-1 总体指标:MetricsCard-1 容器卡片:ContainerCard-1 四分图:QuarterChart-1) | 21 | + Type string `json:"type"` // 图表类型 (记录型表格:RecordTable1 总体指标:MetricsCard1 容器卡片:ContainerCard1 四分图:QuarterChart1) |
| 15 | Name string `json:"name"` // 名称 | 22 | Name string `json:"name"` // 名称 |
| 16 | Data interface{} `json:"data"` // 保存配置的时候置空 | 23 | Data interface{} `json:"data"` // 保存配置的时候置空 |
| 17 | Config *DataConfig `json:"config"` // 配置 | 24 | Config *DataConfig `json:"config"` // 配置 |
| @@ -5,15 +5,11 @@ import ( | @@ -5,15 +5,11 @@ import ( | ||
| 5 | "fmt" | 5 | "fmt" |
| 6 | ) | 6 | ) |
| 7 | 7 | ||
| 8 | -type MessageCode struct { | ||
| 9 | - Code int `json:"code"` | ||
| 10 | - Msg string `json:"msg"` | ||
| 11 | -} | ||
| 12 | - | ||
| 13 | // Response 统一消息返回格式 | 8 | // Response 统一消息返回格式 |
| 14 | type Response struct { | 9 | type Response struct { |
| 15 | - MessageCode | ||
| 16 | - Data json.RawMessage `json:"data"` | 10 | + Code int `json:"code,optional"` |
| 11 | + Msg string `json:"msg,optional"` | ||
| 12 | + Data json.RawMessage `json:"data,optional"` | ||
| 17 | } | 13 | } |
| 18 | 14 | ||
| 19 | // | 15 | // |
| @@ -6,6 +6,7 @@ import ( | @@ -6,6 +6,7 @@ import ( | ||
| 6 | "fmt" | 6 | "fmt" |
| 7 | "github.com/zeromicro/go-zero/core/mapping" | 7 | "github.com/zeromicro/go-zero/core/mapping" |
| 8 | "github.com/zeromicro/go-zero/rest/httpc" | 8 | "github.com/zeromicro/go-zero/rest/httpc" |
| 9 | + "io/ioutil" | ||
| 9 | "net/http" | 10 | "net/http" |
| 10 | "strings" | 11 | "strings" |
| 11 | "time" | 12 | "time" |
| @@ -21,9 +22,10 @@ type Service struct { | @@ -21,9 +22,10 @@ type Service struct { | ||
| 21 | 22 | ||
| 22 | func NewService(name string, host string, timeout time.Duration, opts ...httpc.Option) Service { | 23 | func NewService(name string, host string, timeout time.Duration, opts ...httpc.Option) Service { |
| 23 | client := &http.Client{} | 24 | client := &http.Client{} |
| 24 | - client.Timeout = timeout | 25 | + //client.Timeout = timeout |
| 25 | 26 | ||
| 26 | service := Service{ | 27 | service := Service{ |
| 28 | + host: host, | ||
| 27 | service: httpc.NewServiceWithClient(name, client, opts...), | 29 | service: httpc.NewServiceWithClient(name, client, opts...), |
| 28 | } | 30 | } |
| 29 | return service | 31 | return service |
| @@ -31,10 +33,11 @@ func NewService(name string, host string, timeout time.Duration, opts ...httpc.O | @@ -31,10 +33,11 @@ func NewService(name string, host string, timeout time.Duration, opts ...httpc.O | ||
| 31 | 33 | ||
| 32 | func (gateway Service) Do(ctx context.Context, url string, method string, val interface{}, result interface{}) error { | 34 | func (gateway Service) Do(ctx context.Context, url string, method string, val interface{}, result interface{}) error { |
| 33 | var ( | 35 | var ( |
| 34 | - baseResponse = &Response{} | 36 | + baseResponse = Response{} |
| 35 | begin = time.Now() | 37 | begin = time.Now() |
| 38 | + body []byte | ||
| 36 | ) | 39 | ) |
| 37 | - response, err := gateway.service.Do(ctx, gateway.host+url, method, val) | 40 | + response, err := gateway.service.Do(ctx, method, gateway.host+url, val) |
| 38 | defer func() { | 41 | defer func() { |
| 39 | jsonParam, _ := json.Marshal(val) | 42 | jsonParam, _ := json.Marshal(val) |
| 40 | jsonData, _ := json.Marshal(result) | 43 | jsonData, _ := json.Marshal(result) |
| @@ -55,19 +58,31 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | @@ -55,19 +58,31 @@ func (gateway Service) Do(ctx context.Context, url string, method string, val in | ||
| 55 | if response.StatusCode != http.StatusOK { | 58 | if response.StatusCode != http.StatusOK { |
| 56 | return HttpError{ | 59 | return HttpError{ |
| 57 | Base: Response{ | 60 | Base: Response{ |
| 58 | - MessageCode: MessageCode{ | ||
| 59 | Code: response.StatusCode, | 61 | Code: response.StatusCode, |
| 60 | Msg: response.Status, | 62 | Msg: response.Status, |
| 61 | }, | 63 | }, |
| 62 | - }, | ||
| 63 | } | 64 | } |
| 64 | } | 65 | } |
| 65 | - if err = httpc.ParseJsonBody(response, baseResponse); err != nil { | 66 | + body, err = Bytes(response) |
| 67 | + if err != nil { | ||
| 68 | + return err | ||
| 69 | + } | ||
| 70 | + if err = json.Unmarshal(body, &baseResponse); err != nil { | ||
| 66 | return err | 71 | return err |
| 67 | } | 72 | } |
| 68 | if err = mapping.UnmarshalJsonBytes(baseResponse.Data, result); err != nil { | 73 | if err = mapping.UnmarshalJsonBytes(baseResponse.Data, result); err != nil { |
| 69 | return err | 74 | return err |
| 70 | } | 75 | } |
| 71 | - | ||
| 72 | return nil | 76 | return nil |
| 73 | } | 77 | } |
| 78 | + | ||
| 79 | +func Bytes(resp *http.Response) ([]byte, error) { | ||
| 80 | + var body []byte | ||
| 81 | + if resp.Body == nil { | ||
| 82 | + return nil, nil | ||
| 83 | + } | ||
| 84 | + defer resp.Body.Close() | ||
| 85 | + | ||
| 86 | + body, err := ioutil.ReadAll(resp.Body) | ||
| 87 | + return body, err | ||
| 88 | +} |
| @@ -22,11 +22,23 @@ type TableDataPreviewRequest struct { | @@ -22,11 +22,23 @@ type TableDataPreviewRequest struct { | ||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | type TableQueryWhere struct { | 24 | type TableQueryWhere struct { |
| 25 | - PageNumber int64 `json:"pageNumber"` | ||
| 26 | - PageSize int64 `json:"pageSize"` | 25 | + PageNumber int `json:"pageNumber"` |
| 26 | + PageSize int `json:"pageSize"` | ||
| 27 | Conditions []*TableQueryCondition `json:"conditions"` | 27 | Conditions []*TableQueryCondition `json:"conditions"` |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | +func (w *TableQueryWhere) WithPageSize(page, size int) *TableQueryWhere { | ||
| 31 | + w.PageNumber = page - 1 | ||
| 32 | + w.PageSize = size | ||
| 33 | + if page == 0 { | ||
| 34 | + w.PageNumber = 0 | ||
| 35 | + } | ||
| 36 | + if w.PageSize == 0 { | ||
| 37 | + w.PageSize = 20 | ||
| 38 | + } | ||
| 39 | + return w | ||
| 40 | +} | ||
| 41 | + | ||
| 30 | type TableQueryCondition struct { | 42 | type TableQueryCondition struct { |
| 31 | Field *Field `json:"field"` //字段 | 43 | Field *Field `json:"field"` //字段 |
| 32 | Like string `json:"like"` //模糊匹配 | 44 | Like string `json:"like"` //模糊匹配 |
| @@ -56,7 +68,7 @@ type TableData struct { | @@ -56,7 +68,7 @@ type TableData struct { | ||
| 56 | 68 | ||
| 57 | type TableDataGrid struct { | 69 | type TableDataGrid struct { |
| 58 | //数据列表 | 70 | //数据列表 |
| 59 | - List []interface{} `json:"list"` | 71 | + List []map[string]string `json:"list"` |
| 60 | //总记录数 | 72 | //总记录数 |
| 61 | Total int64 `json:"total"` | 73 | Total int64 `json:"total"` |
| 62 | } | 74 | } |
| 1 | +package bytelib | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "net/http" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +func (gateway *ByteMetadataService) TableFieldOptionalValues(ctx context.Context, request *TableFieldOptionalValuesRequest) (TableFieldOptionalValuesResponse, error) { | ||
| 9 | + var result TableFieldOptionalValuesResponse | ||
| 10 | + if err := gateway.Do(ctx, "/data/field-optional-values", http.MethodPost, request, &result); err != nil { | ||
| 11 | + return result, err | ||
| 12 | + } | ||
| 13 | + return result, nil | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +type TableFieldOptionalValuesRequest struct { | ||
| 17 | + ObjectType string `json:"objectType" valid:"Required"` // 对象类型 | ||
| 18 | + ObjectId int `json:"objectId" valid:"Required"` // 对象Id标识 | ||
| 19 | + Field Field `json:"field" valid:"Required"` // 选择列 | ||
| 20 | + Match string `json:"match"` // 模糊匹配 | ||
| 21 | + PageNumber int `json:"pageNumber"` // 页吗 | ||
| 22 | + PageSize int `json:"pageSize"` // 页 | ||
| 23 | + Where *TableQueryWhere `json:"where"` | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +type TableFieldOptionalValuesResponse struct { | ||
| 27 | + Values []string `json:"values"` | ||
| 28 | + Total int64 `json:"total"` | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +//type Where struct { | ||
| 32 | +// Conditions []TableQueryCondition `json:"conditions"` | ||
| 33 | +//} |
| @@ -7,7 +7,7 @@ import ( | @@ -7,7 +7,7 @@ import ( | ||
| 7 | 7 | ||
| 8 | func (gateway *ByteMetadataService) TableInfo(ctx context.Context, request *TableInfoRequest) (TableInfoResponse, error) { | 8 | func (gateway *ByteMetadataService) TableInfo(ctx context.Context, request *TableInfoRequest) (TableInfoResponse, error) { |
| 9 | var result TableInfoResponse | 9 | var result TableInfoResponse |
| 10 | - if err := gateway.Do(ctx, "/tables/:tableId", http.MethodGet, request, &result); err != nil { | 10 | + if err := gateway.Do(ctx, "/data/tables/:tableId", http.MethodGet, request, &result); err != nil { |
| 11 | return result, err | 11 | return result, err |
| 12 | } | 12 | } |
| 13 | return result, nil | 13 | return result, nil |
| @@ -15,29 +15,30 @@ func (gateway *ByteMetadataService) ObjectTableSearch(ctx context.Context, reque | @@ -15,29 +15,30 @@ func (gateway *ByteMetadataService) ObjectTableSearch(ctx context.Context, reque | ||
| 15 | 15 | ||
| 16 | type ObjectTableSearchRequest struct { | 16 | type ObjectTableSearchRequest struct { |
| 17 | // 表名称 | 17 | // 表名称 |
| 18 | - Name string `cname:"表名称" json:"name"` | 18 | + Name string `cname:"表名称" json:"name,optional"` |
| 19 | //ViewType string `cname:"视图类型 full:完整 main:主表关系" json:"viewType"` | 19 | //ViewType string `cname:"视图类型 full:完整 main:主表关系" json:"viewType"` |
| 20 | // 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表 SubProcess:子过程 Schema:方案 | 20 | // 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表 SubProcess:子过程 Schema:方案 |
| 21 | - TableTypes []string `cname:"表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表" json:"tableTypes" valid:"Required"` | 21 | + TableTypes []string `json:"tableTypes"` |
| 22 | // 父级ID | 22 | // 父级ID |
| 23 | - ParentId int `cname:"父级ID" json:"parentId"` | 23 | + ParentId int `json:"parentId,optional"` |
| 24 | // 模块 应用于模块 1:数控中心 2:拆解模块 4:计算模块 | 24 | // 模块 应用于模块 1:数控中心 2:拆解模块 4:计算模块 |
| 25 | Module int `json:"module"` | 25 | Module int `json:"module"` |
| 26 | // 父级ID | 26 | // 父级ID |
| 27 | - ParentTableId int `cname:"父级ID" json:"parentTableId"` | ||
| 28 | - // 返回结构信息 | ||
| 29 | - ReturnDetailStructInfo bool `cname:"返回具体的结构信息 默认不返回" json:"returnDetailStructInfo"` | 27 | + ParentTableId int `json:"parentTableId,optional"` |
| 28 | + // 返回具体的结构信息 默认不返回 | ||
| 29 | + ReturnDetailStructInfo bool `json:"returnDetailStructInfo,optional"` | ||
| 30 | // 排除分组项,只返回一级列表;默认 false 不排除,连分组也返回 | 30 | // 排除分组项,只返回一级列表;默认 false 不排除,连分组也返回 |
| 31 | - ReturnGroupItem bool `cname:"排除分组" json:"returnGroupItem"` | 31 | + ReturnGroupItem bool `json:"returnGroupItem,optional"` |
| 32 | // 排除指定表 | 32 | // 排除指定表 |
| 33 | - ExcludeTables []int `cname:"排除指定表" json:"excludeTables"` | ||
| 34 | - FilterRules []*FilterRule `json:"filterRules"` | ||
| 35 | - TableId int `cname:"ID" json:"tableId"` | 33 | + ExcludeTables []int `json:"excludeTables,optional"` |
| 34 | + FilterRules []*FilterRule `json:"filterRules,optional"` | ||
| 35 | + TableId int `json:"tableId,optional"` | ||
| 36 | + QuerySetId int64 `json:"QuerySetId,optional"` | ||
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | type ObjectTableSearchResponse struct { | 39 | type ObjectTableSearchResponse struct { |
| 39 | Count int `json:"count"` | 40 | Count int `json:"count"` |
| 40 | - List []*Table `json:"list"` | 41 | + List []*Table `json:"tableObjects"` |
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | type FilterRule struct { | 44 | type FilterRule struct { |
| @@ -48,7 +49,7 @@ type FilterRule struct { | @@ -48,7 +49,7 @@ type FilterRule struct { | ||
| 48 | 49 | ||
| 49 | type Table struct { | 50 | type Table struct { |
| 50 | // 序号 | 51 | // 序号 |
| 51 | - Id int `json:"id"` | 52 | + // Id int `json:"id"` |
| 52 | // 表Id | 53 | // 表Id |
| 53 | TableId int `json:"tableId"` | 54 | TableId int `json:"tableId"` |
| 54 | // 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表 | 55 | // 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表 |
| @@ -56,17 +57,17 @@ type Table struct { | @@ -56,17 +57,17 @@ type Table struct { | ||
| 56 | // 名称 | 57 | // 名称 |
| 57 | Name string `json:"name"` | 58 | Name string `json:"name"` |
| 58 | // 对应数据库名称 | 59 | // 对应数据库名称 |
| 59 | - SQLName string `json:"sqlName,omitempty"` | 60 | + // SQLName string `json:"sqlName,omitempty"` |
| 60 | // 父级ID | 61 | // 父级ID |
| 61 | ParentId int `json:"parentId"` | 62 | ParentId int `json:"parentId"` |
| 62 | // 模块 应用于模块 1:数控中心 2:拆解模块 4:计算模块 | 63 | // 模块 应用于模块 1:数控中心 2:拆解模块 4:计算模块 |
| 63 | - Module int `json:"module"` | 64 | + // Module int `json:"module"` |
| 64 | // 标识 | 65 | // 标识 |
| 65 | - Flag string `json:"flag,omitempty"` | 66 | + // Flag string `json:"flag,omitempty"` |
| 66 | // 启用状态 | 67 | // 启用状态 |
| 67 | - Status int `json:"status"` | 68 | + // Status int `json:"status"` |
| 68 | // 冲突状态 | 69 | // 冲突状态 |
| 69 | - InConflict bool `json:"inConflict"` | 70 | + // InConflict bool `json:"inConflict"` |
| 70 | // 表字段 | 71 | // 表字段 |
| 71 | Fields []*Field `json:"fields"` | 72 | Fields []*Field `json:"fields"` |
| 72 | } | 73 | } |
| @@ -80,5 +81,5 @@ type Field struct { | @@ -80,5 +81,5 @@ type Field struct { | ||
| 80 | // 对应数据库类型 | 81 | // 对应数据库类型 |
| 81 | SQLType string `json:"sqlType"` | 82 | SQLType string `json:"sqlType"` |
| 82 | // 标识 1.主键 2:主表字段 3:手动添加 | 83 | // 标识 1.主键 2:主表字段 3:手动添加 |
| 83 | - Flag int `json:"flag"` | 84 | + //Flag int `json:"flag"` |
| 84 | } | 85 | } |
| 1 | package bytelib | 1 | package bytelib |
| 2 | 2 | ||
| 3 | var ( | 3 | var ( |
| 4 | - MainTable TableType = "MainTable" // 主表 | ||
| 5 | - SideTable TableType = "SideTable" // 副表 | ||
| 6 | - SubTable TableType = "SubTable" // 分表 | ||
| 7 | - SchemaTable TableType = "Schema" // 方案 | ||
| 8 | - SubProcessTable TableType = "SubProcess" // 子过程 | ||
| 9 | - CalculateItem TableType = "CalculateItem" // 计算项 | ||
| 10 | - CalculateTable TableType = "CalculateTable" // 计算表 | ||
| 11 | - CalculateSet TableType = "CalculateSet" // 计算集 | 4 | + MainTable string = "MainTable" // 主表 |
| 5 | + SideTable string = "SideTable" // 副表 | ||
| 6 | + SubTable string = "SubTable" // 分表 | ||
| 7 | + SchemaTable string = "Schema" // 方案 | ||
| 8 | + SubProcessTable string = "SubProcess" // 子过程 | ||
| 9 | + CalculateItem string = "CalculateItem" // 计算项 | ||
| 10 | + CalculateTable string = "CalculateTable" // 计算表 | ||
| 11 | + CalculateSet string = "CalculateSet" // 计算集 | ||
| 12 | ) | 12 | ) |
| 13 | 13 | ||
| 14 | -type TableType string | 14 | +const ( |
| 15 | + ModuleAll = ModuleDigitalCenter | ModuleQuerySetCenter | ModuleCalculateCenter | ||
| 16 | + ModuleDigitalCenter = 1 | ||
| 17 | + ModuleQuerySetCenter = 2 | ||
| 18 | + ModuleCalculateCenter = 4 | ||
| 19 | +) | ||
| 15 | 20 | ||
| 16 | -func (t TableType) ToString() string { | ||
| 17 | - return string(t) | ||
| 18 | -} | 21 | +const ( |
| 22 | + ObjectFile = "File" | ||
| 23 | + ObjectMetaTable = "MetaTable" | ||
| 24 | + ObjectDBTable = "DBTable" | ||
| 25 | +) |
| @@ -43,10 +43,38 @@ | @@ -43,10 +43,38 @@ | ||
| 43 | ] | 43 | ] |
| 44 | } | 44 | } |
| 45 | }, | 45 | }, |
| 46 | - "v1/chart/rename": { | 46 | + "v1/chart/components/search": { |
| 47 | "post": { | 47 | "post": { |
| 48 | - "summary": "更新图表排序", | ||
| 49 | - "operationId": "renameChartSort", | 48 | + "summary": "搜索图表组件", |
| 49 | + "operationId": "searchChartComponents", | ||
| 50 | + "responses": { | ||
| 51 | + "200": { | ||
| 52 | + "description": "A successful response.", | ||
| 53 | + "schema": { | ||
| 54 | + "$ref": "#/definitions/ChartComponentSearchResponse" | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + }, | ||
| 58 | + "parameters": [ | ||
| 59 | + { | ||
| 60 | + "name": "body", | ||
| 61 | + "in": "body", | ||
| 62 | + "required": true, | ||
| 63 | + "schema": { | ||
| 64 | + "$ref": "#/definitions/ChartComponentSearchRequest" | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + ], | ||
| 68 | + "requestBody": {}, | ||
| 69 | + "tags": [ | ||
| 70 | + "chart" | ||
| 71 | + ] | ||
| 72 | + } | ||
| 73 | + }, | ||
| 74 | + "v1/chart/move": { | ||
| 75 | + "post": { | ||
| 76 | + "summary": "移动图表", | ||
| 77 | + "operationId": "updateChartSort", | ||
| 50 | "responses": { | 78 | "responses": { |
| 51 | "200": { | 79 | "200": { |
| 52 | "description": "A successful response.", | 80 | "description": "A successful response.", |
| @@ -71,15 +99,15 @@ | @@ -71,15 +99,15 @@ | ||
| 71 | ] | 99 | ] |
| 72 | } | 100 | } |
| 73 | }, | 101 | }, |
| 74 | - "v1/chart/search": { | 102 | + "v1/chart/rename": { |
| 75 | "post": { | 103 | "post": { |
| 76 | - "summary": "搜索图表", | ||
| 77 | - "operationId": "searchChart", | 104 | + "summary": "重命名图表", |
| 105 | + "operationId": "renameChartSort", | ||
| 78 | "responses": { | 106 | "responses": { |
| 79 | "200": { | 107 | "200": { |
| 80 | "description": "A successful response.", | 108 | "description": "A successful response.", |
| 81 | "schema": { | 109 | "schema": { |
| 82 | - "$ref": "#/definitions/ChartSearchResponse" | 110 | + "$ref": "#/definitions/ChartRenameResponse" |
| 83 | } | 111 | } |
| 84 | } | 112 | } |
| 85 | }, | 113 | }, |
| @@ -89,7 +117,7 @@ | @@ -89,7 +117,7 @@ | ||
| 89 | "in": "body", | 117 | "in": "body", |
| 90 | "required": true, | 118 | "required": true, |
| 91 | "schema": { | 119 | "schema": { |
| 92 | - "$ref": "#/definitions/ChartSearchRequest" | 120 | + "$ref": "#/definitions/ChartRenameRequest" |
| 93 | } | 121 | } |
| 94 | } | 122 | } |
| 95 | ], | 123 | ], |
| @@ -99,15 +127,15 @@ | @@ -99,15 +127,15 @@ | ||
| 99 | ] | 127 | ] |
| 100 | } | 128 | } |
| 101 | }, | 129 | }, |
| 102 | - "v1/chart/sort": { | 130 | + "v1/chart/search": { |
| 103 | "post": { | 131 | "post": { |
| 104 | - "summary": "更新图表排序", | ||
| 105 | - "operationId": "updateChartSort", | 132 | + "summary": "搜索图表", |
| 133 | + "operationId": "searchChart", | ||
| 106 | "responses": { | 134 | "responses": { |
| 107 | "200": { | 135 | "200": { |
| 108 | "description": "A successful response.", | 136 | "description": "A successful response.", |
| 109 | "schema": { | 137 | "schema": { |
| 110 | - "$ref": "#/definitions/ChartUpdateSortResponse" | 138 | + "$ref": "#/definitions/ChartSearchResponse" |
| 111 | } | 139 | } |
| 112 | } | 140 | } |
| 113 | }, | 141 | }, |
| @@ -117,7 +145,7 @@ | @@ -117,7 +145,7 @@ | ||
| 117 | "in": "body", | 145 | "in": "body", |
| 118 | "required": true, | 146 | "required": true, |
| 119 | "schema": { | 147 | "schema": { |
| 120 | - "$ref": "#/definitions/ChartUpdateSortRequest" | 148 | + "$ref": "#/definitions/ChartSearchRequest" |
| 121 | } | 149 | } |
| 122 | } | 150 | } |
| 123 | ], | 151 | ], |
| @@ -216,9 +244,173 @@ | @@ -216,9 +244,173 @@ | ||
| 216 | "chart" | 244 | "chart" |
| 217 | ] | 245 | ] |
| 218 | } | 246 | } |
| 247 | + }, | ||
| 248 | + "v1/table/data": { | ||
| 249 | + "post": { | ||
| 250 | + "summary": "源数据表-数据", | ||
| 251 | + "operationId": "searchTableData", | ||
| 252 | + "responses": { | ||
| 253 | + "200": { | ||
| 254 | + "description": "A successful response.", | ||
| 255 | + "schema": { | ||
| 256 | + "$ref": "#/definitions/SearchTableDataResponse" | ||
| 257 | + } | ||
| 258 | + } | ||
| 259 | + }, | ||
| 260 | + "parameters": [ | ||
| 261 | + { | ||
| 262 | + "name": "body", | ||
| 263 | + "in": "body", | ||
| 264 | + "required": true, | ||
| 265 | + "schema": { | ||
| 266 | + "$ref": "#/definitions/SearchTableDataRequest" | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + ], | ||
| 270 | + "requestBody": {}, | ||
| 271 | + "tags": [ | ||
| 272 | + "table" | ||
| 273 | + ] | ||
| 274 | + } | ||
| 275 | + }, | ||
| 276 | + "v1/table/field-optional-values": { | ||
| 277 | + "post": { | ||
| 278 | + "summary": "源数据表-字段可选值", | ||
| 279 | + "operationId": "searchTableFieldOptionalValues", | ||
| 280 | + "responses": { | ||
| 281 | + "200": { | ||
| 282 | + "description": "A successful response.", | ||
| 283 | + "schema": { | ||
| 284 | + "$ref": "#/definitions/SearchTableByModuleResponse" | ||
| 285 | + } | ||
| 286 | + } | ||
| 287 | + }, | ||
| 288 | + "parameters": [ | ||
| 289 | + { | ||
| 290 | + "name": "body", | ||
| 291 | + "in": "body", | ||
| 292 | + "required": true, | ||
| 293 | + "schema": { | ||
| 294 | + "$ref": "#/definitions/SearchTableByModuleRequest" | ||
| 295 | + } | ||
| 296 | + } | ||
| 297 | + ], | ||
| 298 | + "requestBody": {}, | ||
| 299 | + "tags": [ | ||
| 300 | + "table" | ||
| 301 | + ] | ||
| 302 | + } | ||
| 303 | + }, | ||
| 304 | + "v1/table/search-by-module": { | ||
| 305 | + "post": { | ||
| 306 | + "summary": "源数据表-按模块搜索", | ||
| 307 | + "operationId": "searchTableByModule", | ||
| 308 | + "responses": { | ||
| 309 | + "200": { | ||
| 310 | + "description": "A successful response.", | ||
| 311 | + "schema": { | ||
| 312 | + "$ref": "#/definitions/SearchTableByModuleResponse" | ||
| 313 | + } | ||
| 314 | + } | ||
| 315 | + }, | ||
| 316 | + "parameters": [ | ||
| 317 | + { | ||
| 318 | + "name": "body", | ||
| 319 | + "in": "body", | ||
| 320 | + "required": true, | ||
| 321 | + "schema": { | ||
| 322 | + "$ref": "#/definitions/SearchTableByModuleRequest" | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + ], | ||
| 326 | + "requestBody": {}, | ||
| 327 | + "tags": [ | ||
| 328 | + "table" | ||
| 329 | + ] | ||
| 330 | + } | ||
| 331 | + }, | ||
| 332 | + "v1/table/{tableId}": { | ||
| 333 | + "get": { | ||
| 334 | + "summary": "源数据表-详情", | ||
| 335 | + "operationId": "getTableDetail", | ||
| 336 | + "responses": { | ||
| 337 | + "200": { | ||
| 338 | + "description": "A successful response.", | ||
| 339 | + "schema": { | ||
| 340 | + "$ref": "#/definitions/GetTableDetailResponse" | ||
| 341 | + } | ||
| 342 | + } | ||
| 343 | + }, | ||
| 344 | + "parameters": [ | ||
| 345 | + { | ||
| 346 | + "name": "tableId", | ||
| 347 | + "in": "path", | ||
| 348 | + "required": true, | ||
| 349 | + "type": "string" | ||
| 350 | + } | ||
| 351 | + ], | ||
| 352 | + "requestBody": {}, | ||
| 353 | + "tags": [ | ||
| 354 | + "table" | ||
| 355 | + ] | ||
| 356 | + } | ||
| 219 | } | 357 | } |
| 220 | }, | 358 | }, |
| 221 | "definitions": { | 359 | "definitions": { |
| 360 | + "ChartComponentItem": { | ||
| 361 | + "type": "object", | ||
| 362 | + "properties": { | ||
| 363 | + "name": { | ||
| 364 | + "type": "string", | ||
| 365 | + "description": " 名称" | ||
| 366 | + }, | ||
| 367 | + "code": { | ||
| 368 | + "type": "string", | ||
| 369 | + "description": " 编码" | ||
| 370 | + }, | ||
| 371 | + "cover": { | ||
| 372 | + "type": "string", | ||
| 373 | + "description": " 封面" | ||
| 374 | + }, | ||
| 375 | + "desc": { | ||
| 376 | + "type": "string", | ||
| 377 | + "description": " 描述" | ||
| 378 | + } | ||
| 379 | + }, | ||
| 380 | + "title": "ChartComponentItem" | ||
| 381 | + }, | ||
| 382 | + "ChartComponentSearchRequest": { | ||
| 383 | + "type": "object", | ||
| 384 | + "properties": { | ||
| 385 | + "name": { | ||
| 386 | + "type": "string" | ||
| 387 | + } | ||
| 388 | + }, | ||
| 389 | + "title": "ChartComponentSearchRequest", | ||
| 390 | + "required": [ | ||
| 391 | + "name" | ||
| 392 | + ] | ||
| 393 | + }, | ||
| 394 | + "ChartComponentSearchResponse": { | ||
| 395 | + "type": "object", | ||
| 396 | + "properties": { | ||
| 397 | + "list": { | ||
| 398 | + "type": "array", | ||
| 399 | + "items": { | ||
| 400 | + "$ref": "#/definitions/ChartComponentItem" | ||
| 401 | + } | ||
| 402 | + }, | ||
| 403 | + "total": { | ||
| 404 | + "type": "integer", | ||
| 405 | + "format": "int64" | ||
| 406 | + } | ||
| 407 | + }, | ||
| 408 | + "title": "ChartComponentSearchResponse", | ||
| 409 | + "required": [ | ||
| 410 | + "list", | ||
| 411 | + "total" | ||
| 412 | + ] | ||
| 413 | + }, | ||
| 222 | "ChartDeleteRequest": { | 414 | "ChartDeleteRequest": { |
| 223 | "type": "object", | 415 | "type": "object", |
| 224 | "properties": { | 416 | "properties": { |
| @@ -355,20 +547,19 @@ | @@ -355,20 +547,19 @@ | ||
| 355 | "ChartSearchRequest": { | 547 | "ChartSearchRequest": { |
| 356 | "type": "object", | 548 | "type": "object", |
| 357 | "properties": { | 549 | "properties": { |
| 358 | - "page": { | ||
| 359 | - "type": "integer", | ||
| 360 | - "format": "int32" | 550 | + "includeTypes": { |
| 551 | + "type": "array", | ||
| 552 | + "items": { | ||
| 553 | + "type": "string" | ||
| 361 | }, | 554 | }, |
| 362 | - "size": { | ||
| 363 | - "type": "integer", | ||
| 364 | - "format": "int32" | 555 | + "description": "包含的类型: 类型 report:报表 group:分组 chart:图表(未指定返回所有)" |
| 556 | + }, | ||
| 557 | + "dataStyle": { | ||
| 558 | + "type": "string", | ||
| 559 | + "description": " 数据样式 tree:树形 flat:平铺" | ||
| 365 | } | 560 | } |
| 366 | }, | 561 | }, |
| 367 | - "title": "ChartSearchRequest", | ||
| 368 | - "required": [ | ||
| 369 | - "page", | ||
| 370 | - "size" | ||
| 371 | - ] | 562 | + "title": "ChartSearchRequest" |
| 372 | }, | 563 | }, |
| 373 | "ChartSearchResponse": { | 564 | "ChartSearchResponse": { |
| 374 | "type": "object", | 565 | "type": "object", |
| @@ -414,25 +605,172 @@ | @@ -414,25 +605,172 @@ | ||
| 414 | "type": "integer", | 605 | "type": "integer", |
| 415 | "format": "int64" | 606 | "format": "int64" |
| 416 | }, | 607 | }, |
| 417 | - "sort": { | 608 | + "pid": { |
| 418 | "type": "integer", | 609 | "type": "integer", |
| 419 | - "format": "int32" | 610 | + "format": "int64" |
| 420 | }, | 611 | }, |
| 421 | - "pid": { | 612 | + "index": { |
| 422 | "type": "integer", | 613 | "type": "integer", |
| 423 | - "format": "int32" | 614 | + "format": "int32", |
| 615 | + "description": " 元素下标" | ||
| 424 | } | 616 | } |
| 425 | }, | 617 | }, |
| 426 | "title": "ChartUpdateSortRequest", | 618 | "title": "ChartUpdateSortRequest", |
| 427 | "required": [ | 619 | "required": [ |
| 428 | "id", | 620 | "id", |
| 429 | - "sort", | ||
| 430 | - "pid" | 621 | + "pid", |
| 622 | + "index" | ||
| 431 | ] | 623 | ] |
| 432 | }, | 624 | }, |
| 433 | "ChartUpdateSortResponse": { | 625 | "ChartUpdateSortResponse": { |
| 434 | "type": "object", | 626 | "type": "object", |
| 435 | "title": "ChartUpdateSortResponse" | 627 | "title": "ChartUpdateSortResponse" |
| 628 | + }, | ||
| 629 | + "Condition": { | ||
| 630 | + "type": "object", | ||
| 631 | + "properties": { | ||
| 632 | + "field": { | ||
| 633 | + "type": "string", | ||
| 634 | + "description": " 条件字段" | ||
| 635 | + }, | ||
| 636 | + "sqlName": { | ||
| 637 | + "type": "string", | ||
| 638 | + "description": " 字段SqlName" | ||
| 639 | + }, | ||
| 640 | + "like": { | ||
| 641 | + "type": "string", | ||
| 642 | + "description": " 模糊匹配" | ||
| 643 | + }, | ||
| 644 | + "in": { | ||
| 645 | + "type": "array", | ||
| 646 | + "items": { | ||
| 647 | + "type": "string" | ||
| 648 | + }, | ||
| 649 | + "description": " 匹配多个值" | ||
| 650 | + }, | ||
| 651 | + "order": { | ||
| 652 | + "type": "string", | ||
| 653 | + "description": " 排序 ASC DESC 默认ASC" | ||
| 654 | + } | ||
| 655 | + }, | ||
| 656 | + "title": "Condition", | ||
| 657 | + "required": [ | ||
| 658 | + "field", | ||
| 659 | + "sqlName", | ||
| 660 | + "order" | ||
| 661 | + ] | ||
| 662 | + }, | ||
| 663 | + "GetTableDetailRequest": { | ||
| 664 | + "type": "object", | ||
| 665 | + "properties": { | ||
| 666 | + "tableId": { | ||
| 667 | + "type": "integer", | ||
| 668 | + "format": "int32", | ||
| 669 | + "description": " 表ID" | ||
| 670 | + } | ||
| 671 | + }, | ||
| 672 | + "title": "GetTableDetailRequest", | ||
| 673 | + "required": [ | ||
| 674 | + "tableId" | ||
| 675 | + ] | ||
| 676 | + }, | ||
| 677 | + "GetTableDetailResponse": { | ||
| 678 | + "type": "object", | ||
| 679 | + "title": "GetTableDetailResponse" | ||
| 680 | + }, | ||
| 681 | + "SearchTableByModuleRequest": { | ||
| 682 | + "type": "object", | ||
| 683 | + "title": "SearchTableByModuleRequest" | ||
| 684 | + }, | ||
| 685 | + "SearchTableByModuleResponse": { | ||
| 686 | + "type": "object", | ||
| 687 | + "title": "SearchTableByModuleResponse" | ||
| 688 | + }, | ||
| 689 | + "SearchTableDataRequest": { | ||
| 690 | + "type": "object", | ||
| 691 | + "properties": { | ||
| 692 | + "objectId": { | ||
| 693 | + "type": "integer", | ||
| 694 | + "format": "int32", | ||
| 695 | + "description": " 对象ID" | ||
| 696 | + }, | ||
| 697 | + "pageNumber": { | ||
| 698 | + "type": "integer", | ||
| 699 | + "format": "int32", | ||
| 700 | + "description": " 分页数" | ||
| 701 | + }, | ||
| 702 | + "pageSize": { | ||
| 703 | + "type": "integer", | ||
| 704 | + "format": "int32", | ||
| 705 | + "description": " 页码" | ||
| 706 | + }, | ||
| 707 | + "conditions": { | ||
| 708 | + "type": "array", | ||
| 709 | + "items": { | ||
| 710 | + "$ref": "#/definitions/Condition" | ||
| 711 | + }, | ||
| 712 | + "description": " 条件" | ||
| 713 | + } | ||
| 714 | + }, | ||
| 715 | + "title": "SearchTableDataRequest", | ||
| 716 | + "required": [ | ||
| 717 | + "objectId" | ||
| 718 | + ] | ||
| 719 | + }, | ||
| 720 | + "SearchTableDataResponse": { | ||
| 721 | + "type": "object", | ||
| 722 | + "title": "SearchTableDataResponse" | ||
| 723 | + }, | ||
| 724 | + "SearchTableFieldOptionalValuesRequest": { | ||
| 725 | + "type": "object", | ||
| 726 | + "properties": { | ||
| 727 | + "objectId": { | ||
| 728 | + "type": "integer", | ||
| 729 | + "format": "int32", | ||
| 730 | + "description": " 对象ID" | ||
| 731 | + }, | ||
| 732 | + "field": { | ||
| 733 | + "type": "string", | ||
| 734 | + "description": " 当前选择的字段" | ||
| 735 | + }, | ||
| 736 | + "sqlName": { | ||
| 737 | + "type": "string", | ||
| 738 | + "description": " 字段SqlName" | ||
| 739 | + }, | ||
| 740 | + "conditions": { | ||
| 741 | + "type": "array", | ||
| 742 | + "items": { | ||
| 743 | + "$ref": "#/definitions/Condition" | ||
| 744 | + }, | ||
| 745 | + "description": " 条件" | ||
| 746 | + } | ||
| 747 | + }, | ||
| 748 | + "title": "SearchTableFieldOptionalValuesRequest", | ||
| 749 | + "required": [ | ||
| 750 | + "objectId", | ||
| 751 | + "field", | ||
| 752 | + "sqlName" | ||
| 753 | + ] | ||
| 754 | + }, | ||
| 755 | + "SearchTableFieldOptionalValuesResponse": { | ||
| 756 | + "type": "object", | ||
| 757 | + "properties": { | ||
| 758 | + "values": { | ||
| 759 | + "type": "array", | ||
| 760 | + "items": { | ||
| 761 | + "type": "string" | ||
| 762 | + } | ||
| 763 | + }, | ||
| 764 | + "total": { | ||
| 765 | + "type": "integer", | ||
| 766 | + "format": "int64" | ||
| 767 | + } | ||
| 768 | + }, | ||
| 769 | + "title": "SearchTableFieldOptionalValuesResponse", | ||
| 770 | + "required": [ | ||
| 771 | + "values", | ||
| 772 | + "total" | ||
| 773 | + ] | ||
| 436 | } | 774 | } |
| 437 | }, | 775 | }, |
| 438 | "securityDefinitions": { | 776 | "securityDefinitions": { |
| @@ -2,9 +2,9 @@ | @@ -2,9 +2,9 @@ | ||
| 2 | syntax = "v1" | 2 | syntax = "v1" |
| 3 | 3 | ||
| 4 | info( | 4 | info( |
| 5 | - title: "xx实例" | ||
| 6 | - desc: "xx实例" | ||
| 7 | - author: "author" | 5 | + title: "天联字库图表模板" |
| 6 | + desc: "图表模板" | ||
| 7 | + author: "小火箭" | ||
| 8 | email: "email" | 8 | email: "email" |
| 9 | version: "v1" | 9 | version: "v1" |
| 10 | ) | 10 | ) |
| @@ -37,6 +37,10 @@ service Core { | @@ -37,6 +37,10 @@ service Core { | ||
| 37 | @doc "重命名图表" | 37 | @doc "重命名图表" |
| 38 | @handler renameChartSort | 38 | @handler renameChartSort |
| 39 | post /chart/rename (ChartRenameRequest) returns (ChartRenameResponse) | 39 | post /chart/rename (ChartRenameRequest) returns (ChartRenameResponse) |
| 40 | + | ||
| 41 | + @doc "搜索图表组件" | ||
| 42 | + @handler searchChartComponents | ||
| 43 | + post /chart/components/search(ChartComponentSearchRequest)returns(ChartComponentSearchResponse) | ||
| 40 | } | 44 | } |
| 41 | 45 | ||
| 42 | type ( | 46 | type ( |
| @@ -94,3 +98,19 @@ type ( | @@ -94,3 +98,19 @@ type ( | ||
| 94 | Charts []ChartItem `json:"charts,optional"` | 98 | Charts []ChartItem `json:"charts,optional"` |
| 95 | } | 99 | } |
| 96 | ) | 100 | ) |
| 101 | + | ||
| 102 | +type( | ||
| 103 | + ChartComponentSearchRequest{ | ||
| 104 | + Name string `json:"name"` | ||
| 105 | + } | ||
| 106 | + ChartComponentSearchResponse{ | ||
| 107 | + List []ChartComponentItem `json:"list"` | ||
| 108 | + Total int64 `json:"total"` | ||
| 109 | + } | ||
| 110 | + ChartComponentItem struct{ | ||
| 111 | + Name string `json:"name,optional"`// 名称 | ||
| 112 | + Code string `json:"code,optional"`// 编码 | ||
| 113 | + Cover string `json:"cover,optional"` // 封面 | ||
| 114 | + Desc string `json:"desc,optional"`// 描述 | ||
| 115 | + } | ||
| 116 | +) |
doc/dsl/api/core/table.api
0 → 100644
| 1 | +syntax = "v1" | ||
| 2 | + | ||
| 3 | +info( | ||
| 4 | + title: "天联字库图表模板" | ||
| 5 | + desc: "图表模板" | ||
| 6 | + author: "小火箭" | ||
| 7 | + email: "email" | ||
| 8 | + version: "v1" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +@server( | ||
| 12 | + prefix: v1 | ||
| 13 | + group: table | ||
| 14 | + jwt: JwtAuth | ||
| 15 | + //middleware: Authority | ||
| 16 | +) | ||
| 17 | +service Core { | ||
| 18 | + @doc "源数据表-按模块搜索" | ||
| 19 | + @handler searchTableByModule | ||
| 20 | + post /table/search-by-module (SearchTableByModuleRequest) returns (SearchTableByModuleResponse) | ||
| 21 | + | ||
| 22 | + @doc "源数据表-字段可选值" | ||
| 23 | + @handler searchTableFieldOptionalValues | ||
| 24 | + post /table/field-optional-values (SearchTableByModuleRequest) returns (SearchTableByModuleResponse) | ||
| 25 | + | ||
| 26 | + @doc "源数据表-详情" | ||
| 27 | + @handler getTableDetail | ||
| 28 | + get /table/:tableId (GetTableDetailRequest) returns (GetTableDetailResponse) | ||
| 29 | + | ||
| 30 | + @doc "源数据表-数据" | ||
| 31 | + @handler searchTableData | ||
| 32 | + post /table/data (SearchTableDataRequest) returns (SearchTableDataResponse) | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +type ( | ||
| 36 | + SearchTableByModuleRequest struct{ | ||
| 37 | + | ||
| 38 | + } | ||
| 39 | + SearchTableByModuleResponse struct{ | ||
| 40 | + | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + SearchTableFieldOptionalValuesRequest struct{ | ||
| 44 | + ObjectId int `json:"objectId"` // 对象ID | ||
| 45 | + Field string `json:"field"` // 当前选择的字段 | ||
| 46 | + SqlName string `json:"sqlName"` // 字段SqlName | ||
| 47 | + // Match string `json:"match"` | ||
| 48 | + //PageNumber int `json:"pageNumber,optional"` // 分页数 | ||
| 49 | + //PageSize int `json:"pageSize,optional"` // 页码 | ||
| 50 | + Condition []*Condition `json:"conditions,optional"` // 条件 | ||
| 51 | + } | ||
| 52 | + SearchTableFieldOptionalValuesResponse struct{ | ||
| 53 | + Values []string `json:"values"` | ||
| 54 | + Total int64 `json:"total"` | ||
| 55 | + } | ||
| 56 | + Condition struct { | ||
| 57 | + FieldName string `json:"field"` // 条件字段 | ||
| 58 | + SqlName string `json:"sqlName"` // 字段SqlName | ||
| 59 | + Like string `json:"like,optional"` // 模糊匹配 | ||
| 60 | + In []string `json:"in,optional"` // 匹配多个值 | ||
| 61 | + Order string `json:"order,optional,options=[ASC,DESC]"` // 排序 ASC DESC 默认ASC | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + GetTableDetailRequest struct { | ||
| 65 | + TableId int `path:"tableId"` // 表ID | ||
| 66 | + } | ||
| 67 | + GetTableDetailResponse struct{ | ||
| 68 | + | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + SearchTableDataRequest struct{ | ||
| 72 | + ObjectId int `json:"objectId"` // 对象ID | ||
| 73 | + PageNumber int `json:"page,optional"` // 分页数 | ||
| 74 | + PageSize int `json:"size,optional"` // 页码 | ||
| 75 | + Condition []*Condition `json:"conditions,optional"` // 条件 | ||
| 76 | + } | ||
| 77 | + SearchTableDataResponse struct{ | ||
| 78 | + | ||
| 79 | + } | ||
| 80 | +) |
| @@ -21,6 +21,9 @@ func (e *CodeError) GetErrCode() uint32 { | @@ -21,6 +21,9 @@ func (e *CodeError) GetErrCode() uint32 { | ||
| 21 | 21 | ||
| 22 | // GetErrMsg 返回给前端显示端错误信息 | 22 | // GetErrMsg 返回给前端显示端错误信息 |
| 23 | func (e *CodeError) GetErrMsg() string { | 23 | func (e *CodeError) GetErrMsg() string { |
| 24 | + if e.errMsg == "" { | ||
| 25 | + return MapErrMsg(e.errCode) | ||
| 26 | + } | ||
| 24 | return e.errMsg | 27 | return e.errMsg |
| 25 | } | 28 | } |
| 26 | 29 |
-
请 注册 或 登录 后发表评论