dalgen

package
v0.0.0-...-8bc0dfe Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RESULT_TYPE_DEFAULT = ""
	RESULT_TYPE_STRUCT  = "struct"
	RESULT_TYPE_MAP     = "map"
	RESULT_TYPE_INT     = "int"
	RESULT_TYPE_STRING  = "string"
)
View Source
const (
	RESULT_SET_DEFAULT = ""
	RESULT_SET_ONE     = "single"
	RESULT_SET_LIST    = "list"
	RESULT_SET_MAP     = "map"
)
View Source
const (
	PARAM_TYPE_INT32LIST  = "[]int32"
	PARAM_TYPE_UINT32LIST = "[]uint32"
	PARAM_TYPE_INT64LIST  = "[]int64"
	PARAM_TYPE_UINT64LIST = "[]uint64"
	PARAM_TYPE_STRINGLIST = "[]string"
)

Variables

This section is empty.

Functions

func BitIn

func BitIn(index int, bitset uint) uint

BitIn test whether the bit at index is set to 1, if true, return 1 << index, else 0

func BitNotIn

func BitNotIn(index int, bitset uint) uint

BitNotIn test whether the bit at index is set to 0, if true, return 1 << index, else 0

func ByteIn

func ByteIn(b byte, bs ...byte) int

ByteIn return the index that byte in byte list or -1 if not exist

func CharIn

func CharIn(b byte, s string) int

CharIn search index of char in sorted string with ascending order

func GenDAO

func GenDAO(dalgen *DalgenConfig, schema *TableSchema)

func GenDataObject

func GenDataObject(dalgen *DalgenConfig, schema *TableSchema)

func GetBindvarList

func GetBindvarList(stmt sqlparser.Statement) []string

GetBindvars returns a map of the bind vars referenced in the statement. TODO(sougou); This function gets called again from vtgate/planbuilder. Ideally, this should be done only once.

func GetTableSchema

func GetTableSchema(db *sqlx.DB, tableName string) string

func IndexN

func IndexN(str, sep string, n int) (index int)

IndexN find index of n-th sep string

func IndexNonSpace

func IndexNonSpace(s string) int

IndexNonSpace find index of first non-space character, if not exist, -1 was returned

func IsAllCharsIn

func IsAllCharsIn(s, encoding string) bool

IsAllCharsIn check whether all chars of string is in encoding string

func IsLetter

func IsLetter(b byte) bool

IsLetter check character is a letter or not

func IsLower

func IsLower(b byte) bool

IsLower check letter is lower case or not

func IsSpace

func IsSpace(b byte) bool

IsSpace only call unicode.IsSpace

func IsSpaceQuote

func IsSpaceQuote(b byte) bool

IsSpaceQuote return wehter a byte is space or quote characters

func IsUpper

func IsUpper(b byte) bool

IsUpper check letter is upper case or not

func JoinPairs

func JoinPairs(pairs map[string]string, eq, sep string) string

func LastIndexByte

func LastIndexByte(s string, b byte) int

func LastIndexN

func LastIndexN(str, sep string, n int) (index int)

LastIndexN find last index of n-th sep string

func LastIndexNonSpace

func LastIndexNonSpace(s string) int

LastIndexNonSpace find index of last non-space character, if not exist, -1 was returned

func MergeSpace

func MergeSpace(s string, trim bool) string

MergeSpace merge multiple space to one, trim determine whether remove space at prefix and suffix

func MidIndex

func MidIndex(s string, sep byte) int

MidIndex find middle separator index of string, not first and last

func MultipleLineOperate

func MultipleLineOperate(s, delim string, operate func(line, delim string) string) string

func RemoveSpace

func RemoveSpace(s string) string

RemoveSpace remove all space characters from string by unibyte.IsSpace

func RuneIn

func RuneIn(ru rune, rs ...rune) int

RuneIn return the index that rune in rune list or -1 if not exist

func Separate

func Separate(s string, sep byte) (string, string)

Separate string by separator, the separator must in the middle of string, not first and last

func SortedNumberIn

func SortedNumberIn(n int, nums ...int) int

SortedNumberIn search index of number in sorted numbers with ascending order

func SplitAndTrim

func SplitAndTrim(s, sep string) []string

TrimSplit split string and return trim space string

func StringIn

func StringIn(str string, strs []string) int

StringIn return the index of string to find in a string slice or -1 if not found

func ToAbridge

func ToAbridge(str string) string

ToAbridge extract first letter and all upper case letter from string as it's abridge case

func ToCamel

func ToCamel(s string) string

ToCamel string, xx_yy to XxYy, xx__yy to Xx_Yy xx _yy to Xx Yy, the rule is that a lower case letter after '_' will combine to a upper case letter

func ToGoType

func ToGoType(name string) (t string)

func ToLower

func ToLower(b byte) byte

ToLower convert a byte to lower case

func ToLowerAbridge

func ToLowerAbridge(str string) (s string)

ToLowerAbridge extract first letter and all upper case letter from string as it's abridge case, and convert it to lower case

func ToLowerString

func ToLowerString(b byte) string

ToLowerString convert a byte to lower case string

func ToSnake

func ToSnake(s string) string

ToSnake string, XxYy to xx_yy, X_Y to x_y

func ToUpper

func ToUpper(b byte) byte

ToUpper convert a byte to upper case

func ToUpperString

func ToUpperString(b byte) string

ToUpperString convert a byte to upper case string

func TrimAfter

func TrimAfter(s, delimiter string) string

TrimAfter trim string and remove the section after delimiter and delimiter itself

func TrimAndToLower

func TrimAndToLower(str string) string

TrimAndToLower return the trim and lower format of a string

func TrimAndToUpper

func TrimAndToUpper(str string) string

TrimAndToUpper return the trim and upper format of a string

func TrimBefore

func TrimBefore(s, delimiter string) string

func TrimFirstN

func TrimFirstN(s, delim string, n int) string

func TrimLastN

func TrimLastN(s, delim string, n int) string

func TrimQuote

func TrimQuote(str string) (string, bool)

TrimQuote trim quote for string, return error if quote don't match

func TrimWrap

func TrimWrap(str, left, right string, strict bool) (string, bool)

func WriteStringsToBuffer

func WriteStringsToBuffer(buffer *bytes.Buffer, strings []string, sep string)

WriteStringsToBuffer write strings to buffer, it avoid memory allocation of join strings

Types

type Coloum

type Coloum struct {
	ColName      string `xml:"name,attr"`
	ColType      string `xml:"type,attr"`
	ColVarName   string `xml:"varname,attr"`
	DefaultValue string `xml:"defaultValue,attr"`
}

type DalgenConfig

type DalgenConfig struct {
	FilePath string

	// 表名
	TableName string `xml:"sqlname,attr"`
	// 列
	Cols []Coloum `xml:"column"`
	// 操作
	Ops []Operation `xml:"operation"`
}

func NewDalgenConfig

func NewDalgenConfig(configFile, xmlFileName string) (dalgen *DalgenConfig, err error)

type FieldSchema

type FieldSchema struct {
	Field      string         `db:"Field"`
	Type       string         `db:"Type"`
	Collation  sql.NullString `db:"Collation"`
	Null       string         `db:"Null"`
	Key        string         `db:"Key"`
	Default    sql.NullString `db:"Default"`
	Extra      string         `db:"Extra"`
	Privileges string         `db:"Privileges"`
	Comment    string         `db:"Comment"`
}

type Func

type Func struct {
	TableName string
	QueryType string

	FuncName           string
	Params             []Param
	QueryParams        []Param
	Sql                string
	CompiledByNamedSql string
	ParamHasList       string
}

type OpParam

type OpParam struct {
	ParamName string `xml:"name,attr"`
	ParamType string `xml:"type,attr"`
}

type OpParams

type OpParams struct {
	OpParams []OpParam `xml:"param"`
}

type Operation

type Operation struct {
	Name       string   `xml:"name,attr"`
	ResultType string   `xml:"result_type,attr"`
	ResultSet  string   `xml:"result_set,attr"`
	Sql        string   `xml:"sql"`
	Parsms     OpParams `xml:"params"`
}

type Param

type Param struct {
	// TODO(@benqi): 驼峰参数名, 参数名从user_id ==> userId
	Name      string
	Type      string
	FieldName string
}

type TableSchema

type TableSchema struct {
	Name    string `db:"Table"`        //  表名
	Comment string `db:"Create Table"` //  字段信息
	Fields  []FieldSchema
}

func NewTableSchema

func NewTableSchema(db *sqlx.DB, dalgen *DalgenConfig) (*TableSchema, error)

func (*TableSchema) GetFieldSchema

func (t *TableSchema) GetFieldSchema(fldName string) (fld *FieldSchema)

type TemplateDAO

type TemplateDAO struct {
	Name    string
	Funcs   []Func
	HasList string
}

type TemplateDO

type TemplateDO struct {
	Name   string
	Fields []TemplateField
}

type TemplateField

type TemplateField struct {
	Name  string
	Type  string
	DbMap string
}

Id int32 `db:"id"`

Jump to

Keyboard shortcuts

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