chart_setting.go 1.7 KB
package domain

import (
	"context"
	"gitlab.fjmaimaimai.com/allied-creation/sumifcc-bchart/cmd/chart-server/interanl/pkg/db/transaction"
)

type ChartSetting struct {
	Id            int64 // ID
	ChartId       int64 // 图表ID
	DataSourceId  int64 // (冗余)数据源ID,多个数据源取第一个源
	DataSourceIds []int64
	ChartType     string // (冗余)图表类型 (记录型表格:RecordTable-1 总体指标:MetricsCard-1 容器卡片:ContainerCard-1 四分图:QuarterChart-1)
	Title         Title
	TableAbility  TableAbility // 表格能力
	Series        []Series     // 系列值-数据绑定
	Other         Other

	TenantId  int64 // 租户ID
	CreatedAt int64 `json:",omitempty"`
	UpdatedAt int64 `json:",omitempty"`
	DeletedAt int64 `json:",omitempty"`
	Version   int   `json:",omitempty"`
}

type ChartSettingRepository interface {
	Insert(ctx context.Context, conn transaction.Conn, dm *ChartSetting) (*ChartSetting, error)
	Update(ctx context.Context, conn transaction.Conn, dm *ChartSetting) (*ChartSetting, error)
	UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ChartSetting) (*ChartSetting, error)
	Delete(ctx context.Context, conn transaction.Conn, dm *ChartSetting) (*ChartSetting, error)
	FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ChartSetting, error)
	Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ChartSetting, error)
}

func (m *ChartSetting) Identify() interface{} {
	if m.Id == 0 {
		return nil
	}
	return m.Id
}

func (m *ChartSetting) ChartProperty(cover string) ChartProperty {
	return ChartProperty{
		Title:        m.Title,
		TableAbility: m.TableAbility,
		Series:       m.Series,
		Cover:        cover,
		Other:        m.Other,
	}
}