作者 yangfu

load chart data

package chart
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/logic/chart"
"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"
)
func LoadChartDataHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.LoadChartDataRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := chart.NewLoadChartDataLogic(r.Context(), svcCtx)
resp, err := l.LoadChartData(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package chart
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/api/internal/logic/chart"
"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"
)
func SaveAsChartHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ChartSaveAsRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := chart.NewSaveAsChartLogic(r.Context(), svcCtx)
resp, err := l.SaveAsChart(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -25,6 +25,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: chart.SaveChartHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/chart/saveas",
Handler: chart.SaveAsChartHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/chart/:id",
Handler: chart.DeleteChartHandler(serverCtx),
... ... @@ -63,9 +68,15 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
[]rest.Route{
{
Method: http.MethodPost,
Path: "/table/search-by-module",
Handler: table.SearchTableByModuleHandler(serverCtx),
Path: "/chart/load-data",
Handler: chart.LoadChartDataHandler(serverCtx),
},
},
rest.WithPrefix("/v1"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/table/field-optional-values",
... ... @@ -82,6 +93,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: table.SearchTableDataHandler(serverCtx),
},
},
rest.WithPrefix("/v1"),
)
server.AddRoutes(
[]rest.Route{
{
Method: http.MethodPost,
Path: "/table/search-by-module",
Handler: table.SearchTableByModuleHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.JwtAuth.AccessSecret),
rest.WithPrefix("/v1"),
)
... ...
package chart
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain"
"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 LoadChartDataLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewLoadChartDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoadChartDataLogic {
return &LoadChartDataLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *LoadChartDataLogic) LoadChartData(req *types.LoadChartDataRequest) (resp interface{}, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
chartSetting *domain.ChartSetting
)
if chartSetting, err = l.svcCtx.ChartSettingRepository.FindOne(l.ctx, conn, req.ChartId); err != nil {
return nil, xerr.NewErrMsgErr("加载图表数据失败", err)
}
resp, err = l.LoadData(chartSetting)
if err != nil {
return nil, xerr.NewErrMsgErr("加载图表数据失败", err)
}
return
}
type SeriesData struct {
Name string `json:"name"`
Data interface{} `json:"data"`
}
func (l *LoadChartDataLogic) LoadData(chartSetting *domain.ChartSetting) (data interface{}, err error) {
var seriesData interface{}
switch chartSetting.ChartType {
case domain.MetricsCard1:
seriesData, err = l.LoadMetricsCardData(chartSetting)
case domain.ContainerCard1:
seriesData, err = l.LoadTableData(chartSetting, 5)
default:
seriesData, err = l.LoadTableData(chartSetting, 0)
}
data = map[string]interface{}{
"chartId": chartSetting.ChartId,
//"title": chartSetting.Title,
//"table": chartSetting.TableAbility,
"series": seriesData,
}
return
}
func (l *LoadChartDataLogic) LoadMetricsCardData(chartSetting *domain.ChartSetting) (data interface{}, err error) {
var (
list = make([]SeriesData, 0)
response bytelib.TablePreviewResponse
)
for _, series := range chartSetting.Series {
seriesData := SeriesData{
Name: series.Name,
}
if series.SourceFrom == domain.SourceFromUser {
seriesData.Data = series.CustomText
list = append(list, seriesData)
continue
}
response, err = l.svcCtx.ByteMetadataService.FastTableData(l.ctx, series.DataSourceId, 1)
if err != nil {
return
}
cellData := response.FirstCellData()
if series.Name == "指标1" && len(series.MatchExpressions) > 0 {
for _, exp := range series.MatchExpressions {
if ok, value := exp.Match(cellData); ok {
cellData = value
}
}
}
seriesData.Data = cellData
list = append(list, seriesData)
continue
}
data = list
return
}
func (l *LoadChartDataLogic) LoadTableData(chartSetting *domain.ChartSetting, limit int) (data interface{}, err error) {
var (
list = make([]SeriesData, 0)
response bytelib.TablePreviewResponse
)
for _, series := range chartSetting.Series {
seriesData := SeriesData{
Name: series.Name,
}
response, err = l.svcCtx.ByteMetadataService.FastTableData(l.ctx, series.DataSourceId, limit)
if err != nil {
return
}
seriesData.Data = map[string]interface{}{
"list": response.Grid.List,
"fields": response.Fields,
"total": response.Grid.Total,
}
list = append(list, seriesData)
}
data = list
return
}
... ...
package chart
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain"
"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 SaveAsChartLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSaveAsChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveAsChartLogic {
return &SaveAsChartLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SaveAsChartLogic) SaveAsChart(req *types.ChartSaveAsRequest) (resp *types.ChartSaveResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
chartSetting *domain.ChartSetting
chart *domain.Chart
)
chart, err = l.svcCtx.ChartRepository.FindOne(l.ctx, conn, req.ChartId)
if err != nil {
return nil, xerr.NewErrMsgErr("未找到图表", err)
}
chartSetting, err = l.svcCtx.ChartSettingRepository.FindOne(l.ctx, conn, req.ChartId)
if err != nil {
return nil, xerr.NewErrMsgErr("未找到图表", err)
}
saveChartLogic := NewSaveChartLogic(l.ctx, l.svcCtx)
resp, err = saveChartLogic.SaveChart(&types.ChartSaveRequest{
Pid: 0,
Type: chart.Type,
ChartType: chart.ChartType,
ChartProperty: types.NewPropertyItem(chartSetting.ChartProperty(chart.Cover)),
})
return
}
... ...
... ... @@ -30,8 +30,8 @@ func NewSaveChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SaveCha
func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.ChartSaveResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
parentChart *domain.Chart
//conn = l.svcCtx.DefaultDBConn()
//parentChart *domain.Chart
chart *domain.Chart
chartSetting *domain.ChartSetting
tenantId = contextdata.GetTenantFromCtx(l.ctx)
... ... @@ -51,16 +51,16 @@ func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.Cha
if chart.Name == "" {
chart.Name = chart.RandName()
}
if req.Pid > 0 {
if parentChart, err = l.svcCtx.ChartRepository.FindOne(l.ctx, conn, req.Pid); err != nil {
return nil, xerr.NewErrMsgErr("父级不存在", err)
}
chart.Group = parentChart.Group
}
//if req.Pid > 0 {
// if parentChart, err = l.svcCtx.ChartRepository.FindOne(l.ctx, conn, req.Pid); err != nil {
// return nil, xerr.NewErrMsgErr("父级不存在", err)
// }
// chart.Group = parentChart.Group
//}
// current sort
if currentSortChart, _ := l.svcCtx.ChartRepository.FindOneByGroup(l.ctx, conn, tenantId, req.Pid); currentSortChart != nil {
chart.Sort = currentSortChart.Sort + 1
}
//if currentSortChart, _ := l.svcCtx.ChartRepository.FindOneByGroup(l.ctx, conn, tenantId, req.Pid); currentSortChart != nil {
// chart.Sort = currentSortChart.Sort + 1
//}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
if chart, err = l.svcCtx.ChartRepository.Insert(ctx, conn, chart); err != nil {
return err
... ...
... ... @@ -11,15 +11,6 @@ func NewChartItem(chart *domain.Chart) ChartItem {
return item
}
func NewChartItemWithProperty(chart *domain.Chart, property *ChartProperty) ChartItem {
item := ChartItem{}
copier.Copy(&item, chart)
if property != nil {
item.ChartProperty = property
}
return item
}
func NewChartItemWithSetting(chart *domain.Chart, chartSetting *domain.ChartSetting) ChartItem {
item := ChartItem{}
copier.Copy(&item, chart)
... ...
... ... @@ -21,6 +21,15 @@ type ChartSaveResponse struct {
Chart ChartItem `json:"chart"`
}
type ChartSaveAsRequest struct {
ChartId int64 `json:"chartId"` // 图表Id
Name string `json:"name"` // 名称
}
type ChartSaveAsResponse struct {
Chart ChartItem `json:"chart"`
}
type ChartDeleteRequest struct {
Id int64 `path:"id"`
}
... ... @@ -73,6 +82,13 @@ type ChartItem struct {
ChartProperty *ChartProperty `json:"property,optional,omitempty"` //属性
}
type LoadChartDataRequest struct {
ChartId int64 `json:"chartId"`
}
type LoadChartDataResponse struct {
}
type ChartComponentSearchRequest struct {
Name string `json:"name,optional"`
}
... ... @@ -113,11 +129,11 @@ type TableAbility struct {
}
type Series struct {
Name string `json:"name"` // 名称 (例如 指标1、指标2)
SourceFrom string `json:"from,options=[ByteBank,User]"` // 数据源类型 ByteBank:字库 User:用户自定义
DataSourceId int64 `json:"dataSourceId,optional,omitempty"` // 数据源ID(from值为ByteBank时有值)
CustomText string `json:"customText,optional,omitempty"` // 自定义数据文本(from值为User时有值)
MatchExpressions []Expression `json:"matchExpressions,omitempty"` // 条件匹配表达式(总体指标)
Name string `json:"name"` // 名称 (例如 指标1、指标2)
SourceFrom string `json:"from,options=[ByteBank,User]"` // 数据源类型 ByteBank:字库 User:用户自定义
DataSourceId int64 `json:"dataSourceId,optional,omitempty"` // 数据源ID(from值为ByteBank时有值)
CustomText string `json:"customText,optional,omitempty"` // 自定义数据文本(from值为User时有值)
MatchExpressions []Expression `json:"matchExpressions,optional,omitempty"` // 条件匹配表达式(总体指标)
}
type Expression struct {
... ... @@ -132,14 +148,14 @@ type Dimension struct {
}
type SearchTableByModuleRequest struct {
Token string `header:"x-mmm-accesstoken"`
Token string `header:"x-mmm-accesstoken,optional"`
}
type SearchTableByModuleResponse struct {
}
type SearchTableFieldOptionalValuesRequest struct {
Token string `header:"x-mmm-accesstoken"`
Token string `header:"x-mmm-accesstoken,optional"`
ObjectId int `json:"objectId"` // 对象ID
Field string `json:"field"` // 当前选择的字段
SqlName string `json:"sqlName"` // 字段SqlName
... ... @@ -160,7 +176,7 @@ type Condition struct {
}
type GetTableDetailRequest struct {
Token string `header:"x-mmm-accesstoken"`
Token string `header:"x-mmm-accesstoken,optional"`
TableId int `path:"tableId"` // 表ID
}
... ... @@ -168,7 +184,7 @@ type GetTableDetailResponse struct {
}
type SearchTableDataRequest struct {
Token string `header:"x-mmm-accesstoken"`
Token string `header:"x-mmm-accesstoken,optional"`
ObjectId int `json:"objectId"` // 对象ID
PageNumber int `json:"page,optional"` // 分页数
PageSize int `json:"size,optional"` // 页码
... ...
... ... @@ -9,12 +9,13 @@ import (
)
type Chart struct {
Id int64 // ID
Pid int64 `gorm:"index:idx_chart_t_pid_sort"` // 父级ID
Type string // 类型
Sort int `gorm:"index:idx_chart_t_pid_sort"` // 排序
Name string // 名称
Group string `gorm:"index:idx_chart_group"` // 分组
Id int64 // ID
Pid int64 `gorm:"index:idx_chart_t_pid_sort"` // 父级ID
Type string // 类型
Sort int `gorm:"index:idx_chart_t_pid_sort"` // 排序
Name string // 名称
Group string `gorm:"index:idx_chart_group"` // 分组
ChartType string
TenantId int64 `gorm:"index:idx_chart_t_pid_sort"` // 租户ID
CreatedAt int64 `json:",omitempty"`
... ...
... ... @@ -119,7 +119,7 @@ func (repository *ChartRepository) Find(ctx context.Context, conn transaction.Co
total int64
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("pid asc").Order("sort asc")
tx = tx.Model(&ms).Order("id desc") //.Order("pid asc").Order("sort asc")
if v, ok := queryOptions["tenantId"]; ok {
tx.Where("tenant_id = ?", v)
}
... ...
package domain
import "strconv"
const (
SourceFromByteBank = "ByteBank"
SourceFromUser = "User"
)
var (
RecordTable1 = "RecordTable"
MetricsCard1 = "MetricsCard"
... ... @@ -47,6 +54,57 @@ type Expression struct {
ToValue string `json:"toValue"` // 显示值(转为)
}
func (exp Expression) Match(value string) (result bool, toValue string) {
fValue, ferr := strconv.ParseFloat(value, 64)
cValue, cerr := strconv.ParseFloat(exp.CompareValue, 64)
if ferr == nil && cerr == nil {
if exp.FloatMatch(exp.Operator, fValue, cValue) {
return true, exp.ToValue
}
return false, value
}
if exp.StringMatch(exp.Operator, value, exp.CompareValue) {
return true, exp.ToValue
}
return false, value
}
func (exp Expression) FloatMatch(op string, v, c float64) bool {
switch op {
case "<":
return v < c
case ">":
return v > c
case "==":
return v == c
case "<>":
return v != c
case "<=":
return v <= c
case ">=":
return v >= c
}
return false
}
func (exp Expression) StringMatch(op string, v, c string) bool {
switch op {
case "<":
return v < c
case ">":
return v > c
case "==":
return v == c
case "<>":
return v != c
case "<=":
return v <= c
case ">=":
return v >= c
}
return false
}
type Dimension struct {
Name string `json:"name"`
Value string `json:"value"`
... ...
package bytelib
type TableFrames struct {
}
func NewTableFrames(tableData TableData) {
var mapData = make([]map[string]interface{}, 0)
for i := range tableData.Grid.List {
mapItem := make(map[string]interface{})
for k, v := range tableData.Grid.List[i] {
mapItem[k] = v
}
mapData = append(mapData, mapItem)
}
//df := dataframe.LoadMaps(mapData)
//if df!=nil{
//
//}
}
... ...
... ... @@ -13,6 +13,17 @@ func (gateway *ByteMetadataService) TableDataPreview(ctx context.Context, reques
return result, nil
}
func (gateway *ByteMetadataService) FastTableData(ctx context.Context, objectId int64, limit int) (TablePreviewResponse, error) {
return gateway.TableDataPreview(ctx, &TableDataPreviewRequest{
ObjectType: ObjectMetaTable,
ObjectId: objectId,
Where: &TableQueryWhere{
PageNumber: 0,
PageSize: limit,
},
})
}
type TableDataPreviewRequest struct {
Token string `header:"x-mmm-accesstoken"`
ObjectId int64 `json:"objectId"` //表ID
... ... @@ -73,3 +84,17 @@ type TableDataGrid struct {
//总记录数
Total int64 `json:"total"`
}
func (t TablePreviewResponse) FirstCellData() string {
var column string
if len(t.Fields) >= 1 {
column = t.Fields[0].SQLName
}
if len(t.Fields) >= 2 && t.Fields[0].SQLName == "id" {
column = t.Fields[1].SQLName
}
if len(t.Grid.List) > 0 {
return t.Grid.List[0][column]
}
return ""
}
... ...
... ... @@ -71,6 +71,34 @@
]
}
},
"v1/chart/load-data": {
"post": {
"summary": "加载图表数据",
"operationId": "loadChartData",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/LoadChartDataResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/LoadChartDataRequest"
}
}
],
"requestBody": {},
"tags": [
"chart"
]
}
},
"v1/chart/move": {
"post": {
"summary": "移动图表",
... ... @@ -347,6 +375,12 @@
"in": "path",
"required": true,
"type": "string"
},
{
"name": "x-mmm-accesstoken",
"in": "query",
"required": false,
"type": "string"
}
],
"requestBody": {},
... ... @@ -386,10 +420,7 @@
"type": "string"
}
},
"title": "ChartComponentSearchRequest",
"required": [
"name"
]
"title": "ChartComponentSearchRequest"
},
"ChartComponentSearchResponse": {
"type": "object",
... ... @@ -479,14 +510,15 @@
"type": "string",
"description": " 名称"
},
"charts": {
"type": "array",
"items": {
"$ref": "#/definitions/ChartItem"
}
"property": {
"$ref": "#/definitions/ChartProperty",
"description": "属性"
}
},
"title": "ChartItem"
"title": "ChartItem",
"required": [
"property"
]
},
"ChartProperty": {
"type": "object",
... ... @@ -705,10 +737,26 @@
"order"
]
},
"Dimension": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"value": {
"type": "string"
}
},
"title": "Dimension",
"required": [
"name",
"value"
]
},
"Expression": {
"type": "object",
"properties": {
"Operator": {
"operator": {
"type": "string",
"description": " 操作符号 \u003c,\u003e,==,\u003c\u003e,\u003c=,\u003e="
},
... ... @@ -723,7 +771,7 @@
},
"title": "Expression",
"required": [
"Operator",
"operator",
"compareValue",
"toValue"
]
... ... @@ -731,6 +779,9 @@
"GetTableDetailRequest": {
"type": "object",
"properties": {
"Token": {
"type": "string"
},
"tableId": {
"type": "integer",
"format": "int32",
... ... @@ -746,8 +797,30 @@
"type": "object",
"title": "GetTableDetailResponse"
},
"LoadChartDataRequest": {
"type": "object",
"properties": {
"chartId": {
"type": "integer",
"format": "int64"
}
},
"title": "LoadChartDataRequest",
"required": [
"chartId"
]
},
"LoadChartDataResponse": {
"type": "object",
"title": "LoadChartDataResponse"
},
"SearchTableByModuleRequest": {
"type": "object",
"properties": {
"Token": {
"type": "string"
}
},
"title": "SearchTableByModuleRequest"
},
"SearchTableByModuleResponse": {
... ... @@ -757,6 +830,9 @@
"SearchTableDataRequest": {
"type": "object",
"properties": {
"Token": {
"type": "string"
},
"objectId": {
"type": "integer",
"format": "int32",
... ... @@ -792,6 +868,9 @@
"SearchTableFieldOptionalValuesRequest": {
"type": "object",
"properties": {
"Token": {
"type": "string"
},
"objectId": {
"type": "integer",
"format": "int32",
... ... @@ -872,6 +951,8 @@
"required": [
"name",
"from",
"dataSourceId",
"customText",
"matchExpressions"
]
},
... ... @@ -886,7 +967,7 @@
"dimensionList": {
"type": "array",
"items": {
"type": "string"
"$ref": "#/definitions/Dimension"
},
"description": " 维度列表"
}
... ...
... ... @@ -22,6 +22,9 @@ service Core {
@doc "保存图表"
@handler saveChart
post /chart (ChartSaveRequest) returns (ChartSaveResponse)
@doc "图表另存为"
@handler saveAsChart
post /chart/saveas (ChartSaveAsRequest) returns (ChartSaveAsResponse)
@doc "删除图表"
@handler deleteChart
delete /chart/:id (ChartDeleteRequest) returns (ChartDeleteResponse)
... ... @@ -43,6 +46,18 @@ service Core {
post /chart/components/search(ChartComponentSearchRequest)returns(ChartComponentSearchResponse)
}
@server(
prefix: v1
group: chart
//jwt: JwtAuth
//middleware: Authority
)
service Core {
@doc "加载图表数据"
@handler loadChartData
post /chart/load-data (LoadChartDataRequest) returns (LoadChartDataResponse)
}
type (
ChartGetRequest {
Id int64 `path:"id"`
... ... @@ -62,6 +77,14 @@ type (
Chart ChartItem `json:"chart"`
}
ChartSaveAsRequest struct{
ChartId int64 `json:"chartId"` // 图表Id
Name string `json:"name"`// 名称
}
ChartSaveAsResponse struct{
Chart ChartItem `json:"chart"`
}
ChartDeleteRequest struct{
Id int64 `path:"id"`
}
... ... @@ -102,6 +125,12 @@ type (
//Charts []ChartItem `json:"charts,optional"`
ChartProperty *ChartProperty `json:"property,optional,omitempty"` //属性
}
LoadChartDataRequest struct{
ChartId int64 `json:"chartId"`
}
LoadChartDataResponse struct{
}
)
type(
... ... @@ -146,7 +175,7 @@ type(
SourceFrom string `json:"from,options=[ByteBank,User]"` // 数据源类型 ByteBank:字库 User:用户自定义
DataSourceId int64 `json:"dataSourceId,optional,omitempty"` // 数据源ID(from值为ByteBank时有值)
CustomText string `json:"customText,optional,omitempty"` // 自定义数据文本(from值为User时有值)
MatchExpressions []Expression `json:"matchExpressions,omitempty"` // 条件匹配表达式(总体指标)
MatchExpressions []Expression `json:"matchExpressions,optional,omitempty"` // 条件匹配表达式(总体指标)
}
Expression struct {
Operator string `json:"operator"` // 操作符号 <,>,==,<>,<=,>=
... ...
... ... @@ -11,14 +11,10 @@ info(
@server(
prefix: v1
group: table
jwt: JwtAuth
//jwt: JwtAuth
//middleware: Authority
)
service Core {
@doc "源数据表-按模块搜索"
@handler searchTableByModule
post /table/search-by-module (SearchTableByModuleRequest) returns (SearchTableByModuleResponse)
@doc "源数据表-字段可选值"
@handler searchTableFieldOptionalValues
post /table/field-optional-values (SearchTableByModuleRequest) returns (SearchTableByModuleResponse)
... ... @@ -32,16 +28,28 @@ service Core {
post /table/data (SearchTableDataRequest) returns (SearchTableDataResponse)
}
@server(
prefix: v1
group: table
jwt: JwtAuth
//middleware: Authority
)
service Core {
@doc "源数据表-按模块搜索"
@handler searchTableByModule
post /table/search-by-module (SearchTableByModuleRequest) returns (SearchTableByModuleResponse)
}
type (
SearchTableByModuleRequest struct{
Token string `header:"x-mmm-accesstoken"`
Token string `header:"x-mmm-accesstoken,optional"`
}
SearchTableByModuleResponse struct{
}
SearchTableFieldOptionalValuesRequest struct{
Token string `header:"x-mmm-accesstoken"`
Token string `header:"x-mmm-accesstoken,optional"`
ObjectId int `json:"objectId"` // 对象ID
Field string `json:"field"` // 当前选择的字段
SqlName string `json:"sqlName"` // 字段SqlName
... ... @@ -63,7 +71,7 @@ type (
}
GetTableDetailRequest struct {
Token string `header:"x-mmm-accesstoken"`
Token string `header:"x-mmm-accesstoken,optional"`
TableId int `path:"tableId"` // 表ID
}
GetTableDetailResponse struct{
... ... @@ -71,7 +79,7 @@ type (
}
SearchTableDataRequest struct{
Token string `header:"x-mmm-accesstoken"`
Token string `header:"x-mmm-accesstoken,optional"`
ObjectId int `json:"objectId"` // 对象ID
PageNumber int `json:"page,optional"` // 分页数
PageSize int `json:"size,optional"` // 页码
... ...
... ... @@ -37,6 +37,7 @@ require (
github.com/garyburd/redigo v1.6.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.5.0 // indirect
github.com/go-gota/gota v0.12.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
... ...