Documentation
¶
Overview ¶
Package sdblueprint Blueprint 代码生成框架
Index ¶
- Constants
- func MustMapper[PROTO any](asPrimitive bool) func(sdjson.Object) (PROTO, error)
- func NewMapper[PROTO any](asPrimitive bool) (func(sdjson.Object) (PROTO, error), error)
- type AttributeValue
- func (v AttributeValue) AsBool(def bool) bool
- func (v AttributeValue) AsFloat64(def float64) float64
- func (v AttributeValue) AsInt(def int) int
- func (v AttributeValue) AsInt64(def int64) int64
- func (v AttributeValue) AsSlice(sep string) []string
- func (v AttributeValue) AsStr() string
- func (v AttributeValue) AsUint(def uint) uint
- func (v AttributeValue) AsUint64(def uint64) uint64
- func (v AttributeValue) IfPresented(f func(v string))
- type Attributes
- type Blueprint
- func (bp *Blueprint) Add(protos ...any) *Blueprint
- func (bp *Blueprint) CreateTableForMysql(tx *gorm.DB, opts *CreateTableOptions) error
- func (bp *Blueprint) Dump(w io.Writer)
- func (bp *Blueprint) FillDummyData(tx *gorm.DB, opts *FillDummyDataOptions) error
- func (bp *Blueprint) Finalize() error
- func (bp *Blueprint) Generate(generators ...Generator) (*sdcodegen.Buffers, error)
- func (bp *Blueprint) GenerateTo(buffs *sdcodegen.Buffers, generators ...Generator) error
- func (bp *Blueprint) IsFinalized() bool
- func (bp *Blueprint) MockDB(addr sdgorm.Address) error
- func (bp *Blueprint) Module(id string) Module
- func (bp *Blueprint) ModuleIds() []string
- func (bp *Blueprint) Modules() []Module
- func (bp *Blueprint) MustFinalize() *Blueprint
- func (bp *Blueprint) Queries() []Query
- func (bp *Blueprint) Query(id string) Query
- func (bp *Blueprint) QueryIds() []string
- func (bp *Blueprint) RunCli()
- func (bp *Blueprint) Sub(groups ...string) *Blueprint
- func (bp *Blueprint) Table(id string) Table
- func (bp *Blueprint) TableIds() []string
- func (bp *Blueprint) Tables() []Table
- func (bp *Blueprint) ToJsonObject() sdjson.Object
- type BunModel
- type Column
- type CreateTableOptions
- type DummyRecord
- type Field
- type FillDummyDataOptions
- type ForModule
- type Generator
- type GormModel
- type Index
- type IndexKind
- type IndexOrder
- type Jsonable
- type MarkAsForeignKey
- type MarkAsGenerateBunModel
- type MarkAsGenerateGormModel
- type MarkAsGenerateMysqlDDL
- type MarkAsGenerateSkeleton
- type MarkAsInlineQuery
- type MarkAsModule
- type MarkAsPrimaryKey
- type MarkAsQuery
- type MarkAsSimpleIndex
- type MarkAsTable
- type MarkAsUniqueIndex
- type Method
- type MethodCode
- type Module
- type ModuleTaskGenerateBunModel
- type ModuleTaskGenerateGormModel
- type ModuleTaskGenerateMysqlDDL
- type ModuleTaskGenerateSkeleton
- type MysqlDDL
- type NameForTable
- type Query
- type QueryKind
- type QueryParam
- type QueryResult
- type Table
Constants ¶
View Source
const ( QueryForCreate = QueryKind("CREATE") QueryForUpdate = QueryKind("UPDATE") QueryForExec = QueryKind("EXEC") QueryForRecord = QueryKind("RECORD") QueryForRecords = QueryKind("RECORDS") QueryForScalar = QueryKind("SCALAR") )
View Source
const ( IndexSimple = IndexKind("Simple") IndexPK = IndexKind("PK") IndexFK = IndexKind("FK") IndexUnique = IndexKind("UNIQUE") )
View Source
const ( IndexASC = IndexOrder("ASC") IndexDESC = IndexOrder("DESC") )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AttributeValue ¶
type AttributeValue string
func (AttributeValue) AsBool ¶
func (v AttributeValue) AsBool(def bool) bool
func (AttributeValue) AsFloat64 ¶
func (v AttributeValue) AsFloat64(def float64) float64
func (AttributeValue) AsInt ¶
func (v AttributeValue) AsInt(def int) int
func (AttributeValue) AsInt64 ¶
func (v AttributeValue) AsInt64(def int64) int64
func (AttributeValue) AsSlice ¶
func (v AttributeValue) AsSlice(sep string) []string
func (AttributeValue) AsStr ¶
func (v AttributeValue) AsStr() string
func (AttributeValue) AsUint ¶
func (v AttributeValue) AsUint(def uint) uint
func (AttributeValue) AsUint64 ¶
func (v AttributeValue) AsUint64(def uint64) uint64
func (AttributeValue) IfPresented ¶
func (v AttributeValue) IfPresented(f func(v string))
type Attributes ¶
type Attributes interface { Has(k string) bool Lookup(k string) (AttributeValue, bool) Get(k string) AttributeValue First(keys []string) AttributeValue }
type Blueprint ¶
type Blueprint struct {
// contains filtered or unexported fields
}
func (*Blueprint) CreateTableForMysql ¶
func (bp *Blueprint) CreateTableForMysql(tx *gorm.DB, opts *CreateTableOptions) error
func (*Blueprint) FillDummyData ¶
func (bp *Blueprint) FillDummyData(tx *gorm.DB, opts *FillDummyDataOptions) error
func (*Blueprint) GenerateTo ¶
func (*Blueprint) IsFinalized ¶
func (*Blueprint) MustFinalize ¶
func (*Blueprint) ToJsonObject ¶
type BunModel ¶ added in v0.2.3
type CreateTableOptions ¶
type DummyRecord ¶
func (DummyRecord) Get ¶
func (record DummyRecord) Get(colId string) any
func (DummyRecord) Has ¶
func (record DummyRecord) Has(colId string) bool
func (DummyRecord) ToDB ¶
func (record DummyRecord) ToDB(t Table) DummyRecord
type FillDummyDataOptions ¶
type FillDummyDataOptions struct {
TableIds []string
}
type GormModel ¶
type GormModel struct { // tables TableIds []string FileForModel string // queries WithQuery bool QueryIds []string FileForQuery string QueryWithContext bool // callback OnHeader func(w sdcodegen.Writer, g *GormModel, bp *Blueprint) OnModel func(w sdcodegen.Writer, g *GormModel, bp *Blueprint, t Table) OnQuery func(w sdcodegen.Writer, g *GormModel, bp *Blueprint, q Query) // options Package string }
type IndexOrder ¶
type IndexOrder string
type MarkAsForeignKey ¶
type MarkAsForeignKey int
type MarkAsGenerateBunModel ¶ added in v0.2.3
type MarkAsGenerateBunModel int
type MarkAsGenerateGormModel ¶
type MarkAsGenerateGormModel int
type MarkAsGenerateMysqlDDL ¶
type MarkAsGenerateMysqlDDL int
type MarkAsGenerateSkeleton ¶
type MarkAsGenerateSkeleton int
type MarkAsInlineQuery ¶
type MarkAsInlineQuery int
type MarkAsModule ¶
type MarkAsModule int
type MarkAsPrimaryKey ¶
type MarkAsPrimaryKey int
type MarkAsQuery ¶
type MarkAsQuery int
type MarkAsSimpleIndex ¶
type MarkAsSimpleIndex int
type MarkAsTable ¶
type MarkAsTable int
type MarkAsUniqueIndex ¶
type MarkAsUniqueIndex int
type Method ¶
type Method interface { Id() string Code() MethodCode }
type MethodCode ¶
type MethodCode string
type ModuleTaskGenerateBunModel ¶ added in v0.2.3
type ModuleTaskGenerateBunModel struct { Dirname string `json:"dir,omitempty"` Groups []string `json:"groups,omitempty"` }
func (*ModuleTaskGenerateBunModel) ToJsonObject ¶ added in v0.2.3
func (t *ModuleTaskGenerateBunModel) ToJsonObject() sdjson.Object
type ModuleTaskGenerateGormModel ¶
type ModuleTaskGenerateGormModel struct { Dirname string `json:"dir,omitempty"` Groups []string `json:"groups,omitempty"` QueryWithContext bool `json:"query_with_context,omitempty"` }
func (*ModuleTaskGenerateGormModel) ToJsonObject ¶
func (t *ModuleTaskGenerateGormModel) ToJsonObject() sdjson.Object
type ModuleTaskGenerateMysqlDDL ¶
type ModuleTaskGenerateMysqlDDL struct { Dirname string `json:"dir,omitempty"` Groups []string `json:"groups,omitempty"` }
func (*ModuleTaskGenerateMysqlDDL) ToJsonObject ¶
func (t *ModuleTaskGenerateMysqlDDL) ToJsonObject() sdjson.Object
type ModuleTaskGenerateSkeleton ¶
type ModuleTaskGenerateSkeleton struct { Template string `json:"template"` Dirname string `json:"dir"` }
func (*ModuleTaskGenerateSkeleton) ToJsonObject ¶
func (t *ModuleTaskGenerateSkeleton) ToJsonObject() sdjson.Object
type MysqlDDL ¶
type MysqlDDL struct { TableIds []string FileForCreate string FileForDrop string // callbacks OnHeader func(w sdcodegen.Writer, g *MysqlDDL, bp *Blueprint) OnCreate func(w sdcodegen.Writer, g *MysqlDDL, bp *Blueprint, t Table) OnDrop func(w sdcodegen.Writer, g *MysqlDDL, bp *Blueprint, t Table) // options Charset string Collation string Engine string DisableFK bool WithDrop bool WithoutCreate bool }
type NameForTable ¶
type Query ¶
type Query interface { Id() string Comment() string Group() string Jsonable Attributes Kind() QueryKind SQL() string Table() string Params() []QueryParam ParamByName(name string) QueryParam ParamByIndex(index int) QueryParam Result() QueryResult ReturnRowAffected() bool }
type QueryParam ¶
type QueryResult ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.