types

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InHeader InType = "header"
	InPath          = "path"
	InQuery         = "query"
	InBody          = "body"
)

Variables

View Source
var (
	IntType        = &Type{Name: "int", IsPrimitive: true, DefaultValue: int(0)}
	Int8Type       = &Type{Name: "int8", IsPrimitive: true, DefaultValue: int8(0)}
	Int16Type      = &Type{Name: "int16", IsPrimitive: true, DefaultValue: int16(0)}
	Int32Type      = &Type{Name: "int32", IsPrimitive: true, DefaultValue: int32(0)}
	Int64Type      = &Type{Name: "int64", IsPrimitive: true, DefaultValue: int64(0)}
	UintType       = &Type{Name: "uint", IsPrimitive: true, DefaultValue: uint(0)}
	Uint8Type      = &Type{Name: "uint8", IsPrimitive: true, DefaultValue: uint8(0)}
	Uint16Type     = &Type{Name: "uint16", IsPrimitive: true, DefaultValue: uint16(0)}
	Uint32Type     = &Type{Name: "uint32", IsPrimitive: true, DefaultValue: uint32(0)}
	Uint64Type     = &Type{Name: "uint64", IsPrimitive: true, DefaultValue: uint64(0)}
	Float32Type    = &Type{Name: "float32", IsPrimitive: true, DefaultValue: float32(0)}
	Float64Type    = &Type{Name: "float64", IsPrimitive: true, DefaultValue: float64(0)}
	BoolType       = &Type{Name: "bool", IsPrimitive: true, DefaultValue: false}
	StringType     = &Type{Name: "string", IsPrimitive: true, DefaultValue: ""}
	Complex64Type  = &Type{Name: "complex64", IsPrimitive: true, DefaultValue: 0}
	Complex128Type = &Type{Name: "complex128", IsPrimitive: true, DefaultValue: 0}
	ByteType       = &Type{Name: "byte", IsPrimitive: true, DefaultValue: 0}
	RuneType       = &Type{Name: "rune", IsPrimitive: true, DefaultValue: ""}
	ErrorType      = &Type{Name: "error"}
	PrimitiveTypes = map[string]*Type{
		IntType.Name:        IntType,
		Int8Type.Name:       Int8Type,
		Int16Type.Name:      Int16Type,
		Int32Type.Name:      Int32Type,
		Int64Type.Name:      Int64Type,
		UintType.Name:       UintType,
		Uint8Type.Name:      Uint8Type,
		Uint16Type.Name:     Uint16Type,
		Uint32Type.Name:     Uint32Type,
		Uint64Type.Name:     Uint64Type,
		Float32Type.Name:    Float32Type,
		Float64Type.Name:    Float64Type,
		BoolType.Name:       BoolType,
		StringType.Name:     StringType,
		Complex64Type.Name:  Complex64Type,
		Complex128Type.Name: Complex128Type,
		ByteType.Name:       ByteType,
		RuneType.Name:       RuneType,
	}
)

Functions

This section is empty.

Types

type API

type API struct {
	Name        Name      `yaml:"name"`
	Description string    `yaml:"desc"`
	URI         string    `yaml:"uri"`
	Method      string    `yaml:"method"`
	Request     *Request  `yaml:"request"`
	Response    *Response `yaml:"response"`
}

type APIClass

type APIClass struct {
	Class      `yaml:",inline"`
	Include    []*Include `yaml:"include"`
	IncludeAll bool       `yaml:"include_all"`
}

type APIResponseHelper

type APIResponseHelper struct {
	Class        *Class
	ReceiverName string
	ImportList   ImportList
}

func (*APIResponseHelper) CreateCollectionMethodDeclare

func (h *APIResponseHelper) CreateCollectionMethodDeclare() *MethodDeclare

func (*APIResponseHelper) CreateMethodDeclare

func (h *APIResponseHelper) CreateMethodDeclare() *MethodDeclare

func (*APIResponseHelper) Field

func (h *APIResponseHelper) Field(name string) *code.Statement

func (*APIResponseHelper) GetClass

func (h *APIResponseHelper) GetClass() *Class

