diff --git a/code/makecode.go b/code/makecode.go index 0603be3..9c0ae26 100644 --- a/code/makecode.go +++ b/code/makecode.go @@ -551,7 +551,7 @@ func (that *MakeCode) Add(table string, req *http.Request) Map { //不可使用,未在前端展示,但在内存中保持有 if v.GetBool("notUse") { if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil { - data[v.GetString("name")] = Slice{} + data[v.GetString("name")] = "," } continue @@ -593,7 +593,7 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map { //不可使用,未在前端展示,但在内存中保持有 if v.GetBool("notUse") { if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil { - data[v.GetString("name")] = Slice{} + data[v.GetString("name")] = "," } continue } @@ -626,17 +626,12 @@ func (that *MakeCode) Delete(table string, req *http.Request) Map { //不可使用,未在前端展示,但在内存中保持有 if v.GetBool("notUse") { if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil { - data[v.GetString("name")] = Slice{} + data[v.GetString("name")] = "," } continue } } - - if len(data) == 0 { - return nil - } - return data } diff --git a/code/template.go b/code/template.go index 23a4b1b..bfd18d2 100644 --- a/code/template.go +++ b/code/template.go @@ -21,7 +21,7 @@ var Project = Proj{ this.Display(3, "参数不足") 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 { this.Display(5, "登录失败") return @@ -122,10 +122,13 @@ var {{table}}Ctr = Ctr{ 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")}) 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) @@ -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]}) parentIndex := that.Db.Get(that.RouterString[1], "` + "`index`" + `", Map{"id": inData.Get("parent_id")}) inData["index"] = parentIndex.GetString("index") + that.RouterString[2] + "," diff --git a/dri/ddsms/ddsms.go b/dri/ddsms/ddsms.go index 60edb73..499c8c1 100644 --- a/dri/ddsms/ddsms.go +++ b/dri/ddsms/ddsms.go @@ -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) { for k, v := range data { - tpt = strings.Replace(tpt, "["+k+"]", v, -1) + tpt = strings.Replace(tpt, "{"+k+"}", v, -1) } umobleStr := "" for i, v := range umoblie { diff --git a/example/admin/admin.go b/example/admin/admin.go deleted file mode 100644 index c874228..0000000 --- a/example/admin/admin.go +++ /dev/null @@ -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}) - }, -} diff --git a/example/admin/category.go b/example/admin/category.go deleted file mode 100644 index 7df64fd..0000000 --- a/example/admin/category.go +++ /dev/null @@ -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}) - }, -} diff --git a/example/admin/ctg_order_date.go b/example/admin/ctg_order_date.go deleted file mode 100644 index 9b99f78..0000000 --- a/example/admin/ctg_order_date.go +++ /dev/null @@ -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}) - }, -} diff --git a/example/admin/init.go b/example/admin/init.go deleted file mode 100644 index 1fdddfb..0000000 --- a/example/admin/init.go +++ /dev/null @@ -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) - }, - }, -} diff --git a/example/admin/order.go b/example/admin/order.go deleted file mode 100644 index 743020d..0000000 --- a/example/admin/order.go +++ /dev/null @@ -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}) - }, -} diff --git a/example/admin/org.go b/example/admin/org.go deleted file mode 100644 index 15d5a99..0000000 --- a/example/admin/org.go +++ /dev/null @@ -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}) - }, -} diff --git a/example/admin/role.go b/example/admin/role.go deleted file mode 100644 index ac13993..0000000 --- a/example/admin/role.go +++ /dev/null @@ -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}) - }, -} diff --git a/example/admin/user.go b/example/admin/user.go deleted file mode 100644 index 5c6ddae..0000000 --- a/example/admin/user.go +++ /dev/null @@ -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}) - }, -} diff --git a/example/app/init.go b/example/app/init.go index f6c7038..48849ae 100644 --- a/example/app/init.go +++ b/example/app/init.go @@ -12,8 +12,6 @@ import ( "time" ) -var ID = "aad1472b19e575a71ee8f75629e27867" - // Project 管理端项目 var Project = Proj{ //"user": UserCtr, diff --git a/example/app/order.go b/example/app/order.go index a8bb279..29bdc5e 100644 --- a/example/app/order.go +++ b/example/app/order.go @@ -3,6 +3,7 @@ package app import ( . "../../../hotime" . "../../../hotime/common" + "../../dri/ddsms" "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")}) + //查询并发送短信 + 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) }, "search": func(that *Context) { diff --git a/example/app/sms.go b/example/app/sms.go index 7e8efb5..78432a1 100644 --- a/example/app/sms.go +++ b/example/app/sms.go @@ -26,10 +26,6 @@ var Sms = Ctr{ this.Session("phone", phone) 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}) this.Display(0, "发送成功") diff --git a/example/bzyy.exe b/example/bzyy.exe index 6a54c18..f263cd6 100644 Binary files a/example/bzyy.exe and b/example/bzyy.exe differ diff --git a/example/config/app.json b/example/config/app.json deleted file mode 100644 index 5287cbe..0000000 --- a/example/config/app.json +++ /dev/null @@ -1,1293 +0,0 @@ -{ - "id": "ede7cc05f2e6c63b4572883f4b9a9853", - "label": "HoTime管理平台", - "menus": [ - { - "icon": "el-icon-s-home", - "label": "平台首页", - "name": "HelloWorld" - }, - { - "icon": "el-icon-setting", - "label": "系统管理", - "menus": [ - { - "label": "事项管理", - "table": "category" - }, - { - "label": "排号计划", - "table": "ctg_order_date" - }, - { - "label": "预约管理", - "table": "order" - }, - { - "label": "部门管理", - "table": "org" - }, - { - "label": "角色管理", - "table": "role" - }, - { - "label": "群众管理", - "table": "user" - }, - { - "label": "人员管理", - "table": "admin" - } - ], - "name": "sys" - } - ], - "name": "admin", - "tables": { - "admin": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "must": false, - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "must": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "must": false, - "name": "modify_time", - "type": "time" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "info": false, - "label": "密码", - "list": false, - "must": false, - "name": "password", - "type": "password" - }, - { - "label": "头像", - "list": false, - "must": false, - "name": "avatar_img", - "type": "image" - }, - { - "label": "角色", - "link": "role", - "name": "role_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "部门", - "link": "org", - "name": "org_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "手机号", - "name": "phone", - "type": "text" - } - ], - "label": "人员管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "部门", - "link": "org", - "name": "org_id", - "type": "tree", - "value": "name" - } - ], - "table": "admin" - }, - "category": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "must": false, - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "label": "排序 序号越大越排前面", - "list": false, - "must": false, - "name": "sort", - "sortable": true, - "type": "number" - }, - { - "label": "归属专区", - "link": "category", - "must": false, - "name": "parent_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "创建人员", - "link": "admin", - "name": "admin_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "must": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "must": false, - "name": "modify_time", - "type": "time" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "周一上午", - "name": "am1", - "sortable": true, - "type": "number" - }, - { - "label": "周二上午", - "name": "am2", - "sortable": true, - "type": "number" - }, - { - "label": "周三上午", - "name": "am3", - "sortable": true, - "type": "number" - }, - { - "label": "周四上午", - "name": "am4", - "sortable": true, - "type": "number" - }, - { - "label": "周五上午", - "name": "am5", - "sortable": true, - "type": "number" - }, - { - "label": "周一下午", - "name": "pm1", - "sortable": true, - "type": "number" - }, - { - "label": "周二下午", - "name": "pm2", - "sortable": true, - "type": "number" - }, - { - "label": "周三下午", - "name": "pm3", - "sortable": true, - "type": "number" - }, - { - "label": "周四下午", - "name": "pm4", - "sortable": true, - "type": "number" - }, - { - "label": "周五下午", - "name": "pm5", - "sortable": true, - "type": "number" - }, - { - "label": "办理地址", - "list": false, - "must": false, - "name": "address", - "type": "text" - }, - { - "label": "叫号起始号", - "name": "startnum", - "sortable": true, - "type": "number" - }, - { - "label": "办理窗口", - "name": "window", - "type": "text" - }, - { - "label": "天府通办APP端", - "must": true, - "name": "tftbapp", - "options": [ - { - "name": "未启用", - "value": "0" - }, - { - "name": "已启用", - "value": "1" - } - ], - "sortable": true, - "type": "select" - }, - { - "label": "天府通办web端", - "must": true, - "name": "tftbweb", - "options": [ - { - "name": "未启用", - "value": "0" - }, - { - "name": "已启用", - "value": "1" - } - ], - "sortable": true, - "type": "select" - }, - { - "label": "图标", - "list": false, - "must": false, - "name": "icon", - "type": "image" - }, - { - "label": "关联部门", - "link": "org", - "name": "org_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "add": false, - "edit": false, - "info": false, - "label": "索引", - "list": false, - "must": false, - "name": "index", - "notUse": true, - "type": "index" - } - ], - "label": "事项管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "天府通办APP端", - "must": true, - "name": "tftbapp", - "options": [ - { - "name": "未启用", - "value": "0" - }, - { - "name": "已启用", - "value": "1" - }, - { - "name": "全部", - "value": null - } - ], - "sortable": true, - "type": "select", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "天府通办web端", - "must": true, - "name": "tftbweb", - "options": [ - { - "name": "未启用", - "value": "0" - }, - { - "name": "已启用", - "value": "1" - }, - { - "name": "全部", - "value": null - } - ], - "sortable": true, - "type": "select", - "value": null - }, - { - "label": "归属专区", - "link": "category", - "name": "parent_id", - "type": "tree", - "value": "name" - }, - { - "label": "关联部门", - "link": "org", - "name": "org_id", - "type": "tree", - "value": "name" - } - ], - "table": "category" - }, - "ctg_order_date": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "must": false, - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "must": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "must": false, - "name": "modify_time", - "type": "time" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "预约日期", - "name": "date", - "type": "time" - }, - { - "label": "排号起始数", - "name": "start_sn", - "sortable": true, - "type": "number" - }, - { - "label": "排号结束号", - "name": "max_sn", - "sortable": true, - "type": "number" - }, - { - "label": "当前排号", - "name": "now_sn", - "sortable": true, - "type": "number" - }, - { - "label": "类别", - "link": "category", - "name": "category_id", - "sortable": true, - "type": "number", - "value": "name" - } - ], - "label": "排号计划", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "类别", - "link": "category", - "name": "category_id", - "type": "tree", - "value": "name" - } - ], - "table": "ctg_order_date" - }, - "order": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "must": false, - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "must": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "must": false, - "name": "modify_time", - "type": "time" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "预约用户", - "link": "user", - "name": "user_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "预约日期", - "name": "date", - "type": "time" - }, - { - "label": "排号", - "name": "sn", - "sortable": true, - "type": "number" - }, - { - "label": "预约分类", - "link": "category", - "name": "category_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "预约状态", - "must": true, - "name": "status", - "options": [ - { - "name": "待分配", - "value": "0" - }, - { - "name": "待办结", - "value": "1" - }, - { - "name": "已办结", - "value": "2" - }, - { - "name": "已逾期", - "value": "3" - }, - { - "name": "异常", - "value": "4" - } - ], - "type": "select" - }, - { - "label": "办事员", - "link": "admin", - "name": "admin_id", - "sortable": true, - "type": "number", - "value": "name" - } - ], - "label": "预约管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "预约状态", - "must": true, - "name": "status", - "options": [ - { - "name": "待分配", - "value": "0" - }, - { - "name": "待办结", - "value": "1" - }, - { - "name": "已办结", - "value": "2" - }, - { - "name": "已逾期", - "value": "3" - }, - { - "name": "异常", - "value": "4" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "预约分类", - "link": "category", - "name": "category_id", - "type": "tree", - "value": "name" - } - ], - "table": "order" - }, - "org": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "must": false, - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "编号", - "name": "sn", - "type": "text" - }, - { - "label": "组织名称", - "name": "name", - "type": "text" - }, - { - "label": "上级组织", - "link": "org", - "must": false, - "name": "parent_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "add": false, - "edit": false, - "label": "注册时间", - "list": false, - "must": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "must": false, - "name": "modify_time", - "type": "time" - }, - { - "label": "创建用户", - "link": "admin", - "name": "admin_id", - "sortable": true, - "type": "number", - "value": "name" - }, - { - "add": false, - "edit": false, - "info": false, - "label": "索引 格式为逗号分隔,1,2,", - "list": false, - "must": false, - "name": "index", - "notUse": true, - "type": "index" - } - ], - "label": "部门管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - }, - { - "label": "上级组织", - "link": "org", - "name": "parent_id", - "type": "tree", - "value": "name" - } - ], - "table": "org" - }, - "role": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "must": false, - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "名称", - "name": "name", - "type": "text" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "must": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "must": false, - "name": "modify_time", - "type": "time" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "规则", - "name": "rule", - "type": "text" - } - ], - "label": "角色管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "已启用", - "value": "0" - }, - { - "name": "未启用", - "value": "1" - }, - { - "name": "异常", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - } - ], - "table": "role" - }, - "user": { - "auth": [ - "add", - "delete", - "edit", - "info" - ], - "columns": [ - { - "add": false, - "edit": false, - "label": "ID", - "must": false, - "name": "id", - "sortable": true, - "type": "number" - }, - { - "label": "编号", - "name": "sn", - "type": "text" - }, - { - "label": "用户姓名", - "name": "name", - "type": "text" - }, - { - "label": "手机号码", - "name": "phone", - "type": "text" - }, - { - "label": "邮箱", - "list": false, - "must": false, - "name": "idcard", - "type": "text" - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "正常", - "value": "0" - }, - { - "name": "异常", - "value": "1" - }, - { - "name": "隐藏", - "value": "2" - } - ], - "type": "select" - }, - { - "label": "头像", - "list": false, - "must": false, - "name": "avatar", - "type": "image" - }, - { - "add": false, - "edit": false, - "label": "创建时间", - "list": false, - "must": false, - "name": "create_time", - "type": "time" - }, - { - "add": false, - "edit": false, - "label": "变更时间", - "must": false, - "name": "modify_time", - "type": "time" - } - ], - "label": "群众管理", - "search": [ - { - "label": "请输入关键词", - "name": "keyword", - "type": "search", - "value": null - }, - { - "label": "时间段", - "name": "daterange", - "type": "search", - "value": null - }, - { - "label": "排序", - "name": "sort", - "type": "search", - "value": null - }, - { - "label": "状态", - "list": false, - "must": true, - "name": "state", - "options": [ - { - "name": "正常", - "value": "0" - }, - { - "name": "异常", - "value": "1" - }, - { - "name": "隐藏", - "value": "2" - }, - { - "name": "全部", - "value": null - } - ], - "type": "select", - "value": null - } - ], - "table": "user" - } - } -} \ No newline at end of file diff --git a/example/config/config.json b/example/config/config.json index 07098f6..c979a6b 100644 --- a/example/config/config.json +++ b/example/config/config.json @@ -47,5 +47,6 @@ "sessionName": "HOTIME", "smsKey": "b0eb4bf0198b9983cffcb85b69fdf4fa", "smsLogin": "【恩易办】您的验证码为:{code},请在5分钟内使用,切勿将验证码泄露于他人,如非本人操作请忽略。", + "smsNotice": "【恩易办】你收到一条新的预约事项,{name}预约办理{ctg}事项,预约办理时间:{date},排号:{sn}。", "tpt": "tpt" } \ No newline at end of file diff --git a/example/main.go b/example/main.go index 7177442..17c95d3 100644 --- a/example/main.go +++ b/example/main.go @@ -3,6 +3,7 @@ package main import ( "../../hotime" "../../hotime/common" + "../dri/ddsms" "./admin" "./app" "fmt" @@ -140,6 +141,9 @@ func main() { //makeCode := code.MakeCode{} //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{ "admin": admin.Project,