修复bug
This commit is contained in:
parent
5c775b4539
commit
3810ba6c0b
@ -551,7 +551,7 @@ func (that *MakeCode) Add(table string, req *http.Request) Map {
|
|||||||
//不可使用,未在前端展示,但在内存中保持有
|
//不可使用,未在前端展示,但在内存中保持有
|
||||||
if v.GetBool("notUse") {
|
if v.GetBool("notUse") {
|
||||||
if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
||||||
data[v.GetString("name")] = Slice{}
|
data[v.GetString("name")] = ","
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue
|
||||||
@ -593,7 +593,7 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map {
|
|||||||
//不可使用,未在前端展示,但在内存中保持有
|
//不可使用,未在前端展示,但在内存中保持有
|
||||||
if v.GetBool("notUse") {
|
if v.GetBool("notUse") {
|
||||||
if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
||||||
data[v.GetString("name")] = Slice{}
|
data[v.GetString("name")] = ","
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -626,17 +626,12 @@ func (that *MakeCode) Delete(table string, req *http.Request) Map {
|
|||||||
//不可使用,未在前端展示,但在内存中保持有
|
//不可使用,未在前端展示,但在内存中保持有
|
||||||
if v.GetBool("notUse") {
|
if v.GetBool("notUse") {
|
||||||
if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
||||||
data[v.GetString("name")] = Slice{}
|
data[v.GetString("name")] = ","
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(data) == 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ var Project = Proj{
|
|||||||
this.Display(3, "参数不足")
|
this.Display(3, "参数不足")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
user := this.Db.Get("admin", "*", Map{"AND": Map{"name": name, "password": Md5(password)}})
|
user := this.Db.Get("admin", "*", Map{"AND": Map{"OR":Map{"name": name,"phone":name}, "password": Md5(password)}})
|
||||||
if user == nil {
|
if user == nil {
|
||||||
this.Display(5, "登录失败")
|
this.Display(5, "登录失败")
|
||||||
return
|
return
|
||||||
@ -122,10 +122,13 @@ var {{table}}Ctr = Ctr{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
//索引管理,便于检索以及权限
|
//索引管理,便于检索以及权限
|
||||||
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
|
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
||||||
index := that.Db.Get(that.RouterString[1], "` + "`index`" + `", Map{"id": inData.Get("parent_id")})
|
index := that.Db.Get(that.RouterString[1], "` + "`index`" + `", Map{"id": inData.Get("parent_id")})
|
||||||
inData["index"] = index.GetString("index")+ObjToStr(re)+","
|
inData["index"] = index.GetString("index")+ObjToStr(re)+","
|
||||||
that.Db.Update(that.RouterString[1],Map{"index":inData["index"]},Map{"id":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)
|
that.Display(0, re)
|
||||||
@ -138,7 +141,7 @@ var {{table}}Ctr = Ctr{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//索引管理,便于检索以及权限
|
//索引管理,便于检索以及权限
|
||||||
if inData.Get("parent_id") != nil && inData.GetSlice("index") != nil {
|
if inData.Get("parent_id") != nil && inData.GetString("index") != "" {
|
||||||
Index := that.Db.Get(that.RouterString[1], "` + "`index`" + `", Map{"id": that.RouterString[2]})
|
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")})
|
parentIndex := that.Db.Get(that.RouterString[1], "` + "`index`" + `", Map{"id": inData.Get("parent_id")})
|
||||||
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
|
inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + ","
|
||||||
|
@ -34,7 +34,7 @@ func (this *DDY) SendYZM(umoblie string, tpt string, data map[string]string) (bo
|
|||||||
//发送通知
|
//发送通知
|
||||||
func (this *DDY) SendTz(umoblie []string, tpt string, data map[string]string) (bool, error) {
|
func (this *DDY) SendTz(umoblie []string, tpt string, data map[string]string) (bool, error) {
|
||||||
for k, v := range data {
|
for k, v := range data {
|
||||||
tpt = strings.Replace(tpt, "["+k+"]", v, -1)
|
tpt = strings.Replace(tpt, "{"+k+"}", v, -1)
|
||||||
}
|
}
|
||||||
umobleStr := ""
|
umobleStr := ""
|
||||||
for i, v := range umoblie {
|
for i, v := range umoblie {
|
||||||
|
@ -1,157 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var adminCtr = 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"), 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.GetSlice("index") != nil {
|
|
||||||
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})
|
|
||||||
}
|
|
||||||
|
|
||||||
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.GetSlice("index") != nil {
|
|
||||||
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,157 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var categoryCtr = 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"), 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.GetSlice("index") != nil {
|
|
||||||
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})
|
|
||||||
}
|
|
||||||
|
|
||||||
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.GetSlice("index") != nil {
|
|
||||||
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,157 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var ctg_order_dateCtr = 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"), 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.GetSlice("index") != nil {
|
|
||||||
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})
|
|
||||||
}
|
|
||||||
|
|
||||||
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.GetSlice("index") != nil {
|
|
||||||
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,72 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
var ID = "ede7cc05f2e6c63b4572883f4b9a9853"
|
|
||||||
|
|
||||||
// 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)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var orderCtr = 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"), 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.GetSlice("index") != nil {
|
|
||||||
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})
|
|
||||||
}
|
|
||||||
|
|
||||||
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.GetSlice("index") != nil {
|
|
||||||
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,157 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var orgCtr = 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.GetSlice("index") != nil {
|
|
||||||
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})
|
|
||||||
}
|
|
||||||
|
|
||||||
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.GetSlice("index") != nil {
|
|
||||||
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,157 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var roleCtr = 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"), 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.GetSlice("index") != nil {
|
|
||||||
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})
|
|
||||||
}
|
|
||||||
|
|
||||||
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.GetSlice("index") != nil {
|
|
||||||
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,157 +0,0 @@
|
|||||||
package admin
|
|
||||||
|
|
||||||
import (
|
|
||||||
. "../../../hotime"
|
|
||||||
. "../../../hotime/common"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
var userCtr = 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"), 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.GetSlice("index") != nil {
|
|
||||||
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})
|
|
||||||
}
|
|
||||||
|
|
||||||
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.GetSlice("index") != nil {
|
|
||||||
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})
|
|
||||||
},
|
|
||||||
}
|
|
@ -12,8 +12,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ID = "aad1472b19e575a71ee8f75629e27867"
|
|
||||||
|
|
||||||
// Project 管理端项目
|
// Project 管理端项目
|
||||||
var Project = Proj{
|
var Project = Proj{
|
||||||
//"user": UserCtr,
|
//"user": UserCtr,
|
||||||
|
@ -3,6 +3,7 @@ package app
|
|||||||
import (
|
import (
|
||||||
. "../../../hotime"
|
. "../../../hotime"
|
||||||
. "../../../hotime/common"
|
. "../../../hotime/common"
|
||||||
|
"../../dri/ddsms"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -52,6 +53,30 @@ var orderCtr = Ctr{
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.Db.Update("ctg_order_date", Map{"now_sn": ctgOrderDate.GetCeilInt64("now_sn") + 1, "modify_time": time.Now().Unix()}, Map{"id": ctgOrderDate.GetCeilInt("id")})
|
this.Db.Update("ctg_order_date", Map{"now_sn": ctgOrderDate.GetCeilInt64("now_sn") + 1, "modify_time": time.Now().Unix()}, Map{"id": ctgOrderDate.GetCeilInt("id")})
|
||||||
|
//查询并发送短信
|
||||||
|
category := this.Db.Get("category", "name", Map{"id": ctgOrderDate.GetCeilInt("category_id")})
|
||||||
|
categorys := this.Db.Select("category", "org_id", Map{"index[~]": "," + ctgOrderDate.GetString("category_id") + ","})
|
||||||
|
orgIDs := Slice{}
|
||||||
|
for _, v := range categorys {
|
||||||
|
orgs := this.Db.Select("org", "id", Map{"index[~]": v.GetCeilInt("org_id")})
|
||||||
|
for _, orgv := range orgs {
|
||||||
|
orgIDs = append(orgIDs, orgv.GetCeilInt("id"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
admin := this.Db.Select("admin", "phone,id", Map{"org_id": orgIDs})
|
||||||
|
user := this.Db.Get("user", "name", Map{"id": this.Session("id").ToCeilInt()})
|
||||||
|
for _, v := range admin {
|
||||||
|
phone := v.GetString("phone")
|
||||||
|
if len(phone) == 11 {
|
||||||
|
ddsms.DefaultDDY.SendTz([]string{phone}, this.Config.GetString("smsNotice"),
|
||||||
|
map[string]string{"date": data.GetString("name"), "ctg": category.GetString("name"),
|
||||||
|
"name": user.GetString("name"),
|
||||||
|
"sn": data.GetString("sn"),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.Display(0, data)
|
this.Display(0, data)
|
||||||
},
|
},
|
||||||
"search": func(that *Context) {
|
"search": func(that *Context) {
|
||||||
|
@ -26,10 +26,6 @@ var Sms = Ctr{
|
|||||||
this.Session("phone", phone)
|
this.Session("phone", phone)
|
||||||
this.Session("code", code)
|
this.Session("code", code)
|
||||||
|
|
||||||
//tencentSendYzm(phone, code)
|
|
||||||
if ddsms.DefaultDDY.ApiKey == "" {
|
|
||||||
ddsms.DefaultDDY.Init(this.Config.GetString("smsKey"))
|
|
||||||
}
|
|
||||||
ddsms.DefaultDDY.SendYZM(phone, this.Config.GetString("smsLogin"), map[string]string{"code": code})
|
ddsms.DefaultDDY.SendYZM(phone, this.Config.GetString("smsLogin"), map[string]string{"code": code})
|
||||||
|
|
||||||
this.Display(0, "发送成功")
|
this.Display(0, "发送成功")
|
||||||
|
BIN
example/bzyy.exe
BIN
example/bzyy.exe
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -47,5 +47,6 @@
|
|||||||
"sessionName": "HOTIME",
|
"sessionName": "HOTIME",
|
||||||
"smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa",
|
"smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa",
|
||||||
"smsLogin": "【恩易办】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
|
"smsLogin": "【恩易办】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。",
|
||||||
|
"smsNotice": "【恩易办】你收到一条新的预约事项,{name}预约办理{ctg}事项,预约办理时间:{date},排号:{sn}。",
|
||||||
"tpt": "tpt"
|
"tpt": "tpt"
|
||||||
}
|
}
|
@ -3,6 +3,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"../../hotime"
|
"../../hotime"
|
||||||
"../../hotime/common"
|
"../../hotime/common"
|
||||||
|
"../dri/ddsms"
|
||||||
"./admin"
|
"./admin"
|
||||||
"./app"
|
"./app"
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -140,6 +141,9 @@ func main() {
|
|||||||
|
|
||||||
//makeCode := code.MakeCode{}
|
//makeCode := code.MakeCode{}
|
||||||
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
|
//fmt.Println(common.ObjToStr(makeCode.Db2JSON("admin","test",appIns.Db)))
|
||||||
|
if ddsms.DefaultDDY.ApiKey == "" {
|
||||||
|
ddsms.DefaultDDY.Init(appIns.Config.GetString("smsKey"))
|
||||||
|
}
|
||||||
|
|
||||||
appIns.Run(hotime.Router{
|
appIns.Run(hotime.Router{
|
||||||
"admin": admin.Project,
|
"admin": admin.Project,
|
||||||
|
Loading…
Reference in New Issue
Block a user