static_data

package
v0.0.0-...-83fd405 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexTypeNot    IndexType = iota // 不是索引
	IndexTypeUnique                  // 唯一索引,值不可以重复
	IndexTypeNormal                  // 普通索引,值可以重复

	IndexNameNot    = ""
	IndexNameUnique = "unique"
	IndexNameNormal = "normal"
)
View Source
const (
	DefaultSchema = "t=int"

	NameSchemaKey        = "n"
	TypeSchemaKey        = "t"
	IndexSchemaKey       = "i"
	SliceSchemaKey       = "s"
	ObjectSchemaKey      = "o"  // todo
	ObjectSliceSchemaKey = "os" // todo
)

Variables

View Source
var (
	MaxRow = 10000
	MaxCol = 150
)

Functions

func CanIgnoreSheetCell

func CanIgnoreSheetCell(cell *xlsx.Cell) (ignore bool, err error)

数据是否可以跳过

func CanIgnoreSheetRow

func CanIgnoreSheetRow(sheet *xlsx.Sheet, row int) (ignore bool, err error)

行是否可以跳过

func IndexType2Name

func IndexType2Name(i IndexType) (o string, ok bool)

func ParseEnumValueAliasString

func ParseEnumValueAliasString(aliasesString string) (aliases []string)

func ParseSchemaString

func ParseSchemaString(input string) (output map[string]string)

func ReadType

func ReadType(path string) (err error)

func XlsxType2GoType

func XlsxType2GoType(i string) (o string, ok bool)

Types

type Attribute

type Attribute struct {
	Field
	Value string `json:"-"`
	Row   int    `json:"-"`
}

func NewAttribute

func NewAttribute(name string, t string, value string, comment string, row int, col int) (a *Attribute, err error)

type Data

type Data []pair

func (*Data) Append

func (d *Data) Append(k string, v interface{})

func (Data) MarshalJSON

func (d Data) MarshalJSON() (ba []byte, err error)

type Enum

type Enum struct {
	Name    string `xml:",attr"`
	Comment string `xml:",attr"`
	Values  []*EnumValue
	// contains filtered or unexported fields
}

func GetEnumByName

func GetEnumByName(es []*Enum, name string) (e *Enum)

func NewEnum

func NewEnum(name string, comment string) (e *Enum)

func ReadEnum

func ReadEnum(path string) (allEnum []*Enum, err error)

func (*Enum) AppendValue

func (e *Enum) AppendValue(new *EnumValue) (err error)

func (*Enum) Format

func (e *Enum) Format() (err error)

func (Enum) GetValue

func (e Enum) GetValue(aliasOrValueString string) (v *EnumValue)

func (Enum) String

func (e Enum) String() string

type EnumValue

type EnumValue struct {
	Name string `xml:",attr"`

	Value   int
	Aliases []string
	Comment string `xml:",attr"`
	// contains filtered or unexported fields
}

func NewEnumValue

func NewEnumValue(name string, valueString string, aliasString string, comment string) (ef *EnumValue)

func (*EnumValue) Format

func (v *EnumValue) Format() (err error)

type ErrIgnoreField

type ErrIgnoreField struct {
}

func (ErrIgnoreField) Error

func (e ErrIgnoreField) Error() string

type ErrNeedSchema

type ErrNeedSchema struct {
}

func (ErrNeedSchema) Error

func (e ErrNeedSchema) Error() string

type ErrNeedType

type ErrNeedType struct {
}

func (ErrNeedType) Error

func (e ErrNeedType) Error() string

type ErrNotField

type ErrNotField struct {
}

func (ErrNotField) Error

func (e ErrNotField) Error() string

type ErrTableFieldEmpty

type ErrTableFieldEmpty struct {
}

func (ErrTableFieldEmpty) Error

func (e ErrTableFieldEmpty) Error() string

type Excel

type Excel struct {
	Name     string `json:"-"`
	Sheets   []*Sheet
	SheetMap map[string]*Sheet `json:"-"`
}

func NewExcel

func NewExcel(name string) *Excel

func Read

func Read(path string, tableTags []string, attributeTags []string, dataTags []string, readData bool, sd *StaticData, clientMode bool) (e *Excel, err error)

func (*Excel) Append

func (e *Excel) Append(sheet *Sheet) (err error)

type Field

type Field struct {
	Name string
	Type string

	Comment string
	Column  int `json:"-"`
	// contains filtered or unexported fields
}

func NewField

func NewField(ft FieldType, name string, tYpE string, realType string, comment string) (f *Field)

func (*Field) CheckAndFormat

func (f *Field) CheckAndFormat() (err error)

type FieldType

type FieldType = int
const (
	FieldTypeBase FieldType = iota
	FieldTypeBaseSlice
	FieldTypeEnum
	FieldTypeEnumSlice
	FieldTypeObject      // todo
	FieldTypeObjectSlice // todo
)

type IndexType

type IndexType int

func IndexName2Type

func IndexName2Type(i string) (o IndexType, ok bool)

func (IndexType) String

func (i IndexType) String() string

type Offset

type Offset [2]int

func NewOffset

func NewOffset(row int, column int) *Offset

func (Offset) Check

func (o Offset) Check() bool

func (Offset) Column

func (o Offset) Column() int

func (Offset) Row

func (o Offset) Row() int

func (*Offset) SetColumn

func (o *Offset) SetColumn(c int)

func (*Offset) SetRow

func (o *Offset) SetRow(r int)

func (Offset) String

func (o Offset) String() string

type Sheet

type Sheet struct {
	Name    string
	Comment string

	Fields        []*Field
	UniqueIndexes []*XlsxField `json:",omitempty"` // 唯一索引
	NormalIndexes []*XlsxField `json:",omitempty"` // 普通索引
	Attributes    []*Attribute
	Global        Data
	Datas         []Data

	SheetName            string  `json:"-"`
	TableNameOffset      *Offset `json:"-"`
	AttributeBeginOffset *Offset `json:"-"`
	DataBeginOffset      *Offset `json:"-"`
	// contains filtered or unexported fields
}

func NewSheet

func NewSheet(sheetName string) *Sheet

func (*Sheet) AppendField

func (s *Sheet) AppendField(newField *Field) (err error)

func (*Sheet) AppendXlsxField

func (s *Sheet) AppendXlsxField(newField *XlsxField) (err error)

func (*Sheet) Format

func (s *Sheet) Format(sd *StaticData, clientMode bool) (err error)

func (*Sheet) ReadData

func (s *Sheet) ReadData(sheet *xlsx.Sheet, sd *StaticData, clientMode bool) (err error)

func (Sheet) String

func (s Sheet) String() string

type StaticData

type StaticData struct {
	Enums  []*Enum
	Tables []*Sheet
}

func New

func New() *StaticData

func (*StaticData) AppendTable

func (sd *StaticData) AppendTable(newTable *Sheet) (err error)

type XlsxField

type XlsxField struct {
	Name string
	Type string

	Comment string
	// contains filtered or unexported fields
}

func NewXlsxField

func NewXlsxField(col int, name string, comment string, schemaString string) (f *XlsxField)

func (*XlsxField) Format

func (f *XlsxField) Format() (err error)

func (XlsxField) String

func (f XlsxField) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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