Documentation ¶
Index ¶
- Constants
- Variables
- func FileContentChange(org, new []byte, seg string) bool
- func GetFilterContent(content string, seg string) string
- func GetSeg(ext string) string
- type Container
- type Descriptor
- type ModelInfo
- type ModelInfos
- type ModelSchema
- type ModelSchemas
- type MysqlParser
- type Parser
- type RenderFile
- type RenderInfo
- type TableSchema
- type TableSchemas
- type TextModel
- type TextParser
- type Timestamp
- type TmplOption
- type UserOption
Constants ¶
View Source
const MDateFormat = "20060102_150405"
Variables ¶
View Source
var ( SQLModeUp = "up" SQLModeDown = "down" )
View Source
var CompareExcept = []string{"@radicalGenerateTime"}
View Source
var DefaultradiantPro = &Container{ radiantProFile: system.CurrentDir + "/radiantpro.toml", TimestampFile: system.CurrentDir + "/.radiantpro.timestamp", GoModFile: system.CurrentDir + "/go.mod", UserOption: UserOption{ Debug: false, ContextDebug: false, Dsn: "", Driver: "mysql", ProType: "default", ApiPrefix: "/api", EnableModule: nil, Models: make(map[string]TextModel), GitRemotePath: "https://github.com/radiant/radiant-pro.git", Branch: "master", GitLocalPath: system.RadiantHome + "/radiant-pro", EnableFormat: true, SourceGen: "text", EnableGitPull: true, Path: map[string]string{ "radiant": ".", }, EnableGomod: true, RefreshGitTime: 24 * 3600, Extend: nil, }, GenerateTime: time.Now().Format(MDateFormat), GenerateTimeUnix: time.Now().Unix(), TmplOption: TmplOption{}, CurPath: system.CurrentDir, EnableModules: make(map[string]interface{}), FunctionOnce: make(map[string]sync.Once), }
View Source
var ParserDriver = map[string]Parser{ "text": &TextParser{}, "mysql": &MysqlParser{}, }
View Source
var SQL utils.DocValue
View Source
var SQLMode utils.DocValue
View Source
var SQLModePath utils.DocValue
Functions ¶
func FileContentChange ¶
func GetFilterContent ¶
Types ¶
type Container ¶
type Container struct { TimestampFile string // store ts file GoModFile string // go mod file UserOption UserOption // user option TmplOption TmplOption // tmpl option CurPath string // user current path EnableModules map[string]interface{} // radiant pro provider a collection of module FunctionOnce map[string]sync.Once // exec function once Timestamp Timestamp GenerateTime string GenerateTimeUnix int64 Parser Parser // contains filtered or unexported fields }
store all data
type Descriptor ¶
type Descriptor struct { Module string `toml:"module"` SrcName string `toml:"srcName"` DstPath string `toml:"dstPath"` Once bool `toml:"once"` Script string `toml:"script"` }
func (Descriptor) ExecScript ¶
func (d Descriptor) ExecScript(path string) (err error)
func (Descriptor) IsExistScript ¶
func (descriptor Descriptor) IsExistScript() bool
func (Descriptor) Parse ¶
func (descriptor Descriptor) Parse(modelName string, paths map[string]string) (newDescriptor Descriptor, ctx pongo2.Context)
type ModelInfo ¶
type ModelInfo struct { Name string `json:"name"` // mysql name InputType string `json:"inputType"` // user input type MysqlType string `json:"mysqlType"` // mysql type GoType string `json:"goType"` // go type Orm string `json:"orm"` // orm tag Comment string `json:"comment"` // mysql comment Extend string `json:"extend"` // user extend info }
parse get the model info
func (ModelInfo) GetColumnKey ¶
func (ModelInfo) IsPrimaryKey ¶
type ModelInfos ¶
type ModelInfos []ModelInfo
func (ModelInfos) ToModelSchemas ¶
func (modelInfos ModelInfos) ToModelSchemas() (output ModelSchemas)
to render model schemas
type ModelSchema ¶
type ModelSchemas ¶
type ModelSchemas []*ModelSchema
func (ModelSchemas) GetPrimaryKey ¶
func (m ModelSchemas) GetPrimaryKey() string
func (ModelSchemas) IsExistTime ¶
func (m ModelSchemas) IsExistTime() bool
type MysqlParser ¶
type MysqlParser struct {
// contains filtered or unexported fields
}
func (*MysqlParser) GetRenderInfos ¶
func (m *MysqlParser) GetRenderInfos(descriptor Descriptor) (output []RenderInfo)
func (*MysqlParser) Parse ¶
func (*MysqlParser) Parse(descriptor Descriptor)
func (*MysqlParser) RegisterOption ¶
func (m *MysqlParser) RegisterOption(userOption UserOption, tmplOption TmplOption)
func (*MysqlParser) Unregister ¶
func (t *MysqlParser) Unregister()
type Parser ¶
type Parser interface { RegisterOption(userOption UserOption, tmplOption TmplOption) Parse(descriptor Descriptor) GetRenderInfos(descriptor Descriptor) (output []RenderInfo) Unregister() }
type RenderFile ¶
type RenderFile struct { *pongo2render.Render Context pongo2.Context GenerateTime string Option UserOption ModelName string PackageName string FlushFile string PkgPath string TmplPath string Descriptor Descriptor }
render
func NewRender ¶
func NewRender(m RenderInfo) *RenderFile
func (*RenderFile) Exec ¶
func (r *RenderFile) Exec(name string)
func (*RenderFile) SetContext ¶
func (r *RenderFile) SetContext(key string, value interface{})
type RenderInfo ¶
type RenderInfo struct { Module string ModelName string Option UserOption Content ModelInfos Descriptor Descriptor TmplPath string GenerateTime string }
type TableSchema ¶
type TableSchemas ¶
type TableSchemas []TableSchema
func (TableSchemas) ToTableMap ¶
func (tableSchemas TableSchemas) ToTableMap() (resp map[string]ModelInfos)
type TextModel ¶
func (TextModel) ToModelInfos ¶
type TextParser ¶
type TextParser struct {
// contains filtered or unexported fields
}
func (*TextParser) GetRenderInfos ¶
func (t *TextParser) GetRenderInfos(descriptor Descriptor) (output []RenderInfo)
func (*TextParser) Parse ¶
func (*TextParser) Parse(descriptor Descriptor)
func (*TextParser) RegisterOption ¶
func (t *TextParser) RegisterOption(userOption UserOption, tmplOption TmplOption)
func (*TextParser) Unregister ¶
func (t *TextParser) Unregister()
type TmplOption ¶
type TmplOption struct { RenderPath string `toml:"renderPath"` Descriptor []Descriptor }
tmpl option
type UserOption ¶
type UserOption struct { Debug bool `json:"debug"` ContextDebug bool `json:"contextDebug"` Dsn string `json:"dsn"` Driver string `json:"driver"` ProType string `json:"proType"` ApiPrefix string `json:"apiPrefix"` EnableModule []string `json:"enableModule"` Models map[string]TextModel `json:"models"` GitRemotePath string `json:"gitRemotePath"` Branch string `json:"branch"` GitLocalPath string `json:"gitLocalPath"` EnableFormat bool `json:"enableFormat"` SourceGen string `json:"sourceGen"` EnableGitPull bool `json:"enbaleGitPull"` Path map[string]string `json:"path"` EnableGomod bool `json:"enableGomod"` RefreshGitTime int64 `json:"refreshGitTime"` Extend map[string]string `json:"extend"` // extend user data }
user option
Click to show internal directories.
Click to hide internal directories.