已经接入配置文件,开始准备生成代码
This commit is contained in:
+44
-12
@@ -3,26 +3,58 @@ package admin
|
||||
import (
|
||||
. "../../../hotime"
|
||||
. "../../../hotime/common"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var UserCtr = Ctr{
|
||||
"info": func(this *Context) {
|
||||
user := this.Db.Get(this.RouterString[1], "*", Map{"id": this.RouterString[2]})
|
||||
this.Display(0, user)
|
||||
"info": func(that *Context) {
|
||||
re := that.Db.Get(that.RouterString[1], that.MakeCode.Info(that.RouterString[1]), Map{"id": that.RouterString[2]})
|
||||
that.Display(0, re)
|
||||
},
|
||||
"add": func(this *Context) {
|
||||
"add": func(that *Context) {
|
||||
inData := that.MakeCode.Add(that.RouterString[1], that.Req)
|
||||
if inData == nil {
|
||||
that.Display(3, "请求参数不足")
|
||||
return
|
||||
}
|
||||
re := that.Db.Insert(that.RouterString[1], inData)
|
||||
|
||||
},
|
||||
"update": func(this *Context) {
|
||||
if re == 0 {
|
||||
that.Display(4, "无法插入对应数据")
|
||||
return
|
||||
}
|
||||
|
||||
that.Display(0, re)
|
||||
},
|
||||
"remove": func(this *Context) {
|
||||
"update": func(that *Context) {
|
||||
inData := that.MakeCode.Edit(that.RouterString[1], that.Req)
|
||||
if inData == nil {
|
||||
that.Display(3, "没有找到要更新的数据")
|
||||
return
|
||||
}
|
||||
re := that.Db.Update(that.RouterString[1], inData, Map{"id": that.RouterString[2]})
|
||||
|
||||
if re == 0 {
|
||||
that.Display(4, "更新数据失败")
|
||||
return
|
||||
}
|
||||
|
||||
that.Display(0, re)
|
||||
},
|
||||
"search": func(this *Context) {
|
||||
user := this.Db.Select(this.RouterString[1], "*")
|
||||
fmt.Println(user, user[0].GetFloat64("age"))
|
||||
this.Display(0, user)
|
||||
"remove": func(that *Context) {
|
||||
re := that.Db.Delete(that.RouterString[1], Map{"id": that.RouterString[2]})
|
||||
|
||||
if re == 0 {
|
||||
that.Display(4, "删除数据失败")
|
||||
return
|
||||
}
|
||||
that.Display(0, re)
|
||||
},
|
||||
"search": func(that *Context) {
|
||||
|
||||
columnStr, where := that.MakeCode.Search(that.RouterString[1], that.Req)
|
||||
reData := that.Db.Page(ObjToInt(that.Req.FormValue("page")), ObjToInt(that.Req.FormValue("pageRow"))).
|
||||
Select(that.RouterString[1], columnStr, where)
|
||||
|
||||
that.Display(0, reData)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
"timeout": 7200
|
||||
}
|
||||
},
|
||||
"codeConfig": {
|
||||
"admin": "config/app.json"
|
||||
},
|
||||
"db": {
|
||||
"sqlite": {
|
||||
"path": "example/config/data.db"
|
||||
@@ -16,7 +19,7 @@
|
||||
"index.htm"
|
||||
],
|
||||
"devConfig": {
|
||||
"admin": "config/app.json"
|
||||
"admin": "example/config/app.json"
|
||||
},
|
||||
"error": {
|
||||
"1": "内部系统异常",
|
||||
|
||||
Binary file not shown.
@@ -54,6 +54,9 @@ func main() {
|
||||
return false
|
||||
})
|
||||
|
||||
//makeCode := code.MakeCode{}
|
||||
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
|
||||
|
||||
appIns.Run(hotime.Router{
|
||||
"admin": admin.Project,
|
||||
"app": hotime.Proj{
|
||||
|
||||
Reference in New Issue
Block a user