Documentation
¶
Index ¶
- Constants
- type Column
- type Filter
- type FilterCommand
- type FilterManager
- type FilterMapper
- type Manager
- func (o *Manager) Attach(container *console.Container, command *console.Command, filter string) (err error)
- func (o *Manager) ListColum(ctx context.Context, table *Table) (list []*Column, err error)
- func (o *Manager) ListTable(ctx context.Context) (list []*Table, err error)
- func (o *Manager) ReadBaseDir(command *console.Command) (err error)
- func (o *Manager) ReadDsn(command *console.Command) (err error)
- func (o *Manager) ReadExport(command *console.Command) (err error)
- func (o *Manager) ReadModelPath(command *console.Command) (err error)
- func (o *Manager) ReadModulePath() (err error)
- func (o *Manager) ReadOverride(command *console.Command) (err error)
- func (o *Manager) ReadPrefix(command *console.Command) (err error)
- func (o *Manager) ReadServicePath(command *console.Command) (err error)
- func (o *Manager) Ready() (err error)
- func (o *Manager) Save(table *Table, data any, text string) (err error)
- type Table
Constants ¶
View Source
const ( CommandDescModel = "Generate model file with given table" CommandNameModel = "gen:model" CommandDescService = "Generate service file with given table" CommandNameService = "gen:service" )
View Source
const ( OptBaseDir = "base-dir" OptBaseDirDefault = "./" OptBaseDirDesc = "Application working directory" OptBaseDirShort = 'b' OptDsn = "dsn" OptDsnDesc = "Database source name for connection, e.g. root:pass@tcp(127.0.0.1:3306)/test" OptDsnDefault = "db" OptExport = "export" OptExportDefault = "*" OptExportDesc = "Specify export names, split with comma" OptExportShort = 'e' OptModelPath = "model-path" OptModelPathDefault = "app/models" OptModelPathDesc = "Generated model files save to" OptModelPathShort = 'm' OptOverride = "override" OptOverrideDesc = "Override existing files" OptPrefix = "prefix" OptPrefixDesc = "Prefix name for table" OptPrefixShort = 'p' OptServicePath = "service-path" OptServicePathDesc = "Generated service files saved to" OptServicePathShort = 's' OptServicePathDefault = "app/services" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
type Column struct {
IsAutoIncrement bool `label:"是否递增" xorm:"-"`
IsDatetime bool `label:"是否时间" xorm:"-"`
IsNotNull bool `label:"是否非空" xorm:"-"`
IsPrimaryKey bool `label:"是否主键" xorm:"-"`
IsTimestampCurrent bool `label:"值是否为系统时间" xorm:"-"`
IsTimestampOnupdate bool `label:"数据更新是否为系统时间" xorm:"-"`
IsUnsigned bool `label:"是否无符号" xorm:"-"`
ExportAlign int `label:"对齐长度" xorm:"-"`
Field string `label:"字段名" xorm:"Field"`
Comment string `label:"字段注释" xorm:"Comment" json:"-"`
Type string `label:"原始类型" xorm:"Type" json:"-"`
Default string `label:"默认值" xorm:"Default" json:"-"`
Key string `label:"索引类型" xorm:"Key" json:"-"`
Null string `label:"空值类型" xorm:"Null" json:"-"`
Extra string `label:"扩展描述" xorm:"Extra" json:"-"`
ExportName string `label:"导出字段名" desc:"如: Id, State 等" xorm:"-"`
ExportType string `label:"导出字段类型名" desc:"如: dict.Id, int, int32, int64" xorm:"-"`
ExportPkg string `label:"导出字段类型包名" desc:"如: server/app/dict" xorm:"-"`
JsonName string `label:"导出JSON字段名" xorm:"-"`
OriginSeek string `label:"搜索类型" xorm:"-"`
OriginType string `label:"原始类型" desc:"如: tinyint, int, bigint" xorm:"-"`
Title string `label:"标题" xorm:"-"`
Description string `label:"表描述" xorm:"-"`
}
type FilterCommand ¶
type FilterCommand struct {
Packages []string `yaml:"packages"`
Fields FilterMapper `yaml:"fields"`
Types FilterMapper `yaml:"types"`
}
type FilterManager ¶
type FilterManager struct {
Commands map[string]*FilterCommand `yaml:"commands"`
}
func NewFilterManager ¶
func NewFilterManager() (*FilterManager, error)
func (*FilterManager) Get ¶
func (o *FilterManager) Get(key string) *FilterCommand
type FilterMapper ¶
func (FilterMapper) Get ¶
func (o FilterMapper) Get(key string) *Filter
type Manager ¶
type Manager struct {
WithModel, WithService bool
Override bool
Command *console.Command `json:"-"`
Container *console.Container `json:"-"`
FilterCommand *FilterCommand `json:"-"`
BaseDir, BaseImport string // e.g "/data/sketch", "sketch"
Dsn, DsnKey string // e.g "root:pass@tcp(host:port)/db?charset=utf8", "db"
Export string // e.g "*" OR "user" OR "user,auth"
ModelPath, ModelPkg string // e.g "app/models", "models"
ModulePath, ModulePkg string // e.g "/data/sketch", "sketch"
Prefix string // e.g "cdb_"
ServicePath, ServicePkg string // e.g "app/services", "services"
// contains filtered or unexported fields
}
func (*Manager) Attach ¶
func (o *Manager) Attach(container *console.Container, command *console.Command, filter string) (err error)
Attach 绑定工具.
func (*Manager) ReadModelPath ¶
func (*Manager) ReadModulePath ¶
func (*Manager) ReadServicePath ¶
type Table ¶
type Table struct {
Name string `xorm:"Name"`
Comment string `xorm:"Comment"`
FileName string `label:"文件名" xorm:"-"`
FilePath string `label:"文件完整名" xorm:"-"`
StructName string `label:"结构体名" desc:"如 User, UserPermission 等" xorm:"-"`
Title string `label:"标题" xorm:"-"`
Description string `label:"表描述" xorm:"-"`
}
Click to show internal directories.
Click to hide internal directories.