check

package
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultModelPkg = "model"
)

Variables

This section is empty.

Functions

func GetStructNames

func GetStructNames(bases []*BaseStruct) (res []string)

func ParseStructRelationShip

func ParseStructRelationShip(relationship *schema.Relationships) []field.Relation

ParseStructRelationShip parse struct's relationship No one should use it directly in project

Types

type BaseStruct

type BaseStruct struct {
	GenBaseStruct bool   // whether to generate db model
	S             string // the first letter(lower case)of simple Name
	NewStructName string // new struct name
	StructName    string // origin struct name
	TableName     string
	StructInfo    parser.Param
	Members       []*model.Member
	Source        model.SourceCode
	// contains filtered or unexported fields
}

BaseStruct struct info in generated code

func CheckStructs

func CheckStructs(db *gorm.DB, structs ...interface{}) (bases []*BaseStruct, err error)

CheckStructs check the legitimacy of structures

func GenBaseStructs

func GenBaseStructs(db *gorm.DB, conf model.DBConf) (bases *BaseStruct, err error)

GenBaseStructs generate db model by table name

func (*BaseStruct) HasMember

func (b *BaseStruct) HasMember() bool

HasMember check if BaseStruct has members

func (*BaseStruct) Relations

func (b *BaseStruct) Relations() []field.Relation

func (*BaseStruct) ReviseMemberName

func (b *BaseStruct) ReviseMemberName()

type Clause

type Clause interface {
	String() string
}

Clause a symbol of clause, it can be sql condition clause, if clause, where clause, set clause and else cluase

type ElseClause

type ElseClause struct {
	Cond  string
	Value []Clause
	// contains filtered or unexported fields
}

ElseClause else clause

func (ElseClause) String

func (e ElseClause) String() (res string)

type ITableInfo

type ITableInfo interface {
	GetTbColumns(schemaName string, tableName string) (result []*model.Column, err error)

	GetTbIndex(schemaName string, tableName string) (result []*model.Index, err error)
}

type IfClause

type IfClause struct {
	Cond  string
	Value []Clause
	Else  []Clause
	// contains filtered or unexported fields
}

IfClause if clause

func (IfClause) String

func (i IfClause) String() string

type InterfaceMethod

type InterfaceMethod struct {
	Doc           string         //comment
	S             string         //First letter of
	OriginStruct  parser.Param   // origin struct name
	TargetStruct  string         // generated query struct bane
	MethodName    string         // generated function name
	Params        []parser.Param // function input params
	Result        []parser.Param // function output params
	ResultData    parser.Param   // output data
	SqlTmplList   []string       // generated function content
	SqlData       []string       // variable in sql need function input
	SqlString     string         // SQL
	GormOption    string         // gorm execute method Find or Exec or Take
	Table         string         // specified by user. if empty, generate it with gorm
	InterfaceName string         // origin interface name
	Package       string         // interface package name
}

InterfaceMethod interface's method

func CheckInterface

func CheckInterface(f *parser.InterfaceSet, s *BaseStruct, data []*InterfaceMethod) (checkResults []*InterfaceMethod, err error)

CheckInterface check the legitimacy of interfaces

func (*InterfaceMethod) DocComment

func (m *InterfaceMethod) DocComment() string

DocComment return comment sql add "//" every line

func (*InterfaceMethod) GetParamInTmpl

func (m *InterfaceMethod) GetParamInTmpl() string

GetParamInTmpl return param list

func (*InterfaceMethod) GetResultParamInTmpl

func (m *InterfaceMethod) GetResultParamInTmpl() string

GetResultParamInTmpl return result list

func (*InterfaceMethod) GormRunMethodName

func (m *InterfaceMethod) GormRunMethodName() string

GormRunMethodName return single data use Take() return array use Find

func (*InterfaceMethod) HasGotPoint

func (m *InterfaceMethod) HasGotPoint() bool

HasGotPoint parameter has pointer or not

func (*InterfaceMethod) HasNeedNewResult

func (m *InterfaceMethod) HasNeedNewResult() bool

HasNeedNewResult need pointer or not

func (*InterfaceMethod) HasSqlData

func (m *InterfaceMethod) HasSqlData() bool

HasSqlData has variable or not

func (*InterfaceMethod) IsRepeatFromDifferentInterface

func (m *InterfaceMethod) IsRepeatFromDifferentInterface(newMethod *InterfaceMethod) bool

IsRepeatFromDifferentInterface check different interface has same mame method

func (*InterfaceMethod) IsRepeatFromSameInterface

func (m *InterfaceMethod) IsRepeatFromSameInterface(newMethod *InterfaceMethod) bool

IsRepeatFromSameInterface check different interface has same mame method

func (*InterfaceMethod) ReturnError

func (m *InterfaceMethod) ReturnError() bool

func (*InterfaceMethod) ReturnRowsAffected

func (m *InterfaceMethod) ReturnRowsAffected() bool

type SQLClause

type SQLClause struct {
	Value []string
	// contains filtered or unexported fields
}

SQLClause sql condition clause

func (SQLClause) String

func (s SQLClause) String() string

type SetClause

type SetClause struct {
	Value []Clause
	// contains filtered or unexported fields
}

SetClause set clause

func (SetClause) String

func (w SetClause) String() string

type Slices

type Slices struct {
	Names map[model.Status]int
	// contains filtered or unexported fields
}

Slices split sql into chunks

func NewSlices

func NewSlices() *Slices

NewSlices create and initialize Slices

func (*Slices) CreateIf

func (s *Slices) CreateIf(name string)

CreateIf create if clause code

func (*Slices) CreateStringSet

func (s *Slices) CreateStringSet(name string)

CreateStringSet create string set

func (*Slices) Current

func (s *Slices) Current() slice

Current return current slice

func (*Slices) GetName

func (s *Slices) GetName(status model.Status) string

GetName ...

func (*Slices) HasMore

func (s *Slices) HasMore() bool

HasMore whether has more slice

func (*Slices) IsNull

func (s *Slices) IsNull() bool

IsNull whether slice is empty

func (*Slices) Len

func (s *Slices) Len() int

Len return length of s.slices

func (*Slices) Next

func (s *Slices) Next() slice

Next return next slice and increase index by 1

func (*Slices) SubIndex

func (s *Slices) SubIndex()

SubIndex take index one step back

type WhereClause

type WhereClause struct {
	Value []Clause
	// contains filtered or unexported fields
}

WhereClause where clause

func (WhereClause) String

func (w WhereClause) String() string

Jump to

Keyboard shortcuts

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