improving gdb.Model/gmap

This commit is contained in:
John
2019-09-26 20:01:48 +08:00
parent ef4e128af7
commit c85162a8a0
19 changed files with 229 additions and 241 deletions

View File

@ -1,8 +1,6 @@
package main
import (
"fmt"
"github.com/gogf/gf/frame/g"
)
@ -10,11 +8,20 @@ func main() {
db := g.DB()
db.SetDebug(true)
r, e := db.Table("test").Where("id IN (?)", []interface{}{1, 2}).All()
//type User struct {
// Uid int
// Name *gvar.Var
//}
//user := new(User)
////user.Name = g.NewVar("john")
//g.Dump(gconv.Map(user))
_, e := db.Table("test").Data(g.Map{
"name": nil,
}).Update()
if e != nil {
panic(e)
}
if r != nil {
fmt.Println(r.ToList())
}
}

View File

@ -1,48 +1,18 @@
package main
import (
"fmt"
"github.com/gogf/gf/os/gfile"
"github.com/gogf/gf/text/gregex"
"github.com/gogf/gf/debug/gdebug"
"github.com/gogf/gf/container/gvar"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
func main() {
cdnUrl := "http://localhost"
content := `
<link rel="stylesheet" href="/plugin/amazeui-2.7.2/css/amazeui.min.css">
<link rel="stylesheet" href="/plugin/markdown-css/github-markdown.min.js">
<link rel="stylesheet" href="/plugin/prism/prism.css">
<link rel="stylesheet" href="/resource/css/document/style.css">
<link rel="icon" href="/resource/image/favicon.ico" type="image/x-icon">
`
s, err := gregex.ReplaceStringFuncMatch(`(href|src)=['"](.+?)['"]`, content, func(match []string) string {
link := match[2]
if len(link) == 0 {
return match[0]
}
if link[0:1] != "/" && link[0:1] != "#" {
if len(link) > 10 && link[0:10] == "javascript" {
return match[0]
}
if len(link) > 7 && link[0:7] == "mailto:" {
return match[0]
}
if len(link) > 4 && link[0:4] == "http" {
return match[0]
}
link = "/" + link
}
if link[0:1] == "/" {
switch gfile.ExtName(link) {
case "png", "jpg", "jpeg", "gif", "js", "css", "otf", "eot", "ttf", "woff", "woff2":
return fmt.Sprintf(`%s="%s%s?%s"`, match[1], cdnUrl, link, gdebug.BinVersion())
}
}
return match[0]
})
fmt.Println(err)
fmt.Println(s)
type User struct {
Uid int
Name *gvar.Var
}
func main() {
user := new(User)
user.Name = g.NewVar("john")
g.Dump(gconv.Map(user))
}