Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ImportPkgs = []string{}
)
Functions ¶
This section is empty.
Types ¶
type BuilderInfo ¶
type BuilderInfo struct { // PkgPath 是加载的entity包的Go package路径,之后会传给gen.Config。 PkgPath string // 加载的entity package的模块信息。 Module *packages.Module // entity package的路径符合条件的所有Databases。 Databases []*Database }
BuilderInfo 是一个用于生成代码的构建器, 包含了entity package的路径和符合条件的database信息。
type Config ¶
type Config struct { // 加载的entity的路径。 Path string // 加载的entity中拥有匿名字段[entity.Entity]的结构体的名称。 Entities []string BuildFlags []string // 加载的entity中拥有匿名字段[entity.Database]的结构体的名称。 Dbs []DbConfig }
Config 用于从entity package中加载的所有database和entity的配置。
func (*Config) Load ¶
func (c *Config) Load() (*BuilderInfo, error)
加载entity package,并且利用这些信息生成一个Builder。
type Database ¶
type Database struct { Name string Tag string // 数据库类型。 Type dialect.DbDriver EntityMap EntityMap Entities map[string]*Entity }
Database 表示了从已经编译好的用户的entity package中加载的database
type Entity ¶
type Entity struct { // entity的名称 Name string `json:"name,omitempty"` AttrName string `json:"attr_name,omitempty"` // entity配置 Config entity.EntityConfig `json:"config,omitempty"` // entity的字段 Fields []*Field `json:"fields,omitempty"` ImportPkgs []string // entity的关联序列 Sequences []entity.Sequence }
Entity 表示了从已经编译好的用户的package中加载的entity
func MarshalEntity ¶
func MarshalEntity(ei entity.EntityInterface) (ent *Entity, err error)
MarshalEntity 将entity.EntityInterface序列化为Entity,用于生成代码。
type EntityMap ¶
EntityMap entity的key和类型。
和Config.Entities不同的是, EntityMap是用于记录database中的entity的信息, 而Config.Entities是用于记录entity结构体的名字。 例如:
type User struct { entity.Database User UserEntity }
则这个EntityMap中的内容为:{ "User": "UserEntity" }
而Config.Entities中的内容为:["UserEntity"]
type ExeTmplConfig ¶
type Field ¶
type Field struct { entity.Descriptor // ValueType 字段的值类型,比如"entity.Int64"的ValueType为"int64"。 ValueType string `json:"value_type,omitempty"` Validators int `json:"validators,omitempty"` StoragerType string `json:"storager_type,omitempty"` // StoragerOrigType 获得去除泛型后的名字 StoragerOrigType string `json:"storager_orig_type,omitempty"` StoragerPkg string `json:"storager_pkg,omitempty"` }
Field 表示entity的字段所包含的信息。 继承了
Click to show internal directories.
Click to hide internal directories.