func (*APIResponseHelper) GetImportList

func (h *APIResponseHelper) GetImportList() ImportList

func (*APIResponseHelper) IsModelPackage

func (h *APIResponseHelper) IsModelPackage() bool

func (*APIResponseHelper) MethodCall

func (h *APIResponseHelper) MethodCall(name string, args ...code.Code) *code.Statement

func (*APIResponseHelper) Package

func (h *APIResponseHelper) Package(name string) string

func (*APIResponseHelper) Receiver

func (h *APIResponseHelper) Receiver() *code.Statement

type Attribute

type Attribute struct {
	Name    string
	Type    string
	Desc    string
	Example interface{}
}

type Class

type Class struct {
	Name      Name      `yaml:"name"`
	DataStore string    `yaml:"datastore"`
	Index     *INDEX    `yaml:"index"`
	ReadOnly  bool      `yaml:"read_only,omitempty"`
	Members   []*Member `yaml:"members"`
	// contains filtered or unexported fields
}

func (*Class) AllDependencyClasses

func (c *Class) AllDependencyClasses() []*Class

func (*Class) DefaultTestObject

func (c *Class) DefaultTestObject() *TestObject

func (*Class) DependencyClasses

func (c *Class) DependencyClasses() []*Class

func (*Class) DependencyMembers

func (c *Class) DependencyMembers() []*Member

func (*Class) ExtendMembers

func (c *Class) ExtendMembers() Members

func (*Class) FileName

func (c *Class) FileName() string

func (*Class) Keys

func (c *Class) Keys() []Members

func (*Class) MarshalRelation

func (c *Class) MarshalRelation() ([]byte, error)

func (*Class) MemberByName

func (c *Class) MemberByName(name string) *Member

func (*Class) Merge

func (c *Class) Merge(schema *Class)

func (*Class) PrimaryKey

func (c *Class) PrimaryKey() *Member

func (*Class) RelationMembers

func (c *Class) RelationMembers() Members

func (*Class) ResolveTypeReference

func (c *Class) ResolveTypeReference() error

func (*Class) SetClassMap

func (c *Class) SetClassMap(classMap *map[string]*Class)

func (*Class) SetSubClassMap

func (c *Class) SetSubClassMap(subClassMap *map[string]*Class)

func (*Class) TestData

func (c *Class) TestData() *TestData

func (*Class) UniqueKeys

func (c *Class) UniqueKeys() []Members

func (*Class) Validate

func (c *Class) Validate() error

type ConstructorDeclare

type ConstructorDeclare struct {
	Class      *Class
	MethodName string
	Args       ValueDeclares
	Return     ValueDeclares
	ImportList ImportList
}

func (*ConstructorDeclare) MethodInterface

func (d *ConstructorDeclare) MethodInterface(importList ImportList) *code.Statement

func (*ConstructorDeclare) Package

func (d *ConstructorDeclare) Package(name string) string

type ConstructorParam

type ConstructorParam struct {
	DataAccessParam
	ImplName string
	Args     *ConstructorParamArgs
}

type ConstructorParamArgs

type ConstructorParamArgs struct {
	Context func() *code.Statement
}

type CountParam

type CountParam struct {
	DataAccessParam
	Args *CountParamArgs
}

type CountParamArgs

type CountParamArgs struct {
	Context func() *code.Statement
	Members []*Member
}

type CreateParam

type CreateParam struct {
	DataAccessParam
	Args *CreateParamArgs
}

type CreateParamArgs

type CreateParamArgs struct {
	Context func() *code.Statement
	Value   func() *code.Statement
}

type DAOContext

type DAOContext interface{}

type DataAccessParam

type DataAccessParam struct {
	Class      *Class
	ClassName  func() *code.Statement
	Receiver   func() *code.Statement
	ImportList ImportList
	SQL        *SQL
}

func (*DataAccessParam) Field

func (p *DataAccessParam) Field(name string) *code.Statement

func (*DataAccessParam) Package

func (p *DataAccessParam) Package(name string) string

type DeleteParam

type DeleteParam struct {
	DataAccessParam
	Args *DeleteParamArgs
}

