schema

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func BuildPreset

func BuildPreset(requst map[string]any, skma *Table) map[string]any

func IsDateRange

func IsDateRange(data any) bool

func PivotByActive

func PivotByActive(p *PivotBy) bool

PivotByActive 透视是否开启。前端保存 on/off,关闭后 Pivot/Value 可能仍有值,必须以 State 为准。

func SetCache

func SetCache(cache ICache)

SetCache 设置全局缓存实例(用于测试或自定义实现)

Types

type CacheConfig

type CacheConfig struct {
	Provider string // mem, redis
}

CacheConfig 缓存配置

type Click

type Click = source.Click

type CountFN

type CountFN = source.CountFn

type Digest

type Digest struct {
	Table *Table

	Fields []Field
	Groups []Group
	Sticky []string

	PivotBy *PivotBy
	GroupBy []source.GroupBy
	CountFn []source.CountFn
}

func (*Digest) Parse

func (self *Digest) Parse(payload object) ([]source.CountFn, error)

type FExtra

type FExtra = source.FExtra

type Field

type Field = source.Field

type GExtra

type GExtra = source.GExtra

type Group

type Group = source.Group

type GroupBy

type GroupBy = source.GroupBy

type ICache

type ICache interface {
	Del(key string)
	Get(key string) *Source
	Set(key string, source *Source)
}

ICache 定义缓存接口

func GetCache

func GetCache() ICache

GetCache 获取全局缓存实例

func NewCache

func NewCache(provider string, ttl time.Duration) ICache

NewCache 创建缓存实例(类似 NewEngine 的工厂模式)

type ISchema

type ISchema interface {
	GetGroups() []Group
	GetFields() []Field
	GetRefers() []Refer
	GetSearch() *request.Search
	GetField(key string) *Field
}

type Input

type Input struct {
	Model  *Model  `json:"-"` // 模型信息
	Input  *SInput `json:"-"` // 模型信息
	Source *Source `json:"-"` // 登陆用户
	Scope  object  `json:"-"` // 查询限制

	// this fields make record unique
	Unique []string `json:"-"` // 唯一字段

	Title string `json:"title,omitempty"` // 模型信息

	Groups []Group `json:"groups,omitempty"` // 分组信息
	Fields []Field `json:"fields,omitempty"` // 字段类型
	XRules []XRule `json:"xrules,omitempty"` // 表单事件
	Clicks []Click `json:"clicks,omitempty"` // 表单按钮

	Values object `json:"values,omitempty"` // 分组信息
	Refers object `json:"refers,omitempty"` // 字典信息
	Others object `json:"-"`                // 视图扩展配置

	// 传入信息
	Account *request.Account `json:"-"`       // 登陆用户
	Request *request.Record  `json:"request"` // 请求信息
}

func (*Input) GetField

func (self *Input) GetField(uukey string) *source.Field

func (*Input) GetFields

func (self *Input) GetFields() []Field

func (*Input) GetGroup

func (self *Input) GetGroup(uukey string) *source.Group

func (*Input) GetGroups

func (self *Input) GetGroups() []Group

func (*Input) GetRefers

func (self *Input) GetRefers() []Refer

func (*Input) GetRelation

func (self *Input) GetRelation(uukey string, value any) object

GetRelation 按 relation 字段在 Refers 中查找与 value 匹配的一条关联对象(扁平 map),与 Table.GetPlain 同源逻辑。 uukey 为字段 key(如 basic.team_id);value 为 Combine 里该字段存的外键值(与 refer.KeyBy 对应)。 未找到时返回 nil。

func (*Input) GetRequest

func (self *Input) GetRequest() *request.Record

func (*Input) GetSearch

func (self *Input) GetSearch() *request.Search

func (*Input) NeedRefers

func (self *Input) NeedRefers() bool

NeedRefers 与 EngineService.AttachRefers 中实际会发起关联查询的条件一致: 存在已展示、已配置 relation、且 Values 里该字段 UUKey 对应有效外键的 RELATION 字段。

type Model

type Model = source.Model

type Option

type Option = source.Option

type PivotBy

type PivotBy = source.PivotBy

type Query

type Query struct {
	Logic string   `json:"logic"`           // 逻辑类型
	Field string   `json:"field"`           // 字段名称
	DType string   `json:"dtype"`           // 数据类型
	Value any      `json:"value"`           // 数据值
	Items *[]Query `json:"items,omitempty"` // 子查询
}

func BuildQuery

func BuildQuery(payload map[string]any) ([]Query, error)

type Refer

type Refer = source.Refer

type SInput

type SInput = source.Input

type STable

type STable = source.Table

type SortBy

type SortBy = source.Order

type Source

type Source = source.Value

type Table

type Table struct {
	Scene string `json:"-"` // 构建来源(场景)

	Model *source.Model `json:"-"` // 模型信息
	Table *source.Table `json:"-"` // 表格信息
	// query scope
	Scope map[string]any `json:"-"` // 查询限制
	Query map[string]any `json:"-"` // 查询信息

	Sticky []string       `json:"sticky"` // 固定字段
	Groups []source.Group `json:"groups"` // 分组信息
	Fields []source.Field `json:"fields"` // 字段类型
	Clicks []source.Click `json:"clicks"` // 表格事件
	Refers map[string]any `json:"refers"` // 字典信息
	Others map[string]any `json:"others"` // 其他信息
	Source *source.Value  `json:"-"`      // 源数据

	// 传入信息
	Account *request.Account `json:"-"`       // 登陆用户
	Request *request.Search  `json:"request"` // 请求信息
}

func (*Table) BuildCountFn

func (self *Table) BuildCountFn() []CountFN

others.count=[]string{index|func|label} 金额求和:["basic.amount|SUM|合计金额"]

func (*Table) BuildDigest

func (self *Table) BuildDigest() *Digest

func (*Table) BuildGroupBy

func (self *Table) BuildGroupBy() []GroupBy

others.group=[]string{index|sort|format} 按车型分组:["basic.vehicle|ASC|车型"]

func (*Table) BuildPivotBy

func (self *Table) BuildPivotBy() *PivotBy

others.pivot=index|value|state

func (*Table) BuildQuery

func (self *Table) BuildQuery() []Query

func (*Table) GetField

func (self *Table) GetField(uukey string) *source.Field

func (*Table) GetFields

func (self *Table) GetFields() []source.Field

func (*Table) GetGroups

func (self *Table) GetGroups() []source.Group

func (*Table) GetPlain

func (self *Table) GetPlain(uukey string, value any) string

func (*Table) GetRefer

func (self *Table) GetRefer(uukey string) *source.Refer

format refer

func (*Table) GetRefers

func (self *Table) GetRefers() []source.Refer

func (*Table) GetRequest

func (self *Table) GetRequest() *request.Search

func (*Table) GetSearch

func (self *Table) GetSearch() *request.Search

func (*Table) GetSubject

func (self *Table) GetSubject() *source.Field

Get Subject Field for Schema

func (*Table) SetDisplay

func (self *Table) SetDisplay(refer *source.Refer, display string)

SetDisplay for Relation Field

type XRule

type XRule = source.XRule

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL