73 lines
1.9 KiB
Go
73 lines
1.9 KiB
Go
package admin
|
|
|
|
import (
|
|
. "../../../hotime"
|
|
. "../../../hotime/common"
|
|
)
|
|
|
|
var ID = "9d45054a3b471ace785f5884621114e3"
|
|
|
|
// Project 管理端项目
|
|
var Project = Proj{
|
|
//"user": UserCtr,
|
|
"admin": adminCtr,
|
|
"category": categoryCtr,
|
|
"ctg_order_date": ctg_order_dateCtr,
|
|
"order": orderCtr,
|
|
"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("admin_id", user.GetCeilInt("id"))
|
|
this.Session("admin_name", name)
|
|
this.Display(0, this.SessionId)
|
|
},
|
|
"logout": func(this *Context) {
|
|
this.Session("admin_id", nil)
|
|
this.Session("admin_name", nil)
|
|
this.Display(0, "退出登录成功")
|
|
},
|
|
"info": func(that *Context) {
|
|
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
str, inData := that.MakeCode.Info("admin", data, that.Db)
|
|
where := Map{"id": that.Session("admin_id").ToCeilInt()}
|
|
if len(inData) == 1 {
|
|
inData["id"] = where["id"]
|
|
where = Map{"AND": inData}
|
|
} else if len(inData) > 1 {
|
|
where["OR"] = inData
|
|
where = Map{"AND": where}
|
|
}
|
|
re := that.Db.Get("admin", str, where)
|
|
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"), "id,"+column.GetString("value"), Map{"id": v})
|
|
}
|
|
}
|
|
|
|
that.Display(0, re)
|
|
},
|
|
},
|
|
}
|