no message

master
zcy 2021-09-29 00:37:13 +08:00
parent 4a81fb706f
commit 977b272ec6
2 changed files with 65 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"background/utils" "background/utils"
"container/list" "container/list"
"encoding/xml" "encoding/xml"
"fmt"
"io" "io"
"log" "log"
@ -94,7 +95,7 @@ func RangeWidget(p *Widget ) string{
for ;tmp != nil;tmp = tmp.Parent{ for ;tmp != nil;tmp = tmp.Parent{
parent = tmp.Class + "#" + tmp.Name + " " + parent parent = tmp.Class + "#" + tmp.Name + " " + parent
} }
ret += parent + " \r\n{\r\n}\r\n" ret += parent + ` \r\n{\r\n}\r\n`
if(p.Childs.Len() > 0){ if(p.Childs.Len() > 0){
wid := p.Childs.Front() wid := p.Childs.Front()
@ -111,6 +112,7 @@ type Controller struct{
Type string Type string
Name string Name string
Parent *Controller Parent *Controller
Childs list.List
} }
func GetUifrom(path io.Reader) string{ func GetUifrom(path io.Reader) string{
@ -201,6 +203,64 @@ func (this *OpenApiController) UI2CSS(c *gin.Context) {
} }
func GetXmlController(path io.Reader) string{
list := list.List{}
maps := map[string]int{}
ret := ""
decoder := xml.NewDecoder(path)
for {
token, _ := decoder.Token()
if token == nil {
break
}
switch startElement := token.(type) {
case xml.StartElement:
log.Print(0,startElement.Name)
if(list.Len() == 0){
ins := new(Controller)
ins.Name = getAttr("name",startElement.Attr)
ins.Parent = nil
list.PushBack(ins)
}else{
ins := new(Controller)
ins.Type = startElement.Name.Local
ins.Name = getAttr("name",startElement.Attr)
ins.Parent = list.Back().Value.(*Controller)
list.Back().Value.(*Controller).Childs.PushBack(ins)
list.PushBack(ins)
}
break
case xml.EndElement:
log.Print(1,startElement.Name)
break
}
}
begin := list.Front()
first := true
for begin.Next() != nil{
if begin.Value.(*Controller).Name != ""{
if first{
first = false
}else{
log.Print(begin.Value.(*Controller).Name," ",begin.Value.(*Controller).Type)
if _,ok := maps[begin.Value.(*Controller).Type] ;ok{
maps[begin.Value.(*Controller).Type]++
}else{
maps[begin.Value.(*Controller).Type] = 1
}
// ui::Button* btn_add_new = dynamic_cast<ui::Button*>(FindControl(L"open_button"));
ret += fmt.Sprintf("ui::%s * = dynamic_cast<ui::%s*>(FindControl(L\"%s\"))\r\n",begin.Value.(*Controller).Type,
begin.Value.(*Controller).Type,begin.Value.(*Controller).Name)
}
}
begin = begin.Next()
}
return ret
}
func (this *OpenApiController) DuilibXml2Cpp(c *gin.Context) { func (this *OpenApiController) DuilibXml2Cpp(c *gin.Context) {
f, err := c.FormFile("xml") //根据name返回给第一个文件 f, err := c.FormFile("xml") //根据name返回给第一个文件
if err != nil { if err != nil {
@ -212,6 +272,7 @@ func (this *OpenApiController) DuilibXml2Cpp(c *gin.Context) {
c.String(200,"上传文件错误") c.String(200,"上传文件错误")
return return
} }
ret := GetUifrom(file) ret := GetXmlController(file)
log.Print(ret)
c.String(200,ret) c.String(200,ret)
} }

View File

@ -30,6 +30,8 @@ func toCamelString(s string) string {
} }
return string(data[:]) return string(data[:])
} }
type FieldDesc struct { type FieldDesc struct {
FiledName string `json:"field_name"` FiledName string `json:"field_name"`
Type string `json:"type"` Type string `json:"type"`