Documentation ¶
Index ¶
- Constants
- func CreateXml(tableName string, bean interface{}) []byte
- func IsMethodElement(tag ElementType) bool
- func LoadMapperXml(bytes []byte) (items map[string]etree.Token)
- func OutPutXml(fileName string, body []byte)
- func SnakeString(s string) string
- func StructToSnakeString(arg interface{}) string
- type ElementType
Constants ¶
View Source
const Element_Mapper = "mapper"
View Source
const ID = `id`
Variables ¶
This section is empty.
Functions ¶
func CreateXml ¶
* //例子
//GoMybatis当前是以xml内容为主gm:""注解只是生成xml的时候使用 //定义数据库模型, gm:"id"表示输出id的xml,gm:"version"表示为输出版本号的xml,gm:"logic"表示输出逻辑删除xml
type TestActivity struct { Id string `json:"id" gm:"id"` Uuid string `json:"uuid"` Name string `json:"name"` PcLink string `json:"pcLink"` H5Link string `json:"h5Link"` Remark string `json:"remark"` Version int `json:"version" gm:"version"` CreatedAt time.Time `json:"createTime"` DeleteFlag int `json:"deleteFlag" gm:"logic"` }
func TestUserAddres(t *testing.T) { var s=utils.CreateDefaultXml("biz_user_address",TestActivity{})//创建xml内容 utils.OutPutXml("D:/GOPATH/src/dao/ActivityMapper.xml",[]byte(s))//写入磁盘 }
根据结构体 创建xml文件
func IsMethodElement ¶
func IsMethodElement(tag ElementType) bool
func SnakeString ¶
转蛇形命名snake string, XxYy to xx_yy , XxYY to xx_yy
func StructToSnakeString ¶
func StructToSnakeString(arg interface{}) string
结构体名称转蛇形名称 例如 pcLink = pc_link
Types ¶
type ElementType ¶
type ElementType = string
const ( //root elements Element_ResultMap ElementType = "resultMap" Element_Insert ElementType = "insert" Element_Delete ElementType = "delete" Element_Update ElementType = `update` Element_Select ElementType = "select" Element_Sql ElementType = "sql" //root templete elements Element_Insert_Templete ElementType = "insertTemplete" Element_Delete_Templete ElementType = "deleteTemplete" Element_Update_Templete ElementType = `updateTemplete` Element_Select_Templete ElementType = "selectTemplete" //child elements Element_bind ElementType = "bind" Element_String ElementType = "string" Element_If ElementType = `if` Element_Trim ElementType = "trim" Element_Foreach ElementType = "foreach" Element_Set ElementType = "set" Element_choose ElementType = "choose" Element_when ElementType = "when" Element_otherwise ElementType = "otherwise" Element_where ElementType = "where" Element_Include ElementType = "include" )
Click to show internal directories.
Click to hide internal directories.