package client

import(
	"encoding/xml"
)

type XmlApplication struct {
	XMLName xml.Name `xml:"application"`
	ApplicationName string `xml:"name,attr"`
	PackageName string `xml:"packagename,attr"`
	Desc         string `xml:"desc,attr"`
	Controllers XmlControllers `xml:"controllers"`
	Tables      XmlTables      `xml:"tables"`
	Beans 		XmlBeans       `xml:"beans"`
}

type XmlControllers struct {
	ControllerList []XmlController `xml:"controller"`
}

type XmlController struct {
	Name            string   `xml:"name,attr"`
	Desc            string   `xml:"desc,attr"`
	Dir             string   `xml:"dir,attr"`
	SkipLogin       bool     `xml:"skip_login,attr"`
	Apis            []XmlApi `xml:"api"`
	ApplicationName string   `xml:"-"`
	PackageName     string   `xml:"-"`
}

type XmlApi struct {
	Name string `xml:"name,attr"`
	Desc string `xml:"desc,attr"`
	Method string `xml:"method,attr"`
	Function string `xml:"function,attr"`//page,tree
	Table string `xml:"table,attr"`
	ParamList []XmlApiParam `xml:"param"`
	Return XmlReturn `xml:"return"`
}

type XmlApiParam struct {
	Name string `xml:"name,attr"`
	TransType string `xml:"trans-type,attr"`
	Type string `xml:"type,attr"`
	Desc string `xml:"desc,attr"`
	Ref string `xml:"ref,attr"`
	Must bool `xml:"must,attr"`
	DefaultValue string `xml:"default-value,attr"`
}

type XmlReturn struct {
	Success XmlSuccess `xml:"success"`
	Failure XmlFailure `xml:"failure"`
}

type XmlSuccess struct {
	Ref string `xml:"ref,attr"`
	Desc string `xml:"desc,attr"`
}

type XmlFailure struct {
	Ref string `xml:"ref,attr"`
	Desc string `xml:"desc,attr"`
}

//
type XmlTables struct {
	TableList []XmlTable `xml:"table"`
}

type XmlTable struct {
	XMLName xml.Name `xml:"table"`
	Name           string `xml:"name,attr"`
	Desc           string `xml:"desc,attr"`
	ImportDateTime bool `xml:"-"`
	ColumnList        []XmlColumn `xml:"column"`
}

type XmlColumn struct {
	Name         string `xml:"name,attr"`
	Caption      string `xml:"caption,attr"`
	IsNull       bool   `xml:"isNull,attr"`
	IsPK         bool   `xml:"isPK,attr"`
	IsIndex 	 bool 	`xml:"isIndex,attr"`
	AutoIncrement     bool   `xml:"autoIncrement,attr"`
	IsUnique     bool   `xml:"isUnique,attr"`
	Size         int    `xml:"size,attr"`
	Type         string `xml:"type,attr"`
	DbType       string `xml:"dbtype,attr"`
	DefaultValue string `xml:"default-value,attr"`
}

type XmlBeans struct {
	BeanList []XmlBean `xml:"bean"`
}

type XmlBean struct {
	XMLName xml.Name `xml:"bean"`
	Name           string `xml:"name,attr"`
	Desc           string `xml:"desc,attr"`
	Inher		 string `xml:"inher,attr"`
	ImportDateTime bool `xml:"-"`
	PropList        []XmlProp `xml:"prop"`
}

type XmlProp struct {
	Name         string `xml:"name,attr"`
	Caption      string `xml:"caption,attr"`
	Type         string `xml:"type,attr"`
	DefaultValue string `xml:"default-value,attr"`
}
