接入RESTfull风格接口

This commit is contained in:
hoteas 2021-05-30 00:10:07 +08:00
parent 465ea889a2
commit 9af232840c
2 changed files with 8 additions and 7 deletions

View File

@ -139,6 +139,7 @@ func (that *HoTimeDB) Row(resl *sql.Rows) []Map {
return nil return nil
} }
for j := 0; j < len(a); j++ { for j := 0; j < len(a); j++ {
//fmt.Println(reflect.ValueOf(a[j]).Type().String() )
if a[j] != nil && reflect.ValueOf(a[j]).Type().String() == "[]uint8" { if a[j] != nil && reflect.ValueOf(a[j]).Type().String() == "[]uint8" {
lis[strs[j]] = string(a[j].([]byte)) lis[strs[j]] = string(a[j].([]byte))
} else { } else {
@ -147,12 +148,12 @@ func (that *HoTimeDB) Row(resl *sql.Rows) []Map {
} }
//防止int被误读为float64 //防止int被误读为float64
jlis, e := json.Marshal(lis) //jlis, e := json.Marshal(lis)
if e != nil { //if e != nil {
that.LastErr.SetError(e) // that.LastErr.SetError(e)
} else { //} else {
lis.JsonToMap(string(jlis), that.LastErr) // lis.JsonToMap(string(jlis), that.LastErr)
} //}
dest = append(dest, lis) dest = append(dest, lis)

View File

@ -24,7 +24,7 @@ var UserCtr = Ctr{
}, },
"search": func(this *Context) { "search": func(this *Context) {
user := this.Db.Select(this.RouterString[1], "*") user := this.Db.Select(this.RouterString[1], "*")
fmt.Println(user) fmt.Println(user, user[0].GetFloat64("age"))
this.Display(0, user) this.Display(0, user)
}, },
} }