增加表关联新建功能,同时修复数据库bug

This commit is contained in:
2021-08-30 07:36:17 +08:00
parent e1f4876621
commit 62cf625fe9
10 changed files with 100 additions and 332 deletions
+46 -1
View File
@@ -2,9 +2,10 @@ package admin
import (
. "../../../hotime"
. "../../../hotime/common"
)
var ID = "f3fb4577ad6c15aedadd869e2bf6663c"
var ID = "3c5fc9732b8ddcb0a91b428976f2ce86"
// Project 管理端项目
var Project = Proj{
@@ -16,4 +17,48 @@ var Project = Proj{
"org": orgCtr,
"role": roleCtr,
"user": userCtr,
"hotime": Ctr{
"login": func(this *Context) {
name := this.Req.FormValue("name")
password := this.Req.FormValue("password")
if name == "" || password == "" {
this.Display(3, "参数不足")
return
}
user := this.Db.Get("admin", "*", Map{"AND": Map{"name": name, "password": Md5(password)}})
if user == nil {
this.Display(5, "登录失败")
return
}
this.Session("id", user.GetCeilInt("id"))
this.Session("name", name)
this.Display(0, "登录成功")
},
"logout": func(this *Context) {
this.Session("id", nil)
this.Session("name", nil)
this.Display(0, "退出登录成功")
},
"info": func(that *Context) {
re := that.Db.Get("admin", that.MakeCode.Info("admin"), Map{"id": that.Session("id").ToCeilInt()})
if re == nil {
that.Display(4, "找不到对应信息")
return
}
for k, v := range re {
column := that.MakeCode.TableColumns["admin"][k]
if column == nil {
continue
}
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" {
re[column.GetString("link")] = that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v})
}
}
that.Display(0, re)
},
},
}