生成代码,逐步进行优化

This commit is contained in:
2021-06-05 02:18:56 +08:00
parent 6aa2b74840
commit 79453d4d2a
10 changed files with 139 additions and 270 deletions
-13
View File
@@ -1,13 +0,0 @@
package admin
import (
. "../../../hotime"
)
var ID = "bc662f6bf19a1f3f269045167a2f273d"
// Project 管理端项目
var Project = Proj{
//"user": UserCtr,
"user": userCtr,
}
-60
View File
@@ -1,60 +0,0 @@
package admin
import (
. "../../../hotime"
. "../../../hotime/common"
)
var userCtr = Ctr{
"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(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)
if re == 0 {
that.Display(4, "无法插入对应数据")
return
}
that.Display(0, re)
},
"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)
},
"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)
},
}
-107
View File
@@ -1,107 +0,0 @@
{
"id": "bc662f6bf19a1f3f269045167a2f273d",
"label": "HoTime管理平台",
"menu": [
{
"icon": "el-icon-s-home",
"label": "平台首页",
"name": "HelloWorld"
},
{
"icon": "el-icon-suitcase",
"label": "测试表格",
"table": "table"
},
{
"icon": "el-icon-setting",
"label": "系统管理",
"menu": [
{
"label": "用户管理",
"table": "user"
},
{
"label": "组织管理",
"table": "organization"
},
{
"label": "角色管理",
"table": "role"
},
{
"default": "edit",
"label": "系统设置",
"table": "system"
}
],
"name": "setting"
}
],
"name": "HoTimeDashBoard",
"tables": [
{
"auth": [
"add",
"delete",
"edit",
"info"
],
"columns": [
{
"label": "备注",
"must": false,
"name": "id",
"type": "integer"
},
{
"label": "备注",
"must": false,
"name": "name",
"type": "text"
},
{
"label": "备注",
"must": false,
"name": "age",
"type": "int"
}
],
"label": "备注",
"search": [
{
"label": "请输入关键词",
"name": "keyword",
"type": "text",
"value": null
},
{
"label": "时间段",
"name": "date",
"type": "date",
"value": null
},
{
"label": "状态",
"name": "state",
"option": [
{
"name": "正常",
"value": 0
},
{
"name": "异常",
"value": 1
},
{
"name": "全部",
"value": null
}
],
"type": "select",
"value": null
}
],
"table": "user"
}
]
}
+7 -2
View File
@@ -10,8 +10,13 @@
"admin": "config/app.json"
},
"db": {
"sqlite": {
"path": "config/data.db"
"mysql": {
"host": "cloud.hoteas.com",
"name": "ljf",
"password": "root",
"port": "3306",
"prefix": "",
"user": "root"
}
},
"defFile": [
+2 -2
View File
@@ -2,7 +2,7 @@ package main
import (
"../../hotime"
"./admin"
//"./admin"
"errors"
"fmt"
"golang.org/x/net/websocket"
@@ -58,7 +58,7 @@ func main() {
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
appIns.Run(hotime.Router{
"admin": admin.Project,
//"admin": admin.Project,
"app": hotime.Proj{
"index": hotime.Ctr{
"test": func(this *hotime.Context) {