domainfile

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DomainFileExt = ".go"
)

Variables

View Source
var (
	Cols = []Column{
		{
			ColumnName:    "user_name",
			DataType:      "varchar",
			IsNullAble:    yesNull,
			ColumnComment: "user name",
		},
		{
			ColumnName: "id",
			ColumnKey:  pri,
			DataType:   "int",
			IsNullAble: noNull,
		},
		{
			ColumnName: "update_time",
			DataType:   "timestamp",
			IsNullAble: noNull,
			Extra:      upCurrentTimestamp,
		},
	}
)
View Source
var ProvideFuncTemplate = `` /* 128-byte string literal not displayed */

Functions

This section is empty.

Types

type AutoTime

type AutoTime struct {
	CurTimeStamp      []string
	OnUpdateTimeStamp []string
}

type Column

type Column struct {
	ColumnName             string `gorm:"column:COLUMN_NAME"`
	ColumnKey              string `gorm:"column:COLUMN_KEY"`
	DataType               string `gorm:"column:DATA_TYPE"`
	IsNullAble             string `gorm:"column:IS_NULLABLE"`
	ColumnDefault          string `gorm:"column:COLUMN_DEFAULT"`
	CharacterMaximumLength string `gorm:"column:CHARACTER_MAXIMUM_LENGTH"`
	ColumnComment          string `gorm:"column:COLUMN_COMMENT"`
	Extra                  string `gorm:"column:EXTRA"`
}

func (*Column) CheckDelField

func (c *Column) CheckDelField() string

func (*Column) FilterComment

func (c *Column) FilterComment() string

filterComment 过滤和转义特殊字符.

func (*Column) GetDefCol

func (c *Column) GetDefCol() string

GetDefCol 默认标签.

func (*Column) GetGoType

func (c *Column) GetGoType(nullable bool) string

func (*Column) IsCurrentTimeStamp

func (c *Column) IsCurrentTimeStamp() bool

func (*Column) IsOnUpdate

func (c *Column) IsOnUpdate() bool

func (*Column) IsPri

func (c *Column) IsPri() bool

func (*Column) IsTime

func (c *Column) IsTime(goType string) bool

type Columns added in v0.0.7

type Columns []Column

func (Columns) IsEntity added in v0.0.7

func (cs Columns) IsEntity() bool

func (Columns) Len added in v0.0.7

func (cs Columns) Len() int

type ColumnsRepo

type ColumnsRepo interface {
	SelectColumns(dbConf *DbConfig) (Columns, error)
}

func NewDBColumnsInter

func NewDBColumnsInter(logger log.Logger) ColumnsRepo

type DBColumnsInter

type DBColumnsInter struct {
	// contains filtered or unexported fields
}

func (*DBColumnsInter) SelectColumns

func (dc *DBColumnsInter) SelectColumns(dbConf *DbConfig) (Columns, error)

SelectColumns Select column details.

type DaoDomainFileOption

type DaoDomainFileOption func(*daoDomainFile)

func WithDaoDomainFileLogger

func WithDaoDomainFileLogger(logger log.Logger) DaoDomainFileOption

func WithDaoDomainFileTpl

func WithDaoDomainFileTpl(tpl templates.Tpl) DaoDomainFileOption

type DbConfig

type DbConfig struct {
	Host string

	Port int

	User string

	Password string

	Database string

	Table string
}

func NewDbConfig

func NewDbConfig() *DbConfig

func (*DbConfig) ParseConfig

func (dc *DbConfig) ParseConfig(v *viper.Viper, logger log.Logger)

type DomainFile

type DomainFile interface {
	// 不需要生成这个文件
	Disabled() bool

	BindInput(*viper.Viper) error

	// 解析字段信息
	ParseCloumns(Columns, *ShareInfo)

	// 使用模板解析领域内容,返回解析后的内容
	Execute() string

	// 保存路径
	GetSavePath() string

	GetName() string

	GetInjectInfo() *InjectInfo
}

func NewDaoDomainFile

func NewDaoDomainFile(options ...DaoDomainFileOption) DomainFile

func NewEntityDomainFile

func NewEntityDomainFile(options ...EntityDomainFileOption) DomainFile

func NewRepoDomainFile

func NewRepoDomainFile(options ...RepoDomainFileOption) DomainFile

type EntityDomainFileOption

type EntityDomainFileOption func(*entityDomainFile)

func WithEntityDomainFileLogger

func WithEntityDomainFileLogger(logger log.Logger) EntityDomainFileOption

func WithEntityDomainFileTpl

func WithEntityDomainFileTpl(tpl templates.Tpl) EntityDomainFileOption

type InjectInfo

type InjectInfo struct {
	Fields pkg.Fields

	Imports pkg.Imports

	InfraSetArgs []string

	ProvideRepoFuns []ProvideRepoFunc
}

func NewInjectInfo

func NewInjectInfo() *InjectInfo

type Provide

type Provide struct {
	Content string
}

type ProvideRepoFunc added in v0.1.2

type ProvideRepoFunc struct {
	FuncName *dst.Ident

	ParamName *dst.Ident

	ParamType *dst.Ident

	Result *dst.Ident

	BodyFunc *dst.Ident

	BodyFuncArg *dst.Ident
}

func NewProvideRepoFunc added in v0.1.2

func NewProvideRepoFunc(entityName, path string) ProvideRepoFunc

type Provides

type Provides []Provide

func (Provides) Len

func (ps Provides) Len() int

func (Provides) String

func (ps Provides) String() string

type RepoDomainFileOption

type RepoDomainFileOption func(*repoDomainFile)

func WithRepoDomainFileLogger

func WithRepoDomainFileLogger(logger log.Logger) RepoDomainFileOption

func WithRepoDomainFileTpl

func WithRepoDomainFileTpl(tpl templates.Tpl) RepoDomainFileOption

type ShareInfo

type ShareInfo struct {
	// Camel Form
	CamelStruct string

	DbConf *DbConfig

	WithEntityTarget string

	WithDaoTarget string

	WithRepoTarget string
}

和其他领域文件共享信息,避免"import cycle not allowed".

func NewShareInfo

func NewShareInfo() *ShareInfo

func (*ShareInfo) ParseInfo

func (shareInfo *ShareInfo) ParseInfo(obj interface{})

type StubsColumnsRepo

type StubsColumnsRepo struct{}

func (StubsColumnsRepo) SelectColumns

func (scr StubsColumnsRepo) SelectColumns(dbConf *DbConfig) (Columns, error)

Jump to

Keyboard shortcuts

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