defines

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseSQL

func ParseSQL(comment, dialect string) (sql, orderBy string)

Types

type Func

type Func struct {
	// repoIntf *RepoInterface
	*Object
	Template Template
}

func NewFunc

func NewFunc(repo *RepoInterface) *Func

func NewFuncWithObject

func NewFuncWithObject(o *Object) *Func

func (*Func) AddDBUtilPackage

func (f *Func) AddDBUtilPackage() string

func (*Func) AddInterfacePackage added in v0.1.6

func (f *Func) AddInterfacePackage() (string, string)

func (*Func) AddSQLPackage

func (f *Func) AddSQLPackage() string

func (*Func) AddXTypePackage

func (f *Func) AddXTypePackage(fullPkgPath string) string

func (*Func) CreateError

func (f *Func) CreateError(format string, v ...interface{}) error

func (*Func) Format

func (f *Func) Format(format string, v ...interface{}) string

func (*Func) Parse

func (f *Func) Parse(method *ast.Field, dialect string) error

type Info

type Info struct {
	Parsed             bool
	Package            string
	PackageName        string
	OldRepositoriesMap map[string]bool // 从已存在的 interface.go 文件中读取的已经提供的 Repository 列表
	Dir                string
	Dialect            string
	FSet               *token.FileSet `json:"-"`
	Files              []*RepoFile
	// contains filtered or unexported fields
}

func NewInfo

func NewInfo(pkg string, dialect constants.DIALECT, logger logo.Logger) *Info

func (*Info) CreateImplementFilePath

func (m *Info) CreateImplementFilePath(fileName string) string

func (*Info) CreateInterfaceFilePath

func (m *Info) CreateInterfaceFilePath(fileName string) string

func (*Info) CreateRepositoryDirIfNotExists

func (m *Info) CreateRepositoryDirIfNotExists() error

oldname: CheckDialectDir

func (*Info) FindRepoFiles

func (m *Info) FindRepoFiles() (err error)

func (*Info) GenerateImplementFilePath

func (m *Info) GenerateImplementFilePath(fileName string) string

oldname: CreateImplementFilePath

func (*Info) GenerateInterfaceFilePath

func (m *Info) GenerateInterfaceFilePath(fileName string) string

oldname: CreateInterfaceFilePath

func (*Info) IsProvidesChanged

func (m *Info) IsProvidesChanged() bool

func (*Info) TraverseFuncs

func (m *Info) TraverseFuncs(fn func(f *Func, intf *RepoInterface, rf *RepoFile) error) error

func (*Info) TraverseRepoFiles

func (m *Info) TraverseRepoFiles(fn func(rf *RepoFile) error) error

func (*Info) TraverseRepos

func (m *Info) TraverseRepos(fn func(intf *RepoInterface, rf *RepoFile) error) error

type Object

type Object struct {
	*objs.Object

	SQL     string
	OrderBy string // 用于 FindXBy 模式的查询排序
	// contains filtered or unexported fields
}

func NewEmptyObject

func NewEmptyObject(repo *RepoInterface) *Object

func NewObject

func NewObject(repo *RepoInterface, obj *objs.Object) *Object

func (*Object) GetBeanType

func (o *Object) GetBeanType() (*xtype.XType, error)

func (*Object) GetRepoInterface

func (o *Object) GetRepoInterface() *RepoInterface

func (*Object) MakeObject

func (o *Object) MakeObject(obj *objs.Object) *Object

func (*Object) Parse

func (o *Object) Parse(field *ast.Field, expr ast.Expr, dialect string, reposMethod bool, level int) error

type RepoFile

type RepoFile struct {
	File *ast.File `json:"-"`
	// Parsed  bool
	Name              string
	Path              string
	Package           string
	Imports           map[string]string // key: 简写包名称  value: 包全称
	ImportsReverseMap map[string]string // key: 包全称      value: 简写包名称
	Repos             []*RepoInterface

	InterfacePackage string // 接口定义包
	SQLPackage       string // database/sql
	LogoPackage      string // gitee.com/knowgo/logo
	RunTimePackage   string // gitee.com/knowgo/gpa/rt
	DBUtilPackage    string // gitee.com/knowgo/gpa/rt/dbutil
	// contains filtered or unexported fields
}

func NewRepoFile

func NewRepoFile(info *Info, file *ast.File) *RepoFile

func (*RepoFile) AddDBUtilPackage

func (rf *RepoFile) AddDBUtilPackage() string

func (*RepoFile) AddInterfacePackage added in v0.1.6

func (rf *RepoFile) AddInterfacePackage() (string, string)

func (*RepoFile) AddLogoPackage added in v0.2.0

func (rf *RepoFile) AddLogoPackage() string

func (*RepoFile) AddRepo

func (rf *RepoFile) AddRepo(repo *RepoInterface)

func (*RepoFile) AddRuntimePackage

func (rf *RepoFile) AddRuntimePackage() string

func (*RepoFile) AddSQLPackage

func (rf *RepoFile) AddSQLPackage() string

func (*RepoFile) AddXTypePackage

func (rf *RepoFile) AddXTypePackage(pkgPath string) string

func (*RepoFile) FindImport

func (rf *RepoFile) FindImport(pkg string) string

func (*RepoFile) FindPackagePath

func (rf *RepoFile) FindPackagePath(pkg string) (string, error)

func (*RepoFile) Parse

func (rf *RepoFile) Parse(dialect string) error

type RepoInterface

type RepoInterface struct {
	Name           string
	Funcs          []*Func
	RunTimePackage string
	LogoPackage    string
	// contains filtered or unexported fields
}

func NewRepoInterface

func NewRepoInterface(name string, logger logo.Logger) *RepoInterface

func (*RepoInterface) AddFunction

func (rf *RepoInterface) AddFunction(fn *Func)

func (*RepoInterface) Parse

func (rf *RepoInterface) Parse(body *ast.InterfaceType, dialect string) error

type Template

type Template string
const (
	INSERT   Template = "insert"
	UPDATE   Template = "update"
	DELETE   Template = "delete"
	FIND     Template = "find"
	COUNT    Template = "count"
	TRUNCATE Template = "truncate"
)

Jump to

Keyboard shortcuts

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