Documentation ¶
Index ¶
- Constants
- func GetStructNames(bases []*BaseStruct) (res []string)
- func ParseStructRelationShip(relationship *schema.Relationships) []field.Relation
- type BaseStruct
- type Clause
- type ElseClause
- type ITableInfo
- type IfClause
- type InterfaceMethod
- func (m *InterfaceMethod) DocComment() string
- func (m *InterfaceMethod) GetParamInTmpl() string
- func (m *InterfaceMethod) GetResultParamInTmpl() string
- func (m *InterfaceMethod) GormRunMethodName() string
- func (m *InterfaceMethod) HasGotPoint() bool
- func (m *InterfaceMethod) HasNeedNewResult() bool
- func (m *InterfaceMethod) HasSqlData() bool
- func (m *InterfaceMethod) IsRepeatFromDifferentInterface(newMethod *InterfaceMethod) bool
- func (m *InterfaceMethod) IsRepeatFromSameInterface(newMethod *InterfaceMethod) bool
- func (m *InterfaceMethod) ReturnError() bool
- func (m *InterfaceMethod) ReturnRowsAffected() bool
- type SQLClause
- type SetClause
- type Slices
- func (s *Slices) CreateIf(name string)
- func (s *Slices) CreateStringSet(name string)
- func (s *Slices) Current() slice
- func (s *Slices) GetName(status model.Status) string
- func (s *Slices) HasMore() bool
- func (s *Slices) IsNull() bool
- func (s *Slices) Len() int
- func (s *Slices) Next() slice
- func (s *Slices) SubIndex()
- type WhereClause
Constants ¶
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 ¶
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 ¶
ElseClause else clause
func (ElseClause) String ¶
func (e ElseClause) String() (res string)
type ITableInfo ¶
type IfClause ¶
type IfClause struct { Cond string Value []Clause Else []Clause // contains filtered or unexported fields }
IfClause if clause
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
type SetClause ¶
type SetClause struct { Value []Clause // contains filtered or unexported fields }
SetClause set clause
type Slices ¶
Slices split sql into chunks
func (*Slices) CreateStringSet ¶
CreateStringSet create string set
type WhereClause ¶
type WhereClause struct { Value []Clause // contains filtered or unexported fields }
WhereClause where clause
func (WhereClause) String ¶
func (w WhereClause) String() string