xml

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MapperStart = "mapper"
)

Variables

This section is empty.

Functions

func Compare

func Compare(src string, getFunc func(key string) string) bool

test的参数必须是使用{}包裹起来,并且比较符号需要空格分隔,如<if test="{1} != nil"> 或者 <if test="{x.name} != nil">

func ParseDynamic

func ParseDynamic(src string, sqls []Sql) (*parsing.DynamicData, error)

Types

type Choose

type Choose struct {
	When      []When    `xml:"when"`
	Otherwise Otherwise `xml:"otherwise"`
}

func (*Choose) Format

func (de *Choose) Format(getFunc func(key string) string) string

type ChooseProcessor

type ChooseProcessor string

func (ChooseProcessor) EndStr

func (d ChooseProcessor) EndStr() string

func (ChooseProcessor) Parse

type Constructor

type Constructor struct {
	IdArg IdArg  `xml:"idArg"`
	Arg   string `xml:"arg"`
}

type Delete

type Delete struct {
	XMLName       xml.Name
	Id            string `xml:"id,attr"`
	ParameterType string `xml:"parameterType,attr"`
	FlushCache    string `xml:"flushCache,attr"`
	Timeout       string `xml:"timeout,attr"`
	StatementType string `xml:"statementType,attr"`

	//If       []If    `xml:"if"`
	//Include Include `xml:"include"`
	//Where   Where   `xml:"where"`
	//Data    string  `xml:",chardata"`
	Data string `xml:",innerxml"`
}

type Foreach

type Foreach struct {
	Item       string `xml:"item,attr"`
	Collection string `xml:"collection,attr"`
	Separator  string `xml:"separator,attr"`
	Index      string `xml:"index,attr"`
	Open       string `xml:"open,attr"`
	Close      string `xml:"close,attr"`
	Data       string `xml:",chardata"`
}

func (*Foreach) Format

func (de *Foreach) Format(getFunc func(key string) string) string

type ForeachProcessor

type ForeachProcessor string

func (ForeachProcessor) EndStr

func (d ForeachProcessor) EndStr() string

func (ForeachProcessor) Parse

type IdArg

type IdArg struct {
	Column string `xml:"column,attr"`
	GoType string `xml:"type,attr"`
}

type If

type If struct {
	Foreach Foreach `xml:"foreach"`
	Test    string  `xml:"test,attr"`
	Data    string  `xml:",chardata"`
}

func (*If) Format

func (de *If) Format(getFunc func(key string) string) string

传入方法必须是通过参数名获得参数值

type IfProcessor

type IfProcessor string

func (IfProcessor) EndStr

func (d IfProcessor) EndStr() string

func (IfProcessor) Parse

type Include

type Include struct {
	Refid      string     `xml:"refid,attr"`
	Properties []Property `xml:"property"`
	Sql        Sql        `xml:-`
}

func (*Include) Format

func (de *Include) Format(getFunc func(key string) string) string

传入方法必须是通过参数名获得参数值

type IncludeProcessor

type IncludeProcessor string

func (IncludeProcessor) EndStr

func (d IncludeProcessor) EndStr() string

func (IncludeProcessor) Parse

type Insert

type Insert struct {
	XMLName          xml.Name
	Id               string `xml:"id,attr"`
	ParameterType    string `xml:"parameterType,attr"`
	FlushCache       string `xml:"flushCache,attr"`
	Timeout          string `xml:"timeout,attr"`
	StatementType    string `xml:"statementType,attr"`
	UseGeneratedKeys string `xml:"useGeneratedKeys,attr"`
	KeyProperty      string `xml:"keyProperty,attr"`
	KeyColumn        string `xml:"keyColumn,attr"`

	//If       []If    `xml:"if"`
	//Include Include `xml:"include"`
	//Where   Where   `xml:"where"`
	//Data    string  `xml:",chardata"`
	Data string `xml:",innerxml"`
}

type Manager added in v0.2.7

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

func NewManager added in v0.2.7

func NewManager() *Manager

func (*Manager) FindSqlParser added in v0.2.7

func (manager *Manager) FindSqlParser(sqlId string) (sqlparser.SqlParser, bool)

func (*Manager) RegisterData added in v0.2.7

func (manager *Manager) RegisterData(data []byte) error

func (*Manager) RegisterFile added in v0.2.7

