Documentation
¶
Index ¶
- Variables
- type ColumnShow
- type MakeCode
- func (that *MakeCode) Add(table string, user Map, req *http.Request) Map
- func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map)
- func (that *MakeCode) Delete(table string, req *http.Request) Map
- func (that *MakeCode) Edit(table string, req *http.Request) Map
- func (that *MakeCode) Info(table string, userData Map, db *db.HoTimeDB) (string, Map)
- func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Request, db *db.HoTimeDB) (string, Map)
Constants ¶
This section is empty.
Variables ¶
View Source
var ColumnDataType = map[string]string{
"real": "number",
"int": "number",
"float": "number",
"double": "number",
"decimal": "number",
"integer": "number",
"char": "text",
"text": "text",
"blob": "text",
"date": "time",
"time": "time",
"year": "time",
"geometry": "gis",
}
View Source
var Config = Map{
"name": "HoTimeDashBoard",
"label": "HoTime管理平台",
"stop": Slice{"role", "org"},
"labelConfig": Map{
"show": "开启",
"add": "添加",
"delete": "删除",
"edit": "编辑",
"info": "查看详情",
"download": "下载清单",
},
"menus": []Map{},
}
View Source
var CtrTpt = `package {{name}}
import (
. "code.hoteas.com/golang/hotime"
. "code.hoteas.com/golang/hotime/common"
"strings"
)
var {{table}}Ctr = Ctr{
"info": func(that *Context) {
hotimeName := that.RouterString[0]
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
str, inData := that.MakeCodeRouter[hotimeName].Info(that.RouterString[1], data, that.Db)
where := Map{"id": that.RouterString[2]}
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(that.RouterString[1], str, where)
if re == nil {
that.Display(4, "找不到对应信息")
return
}
for k, v := range re {
column := that.MakeCodeRouter[hotimeName].TableColumns[that.RouterString[1]][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)
},
"add": func(that *Context) {
hotimeName := that.RouterString[0]
inData := that.MakeCodeRouter[hotimeName].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
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
index := that.Db.Get(that.RouterString[1], "` + "`index`" + `", Map{"id": inData.Get("parent_id")})
inData["index"] = index.GetString("index")+ObjToStr(re)+","
that.Db.Update(that.RouterString[1],Map{"index":inData["index"]},Map{"id":re})
}else if inData.GetString("index") != ""{
inData["index"] = "," + ObjToStr(re) + ","
that.Db.Update(that.RouterString[1], Map{"index": inData["index"]}, Map{"id": re})
}
that.Display(0, re)
},
"update": func(that *Context) {
hotimeName := that.RouterString[0]
inData := that.MakeCodeRouter[hotimeName].Edit(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "没有找到要更新的数据")
return
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
Index := that.Db.Get(that.RouterString[1], "` + "`index`" + `", Map{"id": that.RouterString[2]})
parentIndex := that.Db.Get(that.RouterString[1], "` + "`index`" + `", Map{"id": inData.Get("parent_id")})
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
childNodes := that.Db.Select(that.RouterString[1], "id,` + "`index`" + `", Map{"index[~]": "," + that.RouterString[2] + ","})
for _, v := range childNodes {
v["index"] = strings.Replace(v.GetString("index"), Index.GetString("index"), inData.GetString("index"), -1)
that.Db.Update(that.RouterString[1], Map{"index": v["index"]}, Map{"id": v.GetCeilInt("id")})
}
}
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) {
hotimeName := that.RouterString[0]
inData := that.MakeCodeRouter[hotimeName].Delete(that.RouterString[1], that.Req)
if inData == nil {
that.Display(3, "请求参数不足")
return
}
re :=int64(0)
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
re=that.Db.Delete(that.RouterString[1], Map{"index[~]": "," + that.RouterString[2] + ","})
}else {
re=that.Db.Delete(that.RouterString[1], Map{"id": that.RouterString[2]})
}
if re == 0 {
that.Display(4, "删除数据失败")
return
}
that.Display(0, "删除成功")
},
"search": func(that *Context) {
hotimeName := that.RouterString[0]
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
columnStr, leftJoin, where := that.MakeCodeRouter[hotimeName].Search(that.RouterString[1], data, that.Req, that.Db)
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
if page < 1 {
page = 1
}
if pageSize <= 0 {
pageSize = 20
}
count := that.Db.Count(that.RouterString[1], leftJoin, where)
reData := that.Db.Page(page, pageSize).
PageSelect(that.RouterString[1], leftJoin, columnStr, where)
for _, v := range reData {
for k, _ := range v {
column := that.MakeCodeRouter[hotimeName].TableColumns[that.RouterString[1]][k]
if column == nil {
continue
}
if column["list"] != false && column["name"] == "parent_id" && column.GetString("link") != "" {
parentC := that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v.GetCeilInt(k)})
v[column.GetString("link")+"_"+column.GetString("name")+"_"+column.GetString("value")] = ""
if parentC != nil {
v[column.GetString("link")+"_"+column.GetString("name")+"_"+column.GetString("value")] = parentC.GetString(column.GetString("value"))
}
}
}
}
that.Display(0, Map{"count": count, "data": reData})
},
}
`
View Source
var DefaultMenuParentName = "sys"
View Source
var InitTpt = `` /* 1886-byte string literal not displayed */
View Source
var RuleConfig = []Map{ {"name": "idcard", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "id", "add": false, "list": true, "edit": false, "info": true, "must": false, "strict": true, "type": ""}, {"name": "sn", "add": false, "list": true, "edit": false, "info": true, "must": false, "strict": false, "type": ""}, {"name": "parent_ids", "add": false, "list": false, "edit": false, "info": false, "must": false, "strict": true, "type": "index"}, {"name": "index", "add": false, "list": false, "edit": false, "info": false, "must": false, "strict": true, "type": "index"}, {"name": "parent_id", "add": true, "list": true, "edit": true, "info": true, "must": false, "true": false, "type": ""}, {"name": "amount", "add": true, "list": true, "edit": true, "info": true, "must": false, "strict": true, "type": "money"}, {"name": "info", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": "textArea"}, {"name": "status", "add": true, "list": true, "edit": true, "info": true, "must": false, "strict": false, "type": "select"}, {"name": "state", "add": true, "list": true, "edit": true, "info": true, "must": false, "strict": false, "type": "select"}, {"name": "sex", "add": true, "list": true, "edit": true, "info": true, "must": false, "strict": false, "type": "select"}, {"name": "delete", "add": false, "list": false, "edit": false, "info": false, "must": false, "strict": false, "type": ""}, {"name": "lat", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "lng", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "latitude", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "longitude", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "password", "add": true, "list": false, "edit": true, "info": false, "must": false, "strict": false, "type": "password"}, {"name": "pwd", "add": true, "list": false, "edit": true, "info": false, "must": false, "strict": false, "type": "password"}, {"name": "version", "add": false, "list": false, "edit": false, "info": false, "must": false, "strict": false, "type": ""}, {"name": "seq", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "sort", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "note", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "description", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "abstract", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "content", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": "textArea"}, {"name": "address", "add": true, "list": true, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "full_name", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "create_time", "add": false, "list": false, "edit": false, "info": true, "must": false, "strict": true, "type": "time"}, {"name": "modify_time", "add": false, "list": true, "edit": false, "info": true, "must": false, "strict": true, "type": "time"}, {"name": "image", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": "image"}, {"name": "img", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": "image"}, {"name": "avatar", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": "image"}, {"name": "icon", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": "image"}, {"name": "file", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": "file"}, {"name": "age", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "email", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": ""}, {"name": "time", "add": true, "list": true, "edit": true, "info": true, "must": false, "strict": false, "type": "time"}, {"name": "level", "add": false, "list": false, "edit": false, "info": true, "must": false, "strict": false, "type": ""}, {"name": "rule", "add": true, "list": true, "edit": true, "info": true, "must": false, "strict": false, "type": "form"}, {"name": "auth", "add": true, "list": false, "edit": true, "info": true, "must": false, "strict": false, "type": "auth"}, {"name": "table", "add": false, "list": true, "edit": false, "info": true, "must": false, "strict": false, "type": "table"}, {"name": "table_id", "add": false, "list": true, "edit": false, "info": true, "must": false, "strict": false, "type": "table_id"}, }
Functions ¶
This section is empty.
Types ¶
type ColumnShow ¶
Click to show internal directories.
Click to hide internal directories.