model

package
v0.0.0-...-b92f783 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommonPrefix = "zd_"
	Models       = []interface{}{
		&ZdDef{},
		&ZdField{},
		&ZdSection{},
		&ZdRefer{},
		&ZdConfig{},
		&ZdRanges{},
		&ZdRangesItem{},
		&ZdInstances{},
		&ZdInstancesItem{},
		&ZdText{},
		&ZdExcel{},
	}
)

Functions

This section is empty.

Types

type BaseModel

type BaseModel struct {
	ID        uint       `gorm:"primary_key" sql:"type:INT(10) UNSIGNED NOT NULL" json:"id"`
	CreatedAt *time.Time `json:"createdAt,omitempty"`
	UpdatedAt *time.Time `json:"updatedAt,omitempty"`

	Deleted  bool `json:"-" gorm:"default:false"`
	Disabled bool `json:"disabled,omitempty" gorm:"default:false"`
}

type ZdConfig

type ZdConfig struct {
	BaseModel

	Title string `json:"title"`
	Desc  string `json:"desc"`

	Range   string `json:"range"`
	Prefix  string `json:"prefix"`
	Postfix string `json:"postfix"`
	Loop    string `json:"loop"`
	Loopfix string `json:"loopfix"`
	Format  string `json:"format"`

	Yaml      string `json:"yaml"`
	Path      string `json:"path" yaml:"-"`
	Folder    string `json:"folder" yaml:"-"`
	FileName  string `json:"fileName" yaml:"-"`
	ReferName string `json:"referName" yaml:"-"`

	// for range edit
	IsRange  bool        `gorm:"default:true" json:"isRange" yaml:"-"`
	Sections []ZdSection `gorm:"ForeignKey:ownerID" json:"sections" yaml:"-"`
}

func (*ZdConfig) TableName

func (*ZdConfig) TableName() string

type ZdDef

type ZdDef struct {
	BaseModel

	Title string `json:"title"`
	Type  string `json:"type"`
	Desc  string `json:"desc"`

	Yaml     string `json:"yaml"`
	Path     string `json:"path" yaml:"-"`
	Folder   string `json:"folder" yaml:"-"`
	FileName string `json:"fileName" yaml:"-"`
	IsMock   bool   `json:"isMock"`

	ReferName string    `json:"referName" yaml:"-"`
	From      string    `json:"from"`
	Fields    []ZdField `json:"fields"`
}

func (ZdDef) TableName

func (ZdDef) TableName() string

type ZdExcel

type ZdExcel struct {
	BaseModel

	Title string `json:"title"`
	Sheet string `json:"sheet"`

	ChangeTime string `json:"changeTime"`
	Yaml       string `json:"yaml"`
	Path       string `json:"path" yaml:"-"`
	Folder     string `json:"folder" yaml:"-"`
	FileName   string `json:"fileName" yaml:"-"`
	ReferName  string `json:"referName" yaml:"-"`
}

func (*ZdExcel) TableName

func (*ZdExcel) TableName() string

type ZdField

type ZdField struct {
	BaseModel

	Field string `json:"field"`
	Note  string `json:"note"`

	Range    string `json:"range"`
	Prefix   string `json:"prefix"`
	Postfix  string `json:"postfix"`
	Divider  string `json:"divider"`
	Loop     string `json:"loop"`
	Loopfix  string `json:"loopfix"`
	Format   string `json:"format"`
	Type     string `json:"type"`
	Mode     string `json:"mode"`
	Items    int    `json:"records"`
	Length   int    `json:"length"`
	LeftPad  string `json:"leftPad"`
	RightPad string `json:"rightPad"`
	Rand     bool   `json:"rand"`
	Config   string `json:"config"`
	Use      string `json:"use"`
	From     string `json:"fromCol"`
	Select   string `json:"selectCol"`
	Where    string `json:"whereCol"`
	Limit    int    `json:"limitCol"`

	// refer to yaml or text by using range prop
	Step   string `json:"step"`
	Repeat string `json:"repeat"`

	Exp      string `json:"exp"`
	DefID    uint   `json:"defID"`
	ParentID uint   `json:"parentID"`
	UseID    uint   `json:"useID"`
	ConfigID uint   `json:"configID"`

	Ord  int  `gorm:"default:1" json:"ord"`
	Join bool `json:"join"`

	Fields []*ZdField `gorm:"-" json:"fields"`
	Froms  []*ZdField `gorm:"-" json:"froms"`

	// for range edit
	IsRange  bool        `gorm:"default:true" json:"isRange"`
	Sections []ZdSection `gorm:"ForeignKey:ownerID" json:"sections"`

	// for refer edit
	Refer ZdRefer `gorm:"ForeignKey:ownerID" json:"refer"`

	// generated by range or refer
	GeneratedBy consts.GeneratedBy `gorm:"default:range" json:"generatedBy"`
}

func (*ZdField) TableName

func (*ZdField) TableName() string

type ZdInstances

type ZdInstances struct {
	BaseModel

	Title string `json:"title" yaml:"title,omitempty"`
	Desc  string `json:"desc" yaml:"desc,omitempty"`

	Yaml   string `json:"yaml" yaml:"-"`
	Path   string `json:"path" yaml:"-"`
	Folder string `json:"folder" yaml:"-"`

	FileName  string `json:"fileName" yaml:"-"`
	ReferName string `json:"referName" yaml:"-"`

	From      string            `gorm:"-" json:"from"`
	Instances []ZdInstancesItem `gorm:"ForeignKey:instancesID" json:"instances" yaml:"instances"`
}

func (*ZdInstances) TableName

func (*ZdInstances) TableName() string

type ZdInstancesItem

type ZdInstancesItem struct {
	BaseModel

	Instance string `json:"instance" yaml:"instance,omitempty"`
	Note     string `json:"note" yaml:"note,omitempty"`

	Field    string `json:"field" yaml:"field,omitempty"`
	Range    string `json:"range" yaml:"range,omitempty"`
	Prefix   string `json:"prefix" yaml:"prefix,omitempty"`
	Postfix  string `json:"postfix" yaml:"postfix,omitempty"`
	Loop     string `json:"loop" yaml:"loop,omitempty"`
	Loopfix  string `json:"loopfix" yaml:"loopfix,omitempty"`
	Format   string `json:"format" yaml:"format,omitempty"`
	Type     string `json:"type" yaml:"type,omitempty"`
	Mode     string `json:"mode" yaml:"mode,omitempty"`
	Items    int    `json:"records,omitempty" yaml:"records,omitempty"`
	Length   int    `json:"length" yaml:"length,omitempty"`
	LeftPad  string `json:"leftPad" yaml:"leftPad,omitempty"`
	RightPad string `json:"rightPad" yaml:"rightPad,omitempty"`
	Rand     bool   `json:"rand" yaml:"rand,omitempty"`

	Config string `json:"config" yaml:"config,omitempty"`
	Use    string `json:"use" yaml:"use,omitempty"`
	From   string `json:"fromCol" yaml:"from,omitempty"`
	Select string `json:"selectCol" yaml:"select,omitempty"`
	Where  string `json:"whereCol" yaml:"where,omitempty"`
	Limit  int    `json:"limitCol" yaml:"limit,omitempty"`

	Exp         string `json:"exp" yaml:"exp,omitempty"`
	InstancesID uint   `json:"instancesID" yaml:"-"`
	ParentID    uint   `json:"parentID" yaml:"-"`
	ConfigID    uint   `json:"configID" yaml:"-"`
	UseID       uint   `json:"useID" yaml:"-"`

	Ord    int                `gorm:"default:1" json:"ord" yaml:"-"`
	Fields []*ZdInstancesItem `gorm:"-" json:"fields" yaml:"fields,omitempty"`
	Froms  []*ZdInstancesItem `gorm:"-" json:"froms" yaml:"froms,omitempty"`

	// for range edit
	IsRange  bool        `gorm:"default:true" json:"isRange" yaml:"-"`
	Sections []ZdSection `gorm:"ForeignKey:ownerID" json:"sections" yaml:"-"`

	// for refer edit
	Refer ZdRefer `gorm:"ForeignKey:ownerID" json:"refer" yaml:"-"`
}

func (*ZdInstancesItem) TableName

func (*ZdInstancesItem) TableName() string

type ZdRanges

type ZdRanges struct {
	BaseModel

	Title   string `json:"title"`
	Desc    string `json:"desc"`
	Prefix  string `json:"prefix"`
	Postfix string `json:"postfix"`
	Format  string `json:"format"`

	Yaml      string `json:"yaml"`
	Path      string `json:"path" yaml:"-"`
	Folder    string `json:"folder" yaml:"-"`
	FileName  string `json:"fileName" yaml:"-"`
	ReferName string `json:"referName" yaml:"-"`

	Ranges   []ZdRangesItem    `gorm:"ForeignKey:rangesID" json:"ranges" yaml:"-"`
	RangeMap map[string]string `gorm:"-" yaml:"ranges"`
}

func (*ZdRanges) TableName

func (*ZdRanges) TableName() string

type ZdRangesItem

type ZdRangesItem struct {
	BaseModel

	RangesID uint   `json:"rangesID"`
	Field    string `json:"field"`
	Ord      int    `json:"ord"`

	Value    string      `json:"value"`
	Sections []ZdSection `gorm:"ForeignKey:ownerID" json:"sections"`

	// for tree node
	ParentID uint            `gorm:"-" json:"parentID"`
	Fields   []*ZdRangesItem `gorm:"-" json:"fields"`
}

func (*ZdRangesItem) TableName

func (*ZdRangesItem) TableName() string

type ZdRefer

type ZdRefer struct {
	BaseModel

	OwnerType string `json:"ownerType"` // field or instances
	OwnerID   uint   `json:"ownerID"`
	Type      string `json:"type"`

	Value string `json:"value"`
	File  string `json:"file"`
	Sheet string `json:"sheet"`

	ColName   string `json:"colName"`
	ColIndex  int    `json:"colIndex"`
	Condition string `json:"condition"`
	Count     int    `json:"count"`
	CountTag  string `json:"countTag"`
	Step      int    `json:"step"`
	Rand      bool   `json:"rand"`
	HasTitle  bool   `json:"hasTitle"`
}

func (*ZdRefer) TableName

func (*ZdRefer) TableName() string

type ZdSection

type ZdSection struct {
	BaseModel

	OwnerType string `json:"ownerType"` // field or instances
	OwnerID   uint   `json:"ownerID"`
	Type      string `gorm:"default:interval" json:"type"`
	Value     string `json:"value"`
	Ord       int    `gorm:"default:1" json:"ord"`

	// for range
	Start     string `json:"start"`
	End       string `json:"end"`
	Step      int    `gorm:"default:1" json:"step"`
	Repeat    string `gorm:"default:1" json:"repeat"`
	RepeatTag string `json:"repeatTag"`
	Rand      bool   `gorm:"default:false" json:"rand"`

	// for arr and const
	Text string `gorm:"-" json:"-"`
}

func (*ZdSection) TableName

func (*ZdSection) TableName() string

type ZdText

type ZdText struct {
	BaseModel

	Title string `json:"title"`

	Content   string `json:"content"`
	Path      string `json:"path" yaml:"-"`
	Folder    string `json:"folder" yaml:"-"`
	FileName  string `json:"fileName" yaml:"-"`
	ReferName string `json:"referName" yaml:"-"`
}

func (*ZdText) TableName

func (*ZdText) TableName() string

Jump to

Keyboard shortcuts

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