func (manager *Manager) RegisterFile(file string) error

func (*Manager) RegisterSql added in v0.2.7

func (manager *Manager) RegisterSql(sqlId string, sql string) error

func (*Manager) UnregisterSql added in v0.2.7

func (manager *Manager) UnregisterSql(sqlId string)

type Mapper

type Mapper struct {
	Namespace  string      `xml:"namespace,attr"`
	ResultMaps []ResultMap `xml:"resultMap"`
	Sql        []Sql       `xml:"sql"`

	Insert []Insert `xml:"insert"`
	Update []Update `xml:"update"`
	Select []Select `xml:"select"`
	Delete []Delete `xml:"delete"`
}

func Parse

func Parse(data []byte) (*Mapper, error)

func ParseFile

func ParseFile(path string) (*Mapper, error)

func (*Mapper) Format

func (mapper *Mapper) Format() map[string]*parsing.DynamicData

type Otherwise

type Otherwise struct {
	Data string `xml:",chardata"`
}

type Property

type Property struct {
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`
}

type Result

type Result struct {
	Property string `xml:"property,attr"`
	Column   string `xml:"column,attr"`
}

type ResultMap

type ResultMap struct {
	XMLName xml.Name
	//id
	Id string `xml:"id,attr"`
	//struct类型名称
	TypeName string `xml:"type,attr"`
	//constructor - 用于在实例化类时,注入结果到构造方法中
	Constructor Constructor `xml:"constructor"`
	//一个 ID 结果;标记出作为 ID 的结果可以帮助提高整体性能
	ResultId Result `xml:"id"`
	//注入到字段或 Struct 属性的普通结果
	Results []Result `xml:"result"`
}

type Select

type Select struct {
	XMLName       xml.Name
	Id            string `xml:"id,attr"`
	ParameterType string `xml:"parameterType,attr"`
	ParameterMap  string `xml:"parameterMap,attr"`
	ResultType    string `xml:"resultType,attr"`
	ResultMap     string `xml:"resultMap,attr"`
	FlushCache    string `xml:"flushCache,attr"`
	UseCache      string `xml:"useCache,attr"`
	Timeout       string `xml:"timeout,attr"`
	FetchSize     string `xml:"fetchSize,attr"`
	StatementType string `xml:"statementType,attr"`
	ResultSetType string `xml:"resultSetType,attr"`

	//If       []If    `xml:"if"`
	//Include Include `xml:"include"`
	//Where   Where   `xml:"where"`
	//Data    string  `xml:",chardata"`
	Data string `xml:",innerxml"`
}

func (*Select) ParseDynamic

func (a *Select) ParseDynamic()

type Set

type Set struct {
	If []If `xml:"if"`
}

func (*Set) Format

func (de *Set) Format(getFunc func(key string) string) string

传入方法必须是通过参数名获得参数值

type SetProcessor

type SetProcessor string

func (SetProcessor) EndStr

func (d SetProcessor) EndStr() string

func (SetProcessor) Parse

type Sql

type Sql struct {
	Id  string `xml:"id,attr"`
	Sql string `xml:",chardata"`
}

func (*Sql) Format

func (de *Sql) Format(getFunc func(key string) string) string

传入方法必须是通过参数名获得参数值

type Update

type Update struct {
	XMLName       xml.Name
	Id            string `xml:"id,attr"`
	ParameterType string `xml:"parameterType,attr"`
	FlushCache    string `xml:"flushCache,attr"`
	Timeout       string `xml:"timeout,attr"`
	StatementType string `xml:"statementType,attr"`

	//If       []If    `xml:"if"`
	//Include Include `xml:"include"`
	//Set     Set     `xml:"set"`
	//Where   Where   `xml:"where"`
	//Data    string  `xml:",chardata"`
	Data string `xml:",innerxml"`
}

type When

type When struct {
	If
}

type Where

type Where struct {
	Choose Choose `xml:"choose"`
	If     []If   `xml:"if"`
}

func (*Where) Format

func (de *Where) Format(getFunc func(key string) string) string

传入方法必须是通过参数名获得参数值

type WhereProcessor

type WhereProcessor string

func (WhereProcessor) EndStr

func (d WhereProcessor) EndStr() string

func (WhereProcessor) Parse

Jump to

Keyboard shortcuts

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