type DeleteParamArgs

type DeleteParamArgs struct {
	Context func() *code.Statement
	Value   func() *code.Statement
	Members []*Member
}

type EntityMethodHelper

type EntityMethodHelper struct {
	Class        *Class
	ReceiverName string
	ImportList   ImportList
}

func (*EntityMethodHelper) CreateMethodDeclare

func (h *EntityMethodHelper) CreateMethodDeclare() *MethodDeclare

func (*EntityMethodHelper) CreatePluralMethodDeclare

func (h *EntityMethodHelper) CreatePluralMethodDeclare() *MethodDeclare

func (*EntityMethodHelper) Field

func (h *EntityMethodHelper) Field(name string) *Statement

func (*EntityMethodHelper) Package

func (h *EntityMethodHelper) Package(name string) string

type FindParam

type FindParam struct {
	DataAccessParam
	Args                *FindParamArgs
	IsSingleReturnValue bool
}

type FindParamArgs

type FindParamArgs struct {
	Context func() *code.Statement
	Members []*Member
}

type INDEX

type INDEX struct {
	PrimaryKey string       `yaml:"primary_key"`
	UniqueKeys []*UniqueKey `yaml:"unique_keys,omitempty"`
	Keys       []*Key       `yaml:"keys,omitempty"`
}

type ImportDeclare

type ImportDeclare struct {
	Name string
	Path string
}

func (*ImportDeclare) GetName

func (d *ImportDeclare) GetName() string

func (*ImportDeclare) GetPath

func (d *ImportDeclare) GetPath() string

type ImportList

type ImportList map[string]*ImportDeclare

func DefaultImportList

func DefaultImportList(modulePath string, ctxImportPath string) ImportList

func (ImportList) Each

func (l ImportList) Each(f func(imp code.Import))

func (ImportList) Package

func (l ImportList) Package(name string) string

type InType

type InType string

type Include

type Include struct {
	Name    Name       `yaml:"name"`
	Only    []Name     `yaml:"only"`
	Except  []Name     `yaml:"except"`
	Include []*Include `yaml:"include"`
}

func (*Include) BuilderCode

func (i *Include) BuilderCode(h *APIResponseHelper) code.Code

type Key

type Key struct {
	Columns []string
}

func (*Key) MarshalYAML

func (k *Key) MarshalYAML() (interface{}, error)

func (*Key) UnmarshalYAML

func (k *Key) UnmarshalYAML(unmarshal func(interface{}) error) error

type Member

type Member struct {
	Name        Name         `yaml:"name"`
	Type        *TypeDeclare `yaml:"type,omitempty"`
	Extend      bool         `yaml:"extend,omitempty"`
	Render      *Render      `yaml:"render,omitempty"`
	HasMany     bool         `yaml:"has_many,omitempty"`
	Nullable    bool         `yaml:"nullable,omitempty"`
	Description string       `yaml:"desc,omitempty"`
	Example     interface{}  `yaml:"example,omitempty"`
	Relation    *Relation    `yaml:"relation,omitempty"`
}

func (*Member) CamelType

func (m *Member) CamelType() string

func (*Member) CollectionName

func (m *Member) CollectionName() Name

func (*Member) IsCollectionType

func (m *Member) IsCollectionType() bool

func (*Member) ModelCollectionTypeName

func (m *Member) ModelCollectionTypeName(importList ImportList) string

func (*Member) RenderNameByProtocol

func (m *Member) RenderNameByProtocol(requiredProtocol string) string

func (*Member) RenderProtocols

func (m *Member) RenderProtocols() []string

func (*Member) Validate

func (m *Member) Validate() error

type Members

type Members []*Member

func (Members) JoinedName

func (m Members) JoinedName() string

func (Members) Names

func (m Members) Names() []Name

type Method

type Method struct {
	Decl *MethodDeclare
	Body []code.Code
}

func (*Method) Generate

func (m *Method) Generate(importList ImportList) code.Code

type MethodDeclare

type MethodDeclare struct {
	Class                *Class
	ReceiverName         string
	ReceiverClassName    string
	ImportList           ImportList
	MethodName           string
	ArgMembers           Members
	Args                 ValueDeclares
	Return               ValueDeclares
	IsNotPointerReceiver bool
}

func (*MethodDeclare) Interface

func (d *MethodDeclare) Interface(importList ImportList) *code.Statement

func (*MethodDeclare) MethodInterface

func (d *MethodDeclare) MethodInterface(importList ImportList) *code.Statement

type Methods

type Methods []*Method

func (Methods) Generate

func (m Methods) Generate(importList ImportList) []code.Code

type ModelMethodHelper

type ModelMethodHelper struct {
	Class        *Class
	ReceiverName string
	ImportList   ImportList
}

func (*ModelMethodHelper) CollectionProperties

func (h *ModelMethodHelper) CollectionProperties() ValueDeclares

func (*ModelMethodHelper) CreateCollectionMethodDeclare

func (h *ModelMethodHelper) CreateCollectionMethodDeclare() *MethodDeclare

func (*ModelMethodHelper) CreateMethodDeclare

func (h *ModelMethodHelper) CreateMethodDeclare() *MethodDeclare

func (*ModelMethodHelper) CreateMultipleCollectionMethodDeclare

func (h *ModelMethodHelper) CreateMultipleCollectionMethodDeclare() *MethodDeclare

func (*ModelMethodHelper) DAO

func (h *ModelMethodHelper) DAO() *code.Statement

func (*ModelMethodHelper) DAOName

func (h *ModelMethodHelper) DAOName() string

func (*ModelMethodHelper) Field

func (h *ModelMethodHelper) Field(name string) *code.Statement

func (*ModelMethodHelper) GetClass

func (h *ModelMethodHelper) GetClass() *Class

func (*ModelMethodHelper) GetImportList

func (h *ModelMethodHelper) GetImportList() ImportList

func (*ModelMethodHelper) IsModelPackage

func (h *ModelMethodHelper) IsModelPackage() bool

func (*ModelMethodHelper) MethodCall

func (h *ModelMethodHelper) MethodCall(name string, args ...code.Code) *code.Statement

func (*ModelMethodHelper) ModelCollectionName

func (h *ModelMethodHelper) ModelCollectionName() string

func (*ModelMethodHelper) ModelCollectionType

func (h *ModelMethodHelper) ModelCollectionType() *TypeDeclare

func (*ModelMethodHelper) ModelName

func (h *ModelMethodHelper) ModelName() string

func (*ModelMethodHelper) ModelType

func (h *ModelMethodHelper) ModelType() *TypeDeclare

func (*ModelMethodHelper) Package

func (h *ModelMethodHelper) Package(name string) string

func (*ModelMethodHelper) Receiver

func (h *ModelMethodHelper) Receiver() *code.Statement

type Name

type Name string

func (Name) CamelLowerName

func (n Name) CamelLowerName() string

func (Name) CamelName

func (n Name) CamelName() string

func (Name) PluralCamelLowerName

func (n Name) PluralCamelLowerName() string

func (Name) PluralCamelName

func (n Name) PluralCamelName() string

func (Name) PluralSnakeName

func (n Name) PluralSnakeName() string

func (Name) SnakeName

func (n Name) SnakeName() string

type Relation

type Relation struct {
	Custom   bool `yaml:"custom,omitempty"`
	All      bool `yaml:"all,omitempty"`
	To       Name `yaml:"to"`
	Internal Name `yaml:"internal,omitempty"`
	External Name `yaml:"external,omitempty"`
}

func (*Relation) Validate

func (r *Relation) Validate() error

type Render

type Render struct {
	IsRender    bool              `yaml:"-"`
	IsInline    bool              `yaml:"-"`
	DefaultName string            `yaml:"-"`
	Names       map[string]string `yaml:"-"`
}

func (*Render) MarshalYAML

func (r *Render) MarshalYAML() (interface{}, error)

MarshalYAML output parameter for render property (1) if IsRender property is true, output the following ``` render: false ``` (2) if IsInline property is true, output the following ``` render:

inline: true

``` (3) if DefaultName property is 'example', output the following ``` render: example ``` (4) if Names property has some keys, output the following ``` render:

json: camelName
yaml: snake_name

```

func (*Render) UnmarshalYAML

func (r *Render) UnmarshalYAML(unmarshal func(interface{}) error) error

type RepositoryMethodHelper

type RepositoryMethodHelper struct {
	AppName      string
	Class        *Class
	ReceiverName string
	ImportList   ImportList
}

func (*RepositoryMethodHelper) ContextType

func (h *RepositoryMethodHelper) ContextType() *TypeDeclare

func (*RepositoryMethodHelper) CreateMethodDeclare

func (h *RepositoryMethodHelper) CreateMethodDeclare() *MethodDeclare

func (*RepositoryMethodHelper) DAO

func (*RepositoryMethodHelper) DAOName

func (h *RepositoryMethodHelper) DAOName() string

func (*RepositoryMethodHelper) EntityClassType

func (h *RepositoryMethodHelper) EntityClassType() *TypeDeclare

func (*RepositoryMethodHelper) EntityCollectionClassType

func (h *RepositoryMethodHelper) EntityCollectionClassType() *TypeDeclare

func (*RepositoryMethodHelper) FieldsToFind

func (h *RepositoryMethodHelper) FieldsToFind() code.Dict

func (*RepositoryMethodHelper) ModelClassType

func (h *RepositoryMethodHelper) ModelClassType() *TypeDeclare

func (*RepositoryMethodHelper) ModelCollectionClassType

func (h *RepositoryMethodHelper) ModelCollectionClassType() *TypeDeclare

func (*RepositoryMethodHelper) Package

func (h *RepositoryMethodHelper) Package(name string) string

func (*RepositoryMethodHelper) Receiver

func (h *RepositoryMethodHelper) Receiver() *code.Statement

func (*RepositoryMethodHelper) ReceiverClassName

func (h *RepositoryMethodHelper) ReceiverClassName() string

type Request

type Request struct {
	Params RequestParams `yaml:"parameters"`
}

type RequestParam

type RequestParam struct {
	Name     Name        `yaml:"name"`
	Type     string      `yaml:"type"`
	In       InType      `yaml:"in"`
	Desc     string      `yaml:"desc"`
	Example  interface{} `yaml:"example"`
	Render   *Render     `yaml:"render,omitempty"`
	Required bool        `yaml:"required"`
}

func (*RequestParam) RenderName

func (p *RequestParam) RenderName() string

type RequestParams

type RequestParams []*RequestParam

func (RequestParams) HasInBodyParam

func (r RequestParams) HasInBodyParam() bool

func (RequestParams) HasInQueryParam

func (r RequestParams) HasInQueryParam() bool

type Response

type Response struct {
	SubTypes []*APIClass
	Type     *APIClass
}

func (*Response) Attributes

func (r *Response) Attributes() []*Attribute

func (*Response) BuilderCode

func (r *Response) BuilderCode(h *APIResponseHelper) []code.Code

func (*Response) Render

func (r *Response) Render() interface{}

func (*Response) RenderJSON

func (r *Response) RenderJSON() string

func (*Response) ResolveClassReference

func (r *Response) ResolveClassReference(classMap *map[string]*Class, subClassMap *map[string]*Class)

func (*Response) UnmarshalYAML

func (r *Response) UnmarshalYAML(unmarshal func(interface{}) error) error

type SQL

type SQL struct {
	Query      string
	Args       []code.Code
	ScanValues []code.Code
}

type StructFieldList

type StructFieldList map[string]*ValueDeclare

type TestData

type TestData struct {
	Single     TestObjectMap            `yaml:"single"`
	Collection map[string][]*TestObject `yaml:"collection"`
}

func (*TestData) MergeDefault

func (d *TestData) MergeDefault(class *Class)

type TestObject

type TestObject struct {
	*TestObject `yaml:",omitempty,inline,alias"`
	MapValue    map[string]interface{} `yaml:",omitempty,inline"`
}

func (*TestObject) MergedMapValue

func (o *TestObject) MergedMapValue() map[string]interface{}

type TestObjectDecl

type TestObjectDecl struct {
	Name        string `yaml:"-"`
	*TestObject `yaml:",inline,anchor"`
}

type TestObjectMap

type TestObjectMap map[string]*TestObject

func (TestObjectMap) MarshalYAML

func (m TestObjectMap) MarshalYAML() (interface{}, error)

type Type

type Type struct {
	PackageName  string
	Name         string
	ImportPath   string
	As           string
	IsPrimitive  bool
	DefaultValue interface{}
}

func (*Type) IsBool

func (d *Type) IsBool() bool

func (*Type) IsByte

func (d *Type) IsByte() bool

func (*Type) IsComplex

func (d *Type) IsComplex() bool

func (*Type) IsFloat

func (d *Type) IsFloat() bool

func (*Type) IsInt

func (d *Type) IsInt() bool

func (*Type) IsRune

func (d *Type) IsRune() bool

func (*Type) IsString

func (d *Type) IsString() bool

func (*Type) IsTime

func (d *Type) IsTime() bool

func (*Type) IsUint

func (d *Type) IsUint() bool

type TypeDeclare

type TypeDeclare struct {
	Type      *Type
	IsPointer bool
	IsSlice   bool
	// contains filtered or unexported fields
}

func TypeDeclareWithName

func TypeDeclareWithName(name string) *TypeDeclare

func TypeDeclareWithType

func TypeDeclareWithType(typ *Type) *TypeDeclare

func (*TypeDeclare) Class

func (d *TypeDeclare) Class() *Class

func (*TypeDeclare) Code

func (d *TypeDeclare) Code(importList ImportList) code.Code

func (*TypeDeclare) CodePackage

func (d *TypeDeclare) CodePackage(pkg string, importList ImportList) code.Code

func (*TypeDeclare) CodeWithoutPackage

func (d *TypeDeclare) CodeWithoutPackage(importList ImportList) code.Code

func (*TypeDeclare) CollectionName

func (d *TypeDeclare) CollectionName(importList ImportList) string

func (*TypeDeclare) DefaultValue

func (d *TypeDeclare) DefaultValue() interface{}

func (*TypeDeclare) FormatName

func (d *TypeDeclare) FormatName(importList ImportList) string

func (*TypeDeclare) IsCustomPrimitiveType

func (d *TypeDeclare) IsCustomPrimitiveType() bool

func (*TypeDeclare) IsSchemaClass

func (d *TypeDeclare) IsSchemaClass() bool

func (*TypeDeclare) MarshalYAML

func (d *TypeDeclare) MarshalYAML() (interface{}, error)

func (*TypeDeclare) Name

func (d *TypeDeclare) Name() string

func (*TypeDeclare) UnmarshalYAML

func (d *TypeDeclare) UnmarshalYAML(unmarshal func(interface{}) error) error

func (*TypeDeclare) ValueToCode

func (d *TypeDeclare) ValueToCode(v interface{}) code.Code

type UniqueKey

type UniqueKey struct {
	Columns []string
}

func (*UniqueKey) MarshalYAML

func (k *UniqueKey) MarshalYAML() (interface{}, error)

func (*UniqueKey) UnmarshalYAML

func (k *UniqueKey) UnmarshalYAML(unmarshal func(interface{}) error) error

type UpdateParam

type UpdateParam struct {
	DataAccessParam
	Args *UpdateParamArgs
}

type UpdateParamArgs

type UpdateParamArgs struct {
	Context   func() *code.Statement
	Value     func() *code.Statement
	UpdateMap func() *code.Statement
	Members   []*Member
}

type ValueDeclare

type ValueDeclare struct {
	Name string
	Type *TypeDeclare
}

func (*ValueDeclare) Code

func (d *ValueDeclare) Code(importList ImportList) code.Code

func (*ValueDeclare) Interface

func (d *ValueDeclare) Interface(importList ImportList) code.Code

type ValueDeclares

type ValueDeclares []*ValueDeclare

func (ValueDeclares) Code

func (d ValueDeclares) Code(importList ImportList) []code.Code

func (ValueDeclares) Interface

func (d ValueDeclares) Interface(importList ImportList) []code.Code

Jump to

Keyboard shortcuts

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