作者 yangfu

chart update

Name: chart
Host: 0.0.0.0
Port: 8081
Verbose: false
Port: 8080
Verbose: true
JwtAuth:
AccessSecret: digital-platform
... ... @@ -12,7 +12,7 @@ Redis:
Type: node
Pass:
DB:
DataSource: host=106.52.103.187 user=postgres password=UYXN134KUm8TeE7 dbname=skateboard-test port=25431 sslmode=disable TimeZone=Asia/Shanghai
DataSource: host=114.55.200.59 user=postgres password=eagle1010 dbname=sumifcc-bchart-dev port=31543 sslmode=disable TimeZone=Asia/Shanghai
ByteMetadata:
Name: ApiByteMetadata
... ...
... ... @@ -2,6 +2,7 @@ package chart
import (
"context"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/xerr"
... ... @@ -31,6 +32,7 @@ func (l *DeleteChartLogic) DeleteChart(req *types.ChartDeleteRequest) (resp *typ
conn = l.svcCtx.DefaultDBConn()
chart *domain.Chart
tenantId = contextdata.GetTenantFromCtx(l.ctx)
appPage *domain.AppPage
)
resp = &types.ChartDeleteResponse{}
if chart, err = l.svcCtx.ChartRepository.FindOne(l.ctx, conn, req.Id); err != nil {
... ... @@ -39,8 +41,13 @@ func (l *DeleteChartLogic) DeleteChart(req *types.ChartDeleteRequest) (resp *typ
if chart.TenantId != tenantId {
return nil, xerr.NewErrMsgErr("无权限", nil)
}
// TODO:图表被引用不能删除
// TODO:删除下级图表
// 图表被引用不能删除
if appPage, err = l.svcCtx.AppPageRepository.FindOneByChartId(l.ctx, conn, tenantId, chart.Id); err != nil {
return nil, xerr.NewErrMsgErr("删除失败", err)
}
if appPage.Identify() != nil {
return nil, xerr.NewErrMsgErr(fmt.Sprintf("该图表已被页面\"%v\"引用", appPage.Name), err)
}
if chart, err = l.svcCtx.ChartRepository.Delete(l.ctx, conn, chart); err != nil {
return nil, xerr.NewErrMsgErr("删除失败", err)
}
... ...
... ... @@ -45,6 +45,7 @@ func (l *SaveAsChartLogic) SaveAsChart(req *types.ChartSaveAsRequest) (resp *typ
Pid: 0,
Type: chart.Type,
ChartType: chart.ChartType,
Name: req.Name,
ChartProperty: types.NewPropertyItem(chartSetting.ChartProperty(chart.Cover)),
})
return
... ...
... ... @@ -47,6 +47,7 @@ func (l *SaveChartLogic) SaveChart(req *types.ChartSaveRequest) (resp *types.Cha
Group: tool.Krand(10, tool.KC_RAND_KIND_UPPER),
TenantId: tenantId,
ChartType: req.ChartType,
Cover: req.Cover,
}
if chart.Name == "" {
chart.Name = chart.RandName()
... ...
... ... @@ -2,6 +2,10 @@ package chart
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/pkg/contextdata"
"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"
... ... @@ -24,7 +28,38 @@ func NewUpdateChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Updat
}
func (l *UpdateChartLogic) UpdateChart(req *types.ChartUpdateRequest) (resp *types.ChartUpdateResponse, err error) {
// todo: add your logic here and delete this line
var (
conn = l.svcCtx.DefaultDBConn()
chart *domain.Chart
chartSetting *domain.ChartSetting
tenantId = contextdata.GetTenantFromCtx(l.ctx)
)
if chart, err = l.svcCtx.ChartRepository.FindOne(l.ctx, conn, req.Id); err != nil || chart.TenantId != tenantId {
return nil, xerr.NewErrMsgErr("图表不存在", err)
}
if chartSetting, err = l.svcCtx.ChartSettingRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("图表配置不存在", err)
}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
if len(req.Cover) > 0 && chart.Cover != req.Cover {
chart.Cover = req.Cover
}
if chart, err = l.svcCtx.ChartRepository.UpdateWithVersion(l.ctx, conn, chart); err != nil {
return err
}
chartProperty := types.NewProperty(req.ChartProperty)
chartSetting.Title = chartProperty.Title
chartSetting.TableAbility = chartProperty.TableAbility
chartSetting.Series = chartProperty.Series
chartSetting.Other = chartProperty.Other
if chartSetting, err = l.svcCtx.ChartSettingRepository.UpdateWithVersion(l.ctx, conn, chartSetting); err != nil {
return err
}
return nil
}, true); err != nil {
return nil, xerr.NewErrMsgErr("创建失败", err)
}
return
}
... ...
... ... @@ -35,7 +35,9 @@ func (l *CreateAppPageShareUrlLogic) CreateAppPageShareUrl(req *types.AppPageCre
if appPage, err = l.svcCtx.AppPageRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErr(err)
}
resp = &types.AppPageCreateShareResponse{}
resp = &types.AppPageCreateShareResponse{
Key: appPage.Key,
}
if appPage.Key != "" {
return
}
... ...
... ... @@ -31,6 +31,7 @@ func (l *GetTableDetailLogic) GetTableDetail(req *types.GetTableDetailRequest) (
logx.Error(err)
return resp, xerr.NewErr(err)
}
response.Fields = removeIdField(response.Fields)
resp = response
return
}
... ...
... ... @@ -43,6 +43,7 @@ func (l *SearchTableByModuleLogic) SearchTableByModule(req *types.SearchTableByM
Token: req.Token,
TableTypes: []string{bytelib.SchemaTable},
Module: bytelib.ModuleQuerySetCenter,
ReturnGroupItem: true,
})
if err != nil {
batchError.Add(err)
... ... @@ -53,6 +54,7 @@ func (l *SearchTableByModuleLogic) SearchTableByModule(req *types.SearchTableByM
Token: req.Token,
TableTypes: []string{bytelib.CalculateItem, bytelib.CalculateSet},
Module: bytelib.ModuleCalculateCenter,
ReturnGroupItem: true,
})
if err != nil {
batchError.Add(err)
... ...
... ... @@ -41,9 +41,20 @@ func (l *SearchTableDataLogic) SearchTableData(req *types.SearchTableDataRequest
}
resp = map[string]interface{}{
"objectId": response.ObjectId,
"fields": response.Fields,
"fields": removeIdField(response.Fields),
"total": response.Grid.Total,
"data": response.Grid.List,
}
return
}
func removeIdField(fields []*bytelib.Field) []*bytelib.Field {
var result = make([]*bytelib.Field, 0)
for _, f := range fields {
if f.SQLName == "id" {
continue
}
result = append(result, f)
}
return result
}
... ...
... ... @@ -32,7 +32,6 @@ func (l *SearchTableFieldOptionalValuesLogic) SearchTableFieldOptionalValues(req
ObjectId: req.ObjectId,
Field: bytelib.Field{
Name: req.Field,
SQLName: req.SqlName,
},
//PageSize: req.PageSize,
//PageNumber: req.PageNumber,
... ... @@ -62,7 +61,6 @@ func newWhere(conditions []*types.Condition) *bytelib.TableQueryWhere {
where.Conditions = append(where.Conditions, &bytelib.TableQueryCondition{
Field: &bytelib.Field{
Name: c.FieldName,
SQLName: c.SqlName,
},
Like: c.Like,
In: c.In,
... ...
... ... @@ -14,6 +14,7 @@ type ChartSaveRequest struct {
Type string `json:"type"` // 类型 report:报表 group:分组 chart:图表
Name string `json:"name,optional"` // 名称
ChartType string `json:"chartType"` // 图表类型
Cover string `json:"cover,optional"` // 封面
ChartProperty ChartProperty `json:"property"` // 图表属性
}
... ... @@ -39,7 +40,7 @@ type ChartDeleteResponse struct {
type ChartUpdateRequest struct {
Id int64 `path:"id"`
ChartType string `json:"chartType"` // 图表类型
Cover string `json:"cover,optional"` // 封面
ChartProperty ChartProperty `json:"property"` // 图表属性
}
... ... @@ -79,6 +80,8 @@ type ChartItem struct {
Type string `json:"type,optional"` // 类型 report:报表 group:分组 chart:图表
Sort int64 `json:"sort,optional"` // 排序
Name string `json:"name,optional"` // 名称
Cover string `json:"cover,optional"` // 封面
ChartType string `json:"chartType,optional"` // 图表类型
ChartProperty *ChartProperty `json:"property,optional,omitempty"` //属性
}
... ... @@ -109,7 +112,6 @@ type ChartProperty struct {
Title Title `json:"title,optional"` // 标题
TableAbility TableAbility `json:"table,optional"` // 表筛选功能
Series []Series `json:"series,optional"` // 系列(数据源)
Cover string `json:"cover,optional"` // 封面
Other Other `json:"other,optional"` // 其他额外配置
}
... ... @@ -119,11 +121,16 @@ type Other struct {
type Quarter struct {
XAxisLabel string `json:"xAxisLabel"` // x轴标签名
XAxisLabelList []string `json:"xAxisLabelList"` // 标签名
YAxisLabel string `json:"yAxisLabel"` // x轴标签名
YAxisLabelList []string `json:"yAxisLabelList"` // 标签名
XAxisFirstLabel string `json:"xAxisFirstLabel"` // 签名1
XAxisSecondLabel string `json:"xAxisSecondLabel"` // 签名2
YAxisLabel string `json:"yAxisLabel"` // y轴标签名
YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1
YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2
Area string `json:"area"` // 图形面积
SeriesList string `json:"seriesList"` // 图形系列
SeriesList []QuarterSeries `json:"seriesList"` // 图形系列
}
type QuarterSeries struct {
}
type Title struct {
... ... @@ -132,7 +139,7 @@ type Title struct {
TitleType string `json:"titleType"` // 标题类型
Heading string `json:"heading,optional"` // 主标题
SubTitle string `json:"subTitle,optional"` // 副标题
ExplainType string `json:"explainType,optional,options=[text,file]"` // text file
ExplainType string `json:"explainType,optional,options=[text,,file]"` // text file ,options=text||file
ExplainTxt string `json:"explainTxt,optional"` // 文字说明
FileUrl string `json:"fileUrl,optional"` // 组件图片/视频
Align string `json:"align,optional"` // 文本对齐方式 left center right
... ... @@ -161,8 +168,8 @@ type Expression struct {
}
type Dimension struct {
Name string `json:"name"`
Value string `json:"value"`
Name string `json:"name,optional,omitempty"`
Value string `json:"dimensionVal,optional"`
}
type SearchTableByModuleRequest struct {
... ... @@ -176,7 +183,6 @@ type SearchTableFieldOptionalValuesRequest struct {
Token string `header:"x-mmm-accesstoken,optional"`
ObjectId int `json:"objectId"` // 对象ID
Field string `json:"field"` // 当前选择的字段
SqlName string `json:"sqlName"` // 字段SqlName
Condition []*Condition `json:"conditions,optional"` // 条件
}
... ... @@ -187,10 +193,9 @@ type SearchTableFieldOptionalValuesResponse struct {
type Condition struct {
FieldName string `json:"field"` // 条件字段
SqlName string `json:"sqlName"` // 字段SqlName
Like string `json:"like,optional"` // 模糊匹配
In []string `json:"in,optional"` // 匹配多个值
Order string `json:"order,optional,options=[ASC,DESC]"` // 排序 ASC DESC 默认ASC
Order string `json:"order,optional,options=ASC||DESC"` // 排序 ASC DESC 默认ASC
}
type GetTableDetailRequest struct {
... ...
... ... @@ -5,6 +5,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/domain"
"gorm.io/gorm"
"gorm.io/plugin/soft_delete"
"time"
)
type AppPage struct {
... ... @@ -13,7 +14,7 @@ type AppPage struct {
Charts []int64 `gorm:"serializer:json"` // 图表
Key string // 分享,预览时绑定映射到Id
TenantId int64 // 租户ID
TenantId int64 `gorm:"index:idx_app_page_t_id"` // 租户ID
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
... ... @@ -26,13 +27,13 @@ func (m *AppPage) TableName() string {
}
func (m *AppPage) BeforeCreate(tx *gorm.DB) (err error) {
// m.CreatedAt = time.Now().Unix()
// m.UpdatedAt = time.Now().Unix()
m.CreatedAt = time.Now().Unix()
m.UpdatedAt = time.Now().Unix()
return
}
func (m *AppPage) BeforeUpdate(tx *gorm.DB) (err error) {
// m.UpdatedAt = time.Now().Unix()
m.UpdatedAt = time.Now().Unix()
return
}
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"fmt"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -132,6 +133,27 @@ func (repository *AppPageRepository) FindOneByKey(ctx context.Context, conn tran
return repository.ModelToDomainModel(m)
}
func (repository *AppPageRepository) FindOneByChartId(ctx context.Context, conn transaction.Conn, tenantId, chartId int64) (*domain.AppPage, error) {
var (
err error
tx = conn.DB()
m = new(models.AppPage)
)
queryFunc := func() (interface{}, error) {
tx = tx.Raw(fmt.Sprintf("SELECT * FROM app_page WHERE tenant_id = ? AND charts::jsonb@>'[%v]' AND is_del = 0 limit 1", chartId),
tenantId,
).Scan(m)
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
return nil, domain.ErrNotFound
}
return m, tx.Error
}
if _, err = repository.Query(queryFunc); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *AppPageRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.AppPage, error) {
var (
tx = conn.DB()
... ... @@ -141,9 +163,18 @@ func (repository *AppPageRepository) Find(ctx context.Context, conn transaction.
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
if v, ok := queryOptions["tenantId"]; ok {
tx.Where("tenant_id = ?", v)
}
if v, ok := queryOptions["ids"]; ok {
tx.Where("id in (?)", v)
}
//if v, ok := queryOptions["chartId"]; ok {
// tx.Where(domain.JSONQuery("charts").Contains(v))
// tx.Where(datatypes.JSONArrayQuery("charts").Contains(v))
// tx.Where(fmt.Sprintf("charts::jsonb @>'[%v]'", v))
//}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ...
... ... @@ -24,6 +24,7 @@ type AppPageRepository interface {
Delete(ctx context.Context, conn transaction.Conn, dm *AppPage) (*AppPage, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*AppPage, error)
FindOneByKey(ctx context.Context, conn transaction.Conn, key string) (*AppPage, error)
FindOneByChartId(ctx context.Context, conn transaction.Conn, tenantId, chartId int64) (*AppPage, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*AppPage, error)
}
... ...
package domain
import "strconv"
import (
"github.com/samber/lo"
"strconv"
)
const (
SourceFromByteBank = "ByteBank"
... ... @@ -8,10 +11,10 @@ const (
)
var (
RecordTable1 = "RecordTable"
MetricsCard1 = "MetricsCard"
ContainerCard1 = "ContainerCard"
QuarterChart1 = "QuarterChart"
RecordTable1 = "RecordTable-1"
MetricsCard1 = "MetricsCard-1"
ContainerCard1 = "ContainerCard-1"
QuarterChart1 = "QuarterChart-1"
)
type ChartProperty struct {
... ... @@ -28,12 +31,17 @@ type Other struct {
}
type Quarter struct {
XAxisLabel string `json:"xAxisLabel"` // x轴标签名
XAxisLabelList []string `json:"xAxisLabelList"` // 标签名
YAxisLabel string `json:"yAxisLabel"` // x轴标签名
YAxisLabelList []string `json:"yAxisLabelList"` // 标签名
XAxisFirstLabel string `json:"xAxisFirstLabel"` // 签名1
XAxisSecondLabel string `json:"xAxisSecondLabel"` // 签名2
YAxisLabel string `json:"yAxisLabel"` // y轴标签名
YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1
YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2
Area string `json:"area"` // 图形面积
SeriesList string `json:"seriesList"` // 图形系列
SeriesList []QuarterSeries `json:"seriesList"` // 图形系列
}
type QuarterSeries struct {
}
type Title struct {
TitleSwitch bool `json:"titleSwitch,optional"` // 组件标题开关
IntroduceSwitch bool `json:"introduceSwitch,optional"` // 组件说明开关
... ... @@ -141,5 +149,5 @@ func (e ChartProperty) GetAllDataSourceId() []int64 {
idList = append(idList, s.DataSourceId)
}
}
return idList
return lo.Uniq(idList)
}
... ...
package domain
import "reflect"
import (
"fmt"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"reflect"
)
func OffsetLimit(page, size int) (offset int, limit int) {
if page == 0 {
... ... @@ -48,3 +53,45 @@ func (options QueryOptions) Copy() QueryOptions {
}
type IndexQueryOptionFunc func() QueryOptions
type JSONQueryContainExpression struct {
column string
contain bool
containValue interface{}
}
func JSONQuery(column string) *JSONQueryContainExpression {
return &JSONQueryContainExpression{
column: column,
}
}
func (jsonQuery *JSONQueryContainExpression) Contains(value interface{}) *JSONQueryContainExpression {
jsonQuery.containValue = value
jsonQuery.contain = true
return jsonQuery
}
func (jsonQuery *JSONQueryContainExpression) Build(builder clause.Builder) {
if stmt, ok := builder.(*gorm.Statement); ok {
switch stmt.Dialector.Name() {
case "mysql", "sqlite":
switch {
case jsonQuery.contain:
}
case "postgres":
switch {
case jsonQuery.contain:
builder.WriteString(fmt.Sprintf("%v::jsonb ", stmt.Quote(jsonQuery.column)))
builder.WriteString("@>'[")
if _, ok := jsonQuery.containValue.(string); ok {
builder.AddVar(builder, jsonQuery.containValue)
} else {
builder.AddVar(builder, jsonQuery.containValue)
}
builder.WriteString("]'")
}
}
}
}
... ...
... ... @@ -73,7 +73,7 @@ type TableData struct {
//表名
Name string `json:"name"`
//数据
Grid *TableDataGrid `json:"grid"`
Grid *TableDataGrid `json:"grid,optional"`
//字段
Fields []*Field `json:"fields"`
}
... ...
... ... @@ -50,7 +50,7 @@ type FilterRule struct {
type Table struct {
// 序号
// Id int `json:"id"`
Id int `json:"id"`
// 表Id
TableId int `json:"tableId"`
// 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表
... ... @@ -64,7 +64,7 @@ type Table struct {
// 模块 应用于模块 1:数控中心 2:拆解模块 4:计算模块
// Module int `json:"module"`
// 标识
// Flag string `json:"flag,omitempty"`
Flag string `json:"flag,omitempty"`
// 启用状态
// Status int `json:"status"`
// 冲突状态
... ...
... ... @@ -71,6 +71,7 @@ type (
Type string `json:"type"`// 类型 report:报表 group:分组 chart:图表
Name string `json:"name,optional"`// 名称
ChartType string `json:"chartType"` // 图表类型
Cover string `json:"cover,optional"` // 封面
ChartProperty ChartProperty `json:"property"` // 图表属性
}
ChartSaveResponse struct{
... ... @@ -92,7 +93,7 @@ type (
ChartUpdateRequest struct{
Id int64 `path:"id"`
ChartType string `json:"chartType"` // 图表类型
Cover string `json:"cover,optional"` // 封面
ChartProperty ChartProperty `json:"property"` // 图表属性
}
ChartUpdateResponse struct{}
... ... @@ -122,7 +123,8 @@ type (
Type string `json:"type,optional"`// 类型 report:报表 group:分组 chart:图表
Sort int64 `json:"sort,optional"`// 排序
Name string `json:"name,optional"`// 名称
//Charts []ChartItem `json:"charts,optional"`
Cover string `json:"cover,optional"` // 封面
ChartType string `json:"chartType,optional"` // 图表类型
ChartProperty *ChartProperty `json:"property,optional,omitempty"` //属性
}
LoadChartDataRequest struct{
... ... @@ -154,7 +156,7 @@ type(
Title Title `json:"title,optional"` // 标题
TableAbility TableAbility `json:"table,optional"` // 表筛选功能
Series []Series `json:"series,optional"` // 系列(数据源)
Cover string `json:"cover,optional"` // 封面
//Cover string `json:"cover,optional"` // 封面
Other Other `json:"other,optional"` // 其他额外配置
}
Other struct {
... ... @@ -162,11 +164,15 @@ type(
}
Quarter struct {
XAxisLabel string `json:"xAxisLabel"` // x轴标签名
XAxisLabelList []string `json:"xAxisLabelList"` // 标签名
YAxisLabel string `json:"yAxisLabel"` // x轴标签名
YAxisLabelList []string `json:"yAxisLabelList"` // 标签名
XAxisFirstLabel string `json:"xAxisFirstLabel"` // 签名1
XAxisSecondLabel string `json:"xAxisSecondLabel"` // 签名2
YAxisLabel string `json:"yAxisLabel"` // y轴标签名
YAxisFirstLabel string `json:"yAxisFirstLabel"` // y标签1
YAxisSecondLabel string `json:"yAxisSecondLabel"` // y标签2
Area string `json:"area"` // 图形面积
SeriesList string `json:"seriesList"` // 图形系列
SeriesList []QuarterSeries `json:"seriesList"` // 图形系列
}
QuarterSeries struct {
}
Title struct {
TitleSwitch bool `json:"titleSwitch,optional"` // 组件标题开关
... ... @@ -174,7 +180,7 @@ type(
TitleType string `json:"titleType"` // 标题类型
Heading string `json:"heading,optional"` // 主标题
SubTitle string `json:"subTitle,optional"` // 副标题
ExplainType string `json:"explainType,optional,options=[text,file]"` // text file
ExplainType string `json:"explainType,optional,options=[text,,file]"` // text file ,options=text||file
ExplainTxt string `json:"explainTxt,optional"` // 文字说明
FileUrl string `json:"fileUrl,optional"` // 组件图片/视频
Align string `json:"align,optional"` // 文本对齐方式 left center right
... ... @@ -199,7 +205,7 @@ type(
ToValue string `json:"toValue"` // 显示值(转为)
}
Dimension struct{
Name string `json:"name"`
Value string `json:"value"`
Name string `json:"name,optional,omitempty"`
Value string `json:"dimensionVal,optional"`
}
)
\ No newline at end of file
... ...
... ... @@ -52,7 +52,7 @@ type (
Token string `header:"x-mmm-accesstoken,optional"`
ObjectId int `json:"objectId"` // 对象ID
Field string `json:"field"` // 当前选择的字段
SqlName string `json:"sqlName"` // 字段SqlName
//SqlName string `json:"sqlName,optional"` // 字段SqlName
// Match string `json:"match"`
//PageNumber int `json:"pageNumber,optional"` // 分页数
//PageSize int `json:"pageSize,optional"` // 页码
... ... @@ -64,10 +64,10 @@ type (
}
Condition struct {
FieldName string `json:"field"` // 条件字段
SqlName string `json:"sqlName"` // 字段SqlName
//SqlName string `json:"sqlName,optional"` // 字段SqlName
Like string `json:"like,optional"` // 模糊匹配
In []string `json:"in,optional"` // 匹配多个值
Order string `json:"order,optional,options=[ASC,DESC]"` // 排序 ASC DESC 默认ASC
Order string `json:"order,optional,options=ASC||DESC"` // 排序 ASC DESC 默认ASC
}
GetTableDetailRequest struct {
... ...
... ... @@ -137,6 +137,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/datatypes v1.2.0 // indirect
k8s.io/api v0.26.3 // indirect
k8s.io/apimachinery v0.27.0-alpha.3 // indirect
k8s.io/client-go v0.26.3 // indirect
... ...
... ... @@ -42,7 +42,13 @@ func OpenGormPGDB(source string) *gorm.DB {
},
)
fmt.Println("starting db...")
db, err := gorm.Open(postgres.Open(source), &gorm.Config{
//db, err := gorm.Open(postgres.Open(source), &gorm.Config{
// Logger: newLogger,
//})
db, err := gorm.Open(postgres.New(postgres.Config{
DSN: source,
PreferSimpleProtocol: true, // disables implicit prepared statement usage
}), &gorm.Config{
Logger: newLogger,
})
if err != nil {
... ...
... ... @@ -44,7 +44,7 @@ func HttpResult(r *http.Request, w http.ResponseWriter, resp interface{}, err er
logx.WithContext(r.Context()).Errorf("【API-ERR】 : %+v ", err)
response := Error(errcode, errmsg)
response.Error = internalErr
httpx.WriteJson(w, http.StatusBadRequest, response)
httpx.WriteJson(w, http.StatusOK, response)
}
}
... ...