Merge branch 'master' into myhs
# Conflicts: # example/admin/init.go # example/bzyy.exe # example/main.go
This commit is contained in:
commit
2fb6abf53a
@ -688,6 +688,11 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
|||||||
hasUser = true
|
hasUser = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reqValue := req.FormValue(v.GetString("name"))
|
||||||
|
if reqValue != "" {
|
||||||
|
data[table+"."+v.GetString("name")] = reqValue
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
reStr += table + "." + v.GetString("name") + ","
|
reStr += table + "." + v.GetString("name") + ","
|
||||||
}
|
}
|
||||||
|
@ -1,160 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var furnace_temperatureCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.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.MakeCode.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) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
|
|
||||||
columnStr, leftJoin, where := that.MakeCode.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.MakeCode.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})
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var materialCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.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.MakeCode.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) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
|
|
||||||
columnStr, leftJoin, where := that.MakeCode.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.MakeCode.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})
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var material_inoutCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.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.MakeCode.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) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
|
|
||||||
columnStr, leftJoin, where := that.MakeCode.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.MakeCode.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})
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var produceCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.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.MakeCode.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) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
|
|
||||||
columnStr, leftJoin, where := that.MakeCode.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.MakeCode.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})
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var produce_materialCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.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.MakeCode.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) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
|
|
||||||
columnStr, leftJoin, where := that.MakeCode.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.MakeCode.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})
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var productCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.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.MakeCode.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) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
|
|
||||||
columnStr, leftJoin, where := that.MakeCode.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.MakeCode.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})
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var product_checkCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.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.MakeCode.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) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
|
|
||||||
columnStr, leftJoin, where := that.MakeCode.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.MakeCode.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})
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,160 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var product_spot_checkCtr = Ctr{
|
|
||||||
"info": func(that *Context) {
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
str, inData := that.MakeCode.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.MakeCode.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) {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
//索引管理,便于检索以及权限
|
|
||||||
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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
inData := that.MakeCode.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) {
|
|
||||||
|
|
||||||
data := that.Db.Get("admin", "*", Map{"id": that.Session("admin_id").ToCeilInt()})
|
|
||||||
|
|
||||||
columnStr, leftJoin, where := that.MakeCode.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.MakeCode.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})
|
|
||||||
},
|
|
||||||
}
|
|
2473
example/config/app.json
Normal file
2473
example/config/app.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -24,7 +24,7 @@
|
|||||||
"db": {
|
"db": {
|
||||||
"mysql": {
|
"mysql": {
|
||||||
"host": "192.168.6.253",
|
"host": "192.168.6.253",
|
||||||
"name": "myhs",
|
"name": "bzyyweb",
|
||||||
"password": "dasda8454456",
|
"password": "dasda8454456",
|
||||||
"port": "3306",
|
"port": "3306",
|
||||||
"prefix": "",
|
"prefix": "",
|
||||||
@ -45,5 +45,8 @@
|
|||||||
"mode": 2,
|
"mode": 2,
|
||||||
"port": "8080",
|
"port": "8080",
|
||||||
"sessionName": "HOTIME",
|
"sessionName": "HOTIME",
|
||||||
|
"smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa",
|
||||||
|
"smsLogin": "【恩易办】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
|
||||||
|
"smsNotice": "【恩易办】你收到一条新的预约事项,{name}预约办理{ctg}事项,预约办理时间:{date},排号:{sn}。",
|
||||||
"tpt": "tpt"
|
"tpt": "tpt"
|
||||||
}
|
}
|
BIN
example/myhs.exe
BIN
example/myhs.exe
Binary file not shown.
BIN
example/tpt/file/2021/11/13/9111bcfcaf8b8240976dc08e97658605.png
Normal file
BIN
example/tpt/file/2021/11/13/9111bcfcaf8b8240976dc08e97658605.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 297 KiB |
BIN
example/tpt/file/2021/11/13/9129a3b12a8eb56a47da20135f8106bc.png
Normal file
BIN
example/tpt/file/2021/11/13/9129a3b12a8eb56a47da20135f8106bc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 120 KiB |
BIN
example/tpt/file/2021/12/27/a24a4bc4d8f4947de0eed6bcf9b7186c.jpg
Normal file
BIN
example/tpt/file/2021/12/27/a24a4bc4d8f4947de0eed6bcf9b7186c.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
Loading…
Reference in New Issue
Block a user