Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7131603c4 | |||
| 2f3a5a0a59 | |||
| c2468a7389 | |||
| b6ba3486d6 | |||
| f59e909d30 | |||
| 3bb47de45a | |||
| c71973850e | |||
| 65f062b860 | |||
| 7b502fed36 | |||
| fd6b15bdaf | |||
| f31bf24ec2 | |||
| 30edb4d9fa | |||
| a32c3a1589 | |||
| 127e027940 | |||
| 2ee0838d8a | |||
| 72c23499f2 | |||
| 96d8868694 | |||
| 1533a57cb8 | |||
| 615f52d2e4 | |||
| f7dfd4ec77 | |||
| 2276aa12ef | |||
| 6505594fd0 | |||
| c55e26021b | |||
| 78420a692f | |||
| 6d9af149ad |
+24
-18
@@ -357,14 +357,18 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) {
|
||||
defer func() {
|
||||
//是否展示日志
|
||||
if that.WebConnectLog != nil {
|
||||
ipStr := Substr(context.Req.RemoteAddr, 0, strings.Index(context.Req.RemoteAddr, ":"))
|
||||
|
||||
//负载均衡优化
|
||||
if ipStr == "127.0.0.1" {
|
||||
if req.Header.Get("X-Forwarded-For") != "" {
|
||||
ipStr = req.Header.Get("X-Forwarded-For")
|
||||
} else if req.Header.Get("X-Real-IP") != "" {
|
||||
ipStr = req.Header.Get("X-Real-IP")
|
||||
}
|
||||
ipStr := ""
|
||||
if req.Header.Get("X-Forwarded-For") != "" {
|
||||
ipStr = req.Header.Get("X-Forwarded-For")
|
||||
} else if req.Header.Get("X-Real-IP") != "" {
|
||||
ipStr = req.Header.Get("X-Real-IP")
|
||||
}
|
||||
//负载均衡优化
|
||||
if ipStr == "" {
|
||||
//RemoteAddr := that.Req.RemoteAddr
|
||||
ipStr = Substr(context.Req.RemoteAddr, 0, strings.Index(context.Req.RemoteAddr, ":"))
|
||||
}
|
||||
|
||||
that.WebConnectLog.Infoln(ipStr, context.Req.Method,
|
||||
@@ -374,15 +378,17 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) {
|
||||
}()
|
||||
|
||||
//访问拦截true继续false暂停
|
||||
connectListenerLen := len(that.connectListener)
|
||||
|
||||
for i := connectListenerLen - 1; i >= 0; i-- {
|
||||
|
||||
if that.connectListener[i](&context) {
|
||||
connectListenerLen := len(that.connectListener) - 1
|
||||
|
||||
for true {
|
||||
if connectListenerLen < 0 {
|
||||
break
|
||||
}
|
||||
if that.connectListener[connectListenerLen](&context) {
|
||||
context.View()
|
||||
return
|
||||
}
|
||||
connectListenerLen--
|
||||
}
|
||||
|
||||
//接口服务
|
||||
@@ -587,9 +593,7 @@ func Init(config string) *Application {
|
||||
appIns.Router[codeMake.GetString("name")][k1] = appIns.Router[codeMake.GetString("name")]["hotimeCommon"]
|
||||
}
|
||||
|
||||
go func() {
|
||||
setMakeCodeLintener(codeMake.GetString("name"), &appIns)
|
||||
}()
|
||||
setMakeCodeListener(codeMake.GetString("name"), &appIns)
|
||||
|
||||
}
|
||||
|
||||
@@ -659,7 +663,7 @@ func SetSqliteDB(appIns *Application, config Map) {
|
||||
})
|
||||
}
|
||||
|
||||
func setMakeCodeLintener(name string, appIns *Application) {
|
||||
func setMakeCodeListener(name string, appIns *Application) {
|
||||
appIns.SetConnectListener(func(context *Context) (isFinished bool) {
|
||||
|
||||
codeIns := appIns.MakeCodeRouter[name]
|
||||
@@ -679,7 +683,9 @@ func setMakeCodeLintener(name string, appIns *Application) {
|
||||
if context.RouterString[1] == "hotime" && context.RouterString[2] == "config" {
|
||||
return isFinished
|
||||
}
|
||||
|
||||
if context.RouterString[1] == "hotime" && context.RouterString[2] == "wallpaper" {
|
||||
return isFinished
|
||||
}
|
||||
if context.Session(codeIns.FileConfig.GetString("table")+"_id").Data == nil {
|
||||
context.Display(2, "你还没有登录")
|
||||
return true
|
||||
@@ -753,7 +759,7 @@ func setMakeCodeLintener(name string, appIns *Application) {
|
||||
context.Router[context.RouterString[0]][context.RouterString[1]]["remove"](context)
|
||||
}
|
||||
|
||||
context.View()
|
||||
//context.View()
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/360EntSecGroup-Skylar/excelize"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -96,12 +97,12 @@ var TptProject = Proj{
|
||||
|
||||
for _, v := range that.MakeCodeRouter[hotimeName].TableColumns[fileConfig.GetString("table")] {
|
||||
if v.GetString("link") != "" {
|
||||
|
||||
//与用户信息有关联的parent_id自填充
|
||||
if v.GetString("link") == tableName && that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["parent_id"] != nil {
|
||||
if inData["parent_id"] == nil && data[v.GetString("name")] != nil {
|
||||
inData["parent_id"] = data.GetCeilInt64(v.GetString("name"))
|
||||
pre := that.Db.Get(v.GetString("link"), "parent_ids", Map{"id": data.GetCeilInt64(v.GetString("name"))})
|
||||
inData["parent_ids"] = pre.GetString("parent_ids")
|
||||
//pre := that.Db.Get(v.GetString("link"), "parent_ids", Map{"id": data.GetCeilInt64(v.GetString("name"))})
|
||||
//inData["parent_ids"] = pre.GetString("parent_ids")+ObjToStr(data.GetCeilInt64(v.GetString("name")))+","
|
||||
}
|
||||
|
||||
}
|
||||
@@ -128,15 +129,18 @@ var TptProject = Proj{
|
||||
name = v1.GetString("table")
|
||||
}
|
||||
if v1["auth"] != nil {
|
||||
linkAuth[name] = v1["auth"]
|
||||
|
||||
}
|
||||
if v1["auth"] == nil {
|
||||
table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)
|
||||
if table != nil {
|
||||
linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"]
|
||||
if linkAuth[name] == nil {
|
||||
linkAuth[name] = v1["auth"]
|
||||
} else {
|
||||
linkAuth[name] = Slice{"show"}
|
||||
newAuth := Slice{}
|
||||
for k2, _ := range linkAuth.GetSlice(name) {
|
||||
v2 := linkAuth.GetSlice(name).GetString(k2)
|
||||
if strings.Contains(v1.GetString("auth"), v2) {
|
||||
newAuth = append(newAuth, v2)
|
||||
}
|
||||
}
|
||||
linkAuth[name] = newAuth
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,15 +152,22 @@ var TptProject = Proj{
|
||||
name = v2.GetString("table")
|
||||
}
|
||||
if v2["auth"] != nil {
|
||||
linkAuth[name] = v2["auth"]
|
||||
continue
|
||||
}
|
||||
if v2["auth"] == nil {
|
||||
table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)
|
||||
if table != nil {
|
||||
linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"]
|
||||
|
||||
if linkAuth[name] == nil {
|
||||
linkAuth[name] = v2["auth"]
|
||||
|
||||
} else {
|
||||
linkAuth[name] = Slice{"show"}
|
||||
|
||||
newAuth := Slice{}
|
||||
for k3, _ := range linkAuth.GetSlice(name) {
|
||||
v3 := linkAuth.GetSlice(name).GetString(k3)
|
||||
if strings.Contains(v2.GetString("auth"), v3) {
|
||||
newAuth = append(newAuth, v3)
|
||||
}
|
||||
}
|
||||
linkAuth[name] = newAuth
|
||||
continue
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,14 +210,16 @@ var TptProject = Proj{
|
||||
return
|
||||
}
|
||||
//索引管理,便于检索以及权限
|
||||
if inData.Get("parent_id") != nil && inData.GetString("parent_ids") != "" {
|
||||
if inData.Get("parent_id") != nil {
|
||||
index := that.Db.Get(tableName, "`parent_ids`", Map{"id": inData.Get("parent_id")})
|
||||
inData["parent_ids"] = index.GetString("parent_ids") + ObjToStr(re) + ","
|
||||
that.Db.Update(tableName, Map{"parent_ids": inData["parent_ids"]}, Map{"id": re})
|
||||
} else if inData.GetString("parent_ids") != "" {
|
||||
inData["parent_ids"] = "," + ObjToStr(re) + ","
|
||||
parent_ids := index.GetString("parent_ids")
|
||||
if parent_ids == "" {
|
||||
parent_ids = ","
|
||||
}
|
||||
inData["parent_ids"] = parent_ids + ObjToStr(re) + ","
|
||||
that.Db.Update(tableName, Map{"parent_ids": inData["parent_ids"]}, Map{"id": re})
|
||||
}
|
||||
|
||||
that.Log["table_id"] = re
|
||||
that.Display(0, re)
|
||||
},
|
||||
@@ -257,48 +270,59 @@ var TptProject = Proj{
|
||||
if v.GetString("link") != "" && that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["auth"] != nil {
|
||||
linkAuthMap := that.Db.Get(v.GetString("link"), "auth", Map{"id": data.GetCeilInt(v.GetString("name"))})
|
||||
linkAuth := linkAuthMap.GetMap("auth")
|
||||
|
||||
//conf := ObjToMap(string(btes))
|
||||
//menus := conf.GetSlice("menus")
|
||||
if linkAuth == nil {
|
||||
|
||||
linkAuth = Map{}
|
||||
for k1, _ := range menus {
|
||||
v1 := menus.GetMap(k1)
|
||||
name := v1.GetString("name")
|
||||
if name == "" {
|
||||
name = v1.GetString("table")
|
||||
}
|
||||
if v1["auth"] != nil {
|
||||
linkAuth[name] = v1["auth"]
|
||||
continue
|
||||
}
|
||||
if v1["auth"] == nil {
|
||||
}
|
||||
|
||||
table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)
|
||||
if table != nil {
|
||||
linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"]
|
||||
} else {
|
||||
linkAuth[name] = Slice{"show"}
|
||||
}
|
||||
}
|
||||
menusChild := v1.GetSlice("menus")
|
||||
for k2, _ := range menusChild {
|
||||
v2 := menusChild.GetMap(k2)
|
||||
name := v2.GetString("name")
|
||||
if name == "" {
|
||||
name = v2.GetString("table")
|
||||
}
|
||||
if v2["auth"] != nil {
|
||||
linkAuth[name] = v2["auth"]
|
||||
continue
|
||||
}
|
||||
if v2["auth"] == nil {
|
||||
table := that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)
|
||||
if table != nil {
|
||||
linkAuth[name] = that.MakeCodeRouter[hotimeName].TableConfig.GetMap(name)["auth"]
|
||||
} else {
|
||||
linkAuth[name] = Slice{"show"}
|
||||
for k1, _ := range menus {
|
||||
v1 := menus.GetMap(k1)
|
||||
name := v1.GetString("name")
|
||||
if name == "" {
|
||||
name = v1.GetString("table")
|
||||
}
|
||||
if v1["auth"] != nil {
|
||||
|
||||
if linkAuth[name] == nil {
|
||||
linkAuth[name] = v1["auth"]
|
||||
} else {
|
||||
newAuth := Slice{}
|
||||
for k2, _ := range linkAuth.GetSlice(name) {
|
||||
v2 := linkAuth.GetSlice(name).GetString(k2)
|
||||
if strings.Contains(v1.GetString("auth"), v2) {
|
||||
newAuth = append(newAuth, v2)
|
||||
}
|
||||
}
|
||||
linkAuth[name] = newAuth
|
||||
}
|
||||
}
|
||||
|
||||
menusChild := v1.GetSlice("menus")
|
||||
for k2, _ := range menusChild {
|
||||
v2 := menusChild.GetMap(k2)
|
||||
name := v2.GetString("name")
|
||||
if name == "" {
|
||||
name = v2.GetString("table")
|
||||
}
|
||||
if v2["auth"] != nil {
|
||||
|
||||
if linkAuth[name] == nil {
|
||||
linkAuth[name] = v2["auth"]
|
||||
|
||||
} else {
|
||||
|
||||
newAuth := Slice{}
|
||||
for k3, _ := range linkAuth.GetSlice(name) {
|
||||
v3 := linkAuth.GetSlice(name).GetString(k3)
|
||||
if strings.Contains(v2.GetString("auth"), v3) {
|
||||
newAuth = append(newAuth, v3)
|
||||
}
|
||||
}
|
||||
linkAuth[name] = newAuth
|
||||
continue
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -333,21 +357,23 @@ var TptProject = Proj{
|
||||
|
||||
}
|
||||
|
||||
//索引管理,便于检索以及权限
|
||||
if inData.GetString("parent_ids") != "" {
|
||||
if inData.Get("parent_id") != nil {
|
||||
Index := that.Db.Get(tableName, "`index`", Map{"id": that.RouterString[2]})
|
||||
parentIndex := that.Db.Get(tableName, "`index`", Map{"id": inData.Get("parent_id")})
|
||||
inData["parent_ids"] = parentIndex.GetString("parent_ids") + that.RouterString[2] + ","
|
||||
|
||||
childNodes := that.Db.Select(tableName, "id,`index``", Map{"index[~]": "," + that.RouterString[2] + ","})
|
||||
|
||||
if inData.Get("parent_id") != nil {
|
||||
//1
|
||||
//12 62
|
||||
//123 623
|
||||
Index := that.Db.Get(tableName, "parent_id,`parent_ids`", Map{"id": that.RouterString[2]})
|
||||
if inData.GetCeilInt64("parent_id") != Index.GetCeilInt64("parent_id") {
|
||||
parentIndex := that.Db.Get(tableName, "`parent_ids`", Map{"id": inData.Get("parent_id")})
|
||||
if strings.Contains(parentIndex.GetString("parent_ids"), ","+that.RouterString[2]+",") {
|
||||
that.Display(4, "不能将子级设置为父级")
|
||||
return
|
||||
}
|
||||
parent_ids := parentIndex.GetString("parent_ids") + that.RouterString[2] + ","
|
||||
childNodes := that.Db.Select(tableName, "id,`parent_ids`", Map{"parent_ids[~]": "," + that.RouterString[2] + ","})
|
||||
for _, v := range childNodes {
|
||||
v["parent_ids"] = strings.Replace(v.GetString("parent_ids"), Index.GetString("parent_ids"), inData.GetString("parent_ids"), -1)
|
||||
v["parent_ids"] = strings.Replace(v.GetString("parent_ids"), Index.GetString("parent_ids"), parent_ids, -1)
|
||||
that.Db.Update(tableName, Map{"parent_ids": v["parent_ids"]}, Map{"id": v.GetCeilInt("id")})
|
||||
}
|
||||
} else {
|
||||
delete(inData, "parent_ids")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -359,21 +385,18 @@ var TptProject = Proj{
|
||||
return
|
||||
}
|
||||
|
||||
//索引管理,便于检索以及权限
|
||||
that.Display(0, re)
|
||||
},
|
||||
"remove": func(that *Context) {
|
||||
tableName := that.RouterString[1]
|
||||
that.Log = Map{"table": tableName, "type": 3, "table_id": that.RouterString[2]}
|
||||
hotimeName := that.RouterString[0]
|
||||
inData := that.MakeCodeRouter[hotimeName].Delete(tableName, that.Req)
|
||||
if inData == nil {
|
||||
that.Display(3, "请求参数不足")
|
||||
return
|
||||
}
|
||||
|
||||
re := int64(0)
|
||||
//索引管理,便于检索以及权限
|
||||
if inData.Get("parent_id") != nil && inData.GetSlice("parent_ids") != nil {
|
||||
re = that.Db.Delete(tableName, Map{"index[~]": "," + that.RouterString[2] + ","})
|
||||
//有索引则删除对应的参数
|
||||
if that.MakeCodeRouter[hotimeName].TableColumns[tableName]["parent_id"] != nil {
|
||||
re = that.Db.Delete(tableName, Map{"parent_ids[~]": "," + that.RouterString[2] + ","})
|
||||
} else {
|
||||
re = that.Db.Delete(tableName, Map{"id": that.RouterString[2]})
|
||||
}
|
||||
@@ -885,6 +908,53 @@ var TptProject = Proj{
|
||||
|
||||
that.Display(0, conf)
|
||||
},
|
||||
//壁纸
|
||||
"wallpaper": func(that *Context) {
|
||||
random := ObjToCeilInt(that.Req.FormValue("random")) //壁纸随机,0为默认,1,为随机
|
||||
|
||||
tp := ObjToCeilInt(that.Req.FormValue("type")) //返回类型,0,json,1,302跳转到图片
|
||||
|
||||
images := that.Application.Cache("wallpaper").ToSlice()
|
||||
if images == nil || len(images) == 0 {
|
||||
|
||||
url := "https://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=7&mkt=zh-CN"
|
||||
res, e := http.Get(url)
|
||||
if e != nil {
|
||||
that.Display(4, "无法取得数据0")
|
||||
return
|
||||
}
|
||||
defer res.Body.Close()
|
||||
b, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
that.Display(4, "无法取得数据1")
|
||||
return
|
||||
}
|
||||
w := ObjToMap(string(b))
|
||||
if len(w) == 0 {
|
||||
that.Display(4, "无法取得数据2")
|
||||
return
|
||||
}
|
||||
|
||||
images = w.GetSlice("images")
|
||||
that.Application.Cache("wallpaper", images)
|
||||
}
|
||||
if random == 1 {
|
||||
random = RandX(0, len(images)-1)
|
||||
}
|
||||
|
||||
img := images.GetMap(random)
|
||||
if !strings.Contains(img.GetString("url"), "http") {
|
||||
img["url"] = "https://cn.bing.com" + img.GetString("url")
|
||||
}
|
||||
if tp == 0 {
|
||||
that.Display(0, img)
|
||||
return
|
||||
}
|
||||
|
||||
that.Resp.Header().Set("Location", img.GetString("url"))
|
||||
that.Resp.WriteHeader(302)
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
+306
-246
@@ -43,20 +43,6 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
||||
that.Config = DeepCopyMap(Config).(Map)
|
||||
|
||||
that.Config["name"] = config.GetString("table")
|
||||
//if err == nil {
|
||||
// cmap := Map{}
|
||||
// //文件是否损坏
|
||||
// cmap.JsonToMap(string(btes), &that.Error)
|
||||
// for k, v := range cmap {
|
||||
// that.Config[k] = v //程序配置
|
||||
// //Config[k] = v //系统配置
|
||||
// }
|
||||
// hasConfigFile = true
|
||||
//} else {
|
||||
//
|
||||
// that.Error.SetError(errors.New("config配置文件不存在,或者配置出错,使用缺省默认配置"))
|
||||
//
|
||||
//}
|
||||
//加载规则文件
|
||||
btesRule, errRule := ioutil.ReadFile(config.GetString("rule"))
|
||||
that.RuleConfig = []Map{}
|
||||
@@ -147,7 +133,8 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
||||
"auth": []string{"show", "add", "delete", "edit", "info", "download"},
|
||||
"columns": []Map{},
|
||||
"search": []Map{
|
||||
|
||||
{"type": "search", "name": "keywordtable", "label": "筛选", "options": Slice{Map{"name": "无", "value": nil}}, "value": nil},
|
||||
{"type": "search", "name": "daterangetable", "label": "筛选", "options": Slice{Map{"name": "无", "value": nil}}, "value": nil},
|
||||
{"type": "search", "name": "keyword", "label": "请输入关键词", "value": nil},
|
||||
{"type": "search", "name": "daterange", "label": "时间段", "value": nil},
|
||||
{"type": "search", "name": "sort", "label": "排序", "value": nil},
|
||||
@@ -206,6 +193,12 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
||||
if indexNum > -1 {
|
||||
coloum["label"] = info.GetString("label")[:indexNum]
|
||||
}
|
||||
psStart := strings.Index(info.GetString("label"), "{")
|
||||
psEnd := strings.Index(info.GetString("label"), "}")
|
||||
if psStart != -1 && psEnd > psStart {
|
||||
coloum["ps"] = info.GetString("label")[psStart+1 : psEnd]
|
||||
}
|
||||
|
||||
//去除数据信息,是用:号分割的
|
||||
indexNum = strings.Index(coloum.GetString("label"), ":")
|
||||
if indexNum > -1 {
|
||||
@@ -332,21 +325,6 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
||||
//数据生成完后进一步解析
|
||||
for fk, fv := range that.TableColumns {
|
||||
|
||||
//判断是否将表写入menu中
|
||||
//isMenusGet := false //判断是否被目录收录
|
||||
//for indexKey, _ := range that.IndexMenus {
|
||||
// indexCode := strings.Index(indexKey, fk)
|
||||
// if indexCode == 0 || indexCode == 4 {
|
||||
// isMenusGet = false
|
||||
// continue
|
||||
// }
|
||||
// //如果相等或者表名在目录中已经设置(主要前一位是/并且他是最后一个字符串)
|
||||
// if indexKey == fk || (indexCode != -1 && indexKey[indexCode-1] == '/' && indexKey[indexCode:] == fk) {
|
||||
// isMenusGet = true
|
||||
// break
|
||||
// }
|
||||
//}
|
||||
|
||||
//目录没有收录
|
||||
//if !isMenusGet {
|
||||
//if !hasConfigFile {
|
||||
@@ -373,12 +351,12 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
||||
|
||||
menuIns := Map{"label": that.TableConfig.GetMap(fk).GetString("label"), "table": fk, "auth": that.TableConfig.GetMap(fk).GetSlice("auth")}
|
||||
//多耗费一点内存
|
||||
mMenu := Map{"menus": Slice{menuIns}, "auth": Slice{"show"}, "label": that.TableConfig.GetMap(fk).GetString("label"), "name": prefixName, "icon": "el-icon-setting"}
|
||||
mMenu := Map{"menus": Slice{menuIns}, "auth": Slice{"show"}, "label": that.TableConfig.GetMap(fk).GetString("label"), "name": prefixName, "icon": "Setting"}
|
||||
//表名有前缀
|
||||
if !isNewPrefix {
|
||||
//是否已有对应前缀,已经有对应的menu只需要push进去即可
|
||||
prefixName = DefaultMenuParentName
|
||||
mMenu = Map{"menus": Slice{menuIns}, "auth": Slice{"show"}, "label": "系统管理", "name": prefixName, "icon": "el-icon-setting"}
|
||||
mMenu = Map{"menus": Slice{menuIns}, "auth": Slice{"show"}, "label": "系统管理", "name": prefixName, "icon": "Setting"}
|
||||
}
|
||||
//没有新前缀
|
||||
if that.IndexMenus[prefixName] != nil {
|
||||
@@ -399,103 +377,129 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
|
||||
that.IndexMenus[prefixName+"/"+fk] = menuIns
|
||||
}
|
||||
//}
|
||||
|
||||
search := that.TableConfig.GetMap(fk).GetSlice("search")
|
||||
for k, v := range fv {
|
||||
|
||||
//虚招后缀是_id结尾的表字段 假设org_id
|
||||
if !(len(k) <= 3 || strings.LastIndex(k, "_id") != len(k)-3) {
|
||||
//普通表匹配 org_id匹配为org
|
||||
oldTableName := k[:len(k)-3]
|
||||
//上级ID匹配
|
||||
if oldTableName == "parent" {
|
||||
oldTableName = fk
|
||||
}
|
||||
//如果本身匹配则不再继续精简匹配
|
||||
if that.TableConfig[oldTableName] == nil {
|
||||
|
||||
//如果依然找不到则查询system_org是否存在
|
||||
if that.TableConfig[DefaultMenuParentName+"_"+oldTableName] != nil {
|
||||
oldTableName = DefaultMenuParentName + "_" + oldTableName
|
||||
}
|
||||
|
||||
//字段有动词前缀,自动进行解析
|
||||
prefixColumn := strings.Index(oldTableName, "_")
|
||||
|
||||
//sys_org_id oldTableName即为sys此处判断为org表存在
|
||||
|
||||
if prefixColumn > -1 && that.TableConfig[oldTableName[prefixColumn+1:]] != nil {
|
||||
oldTableName = oldTableName[prefixColumn+1:]
|
||||
}
|
||||
if prefixColumn >= len(oldTableName) {
|
||||
prefixColumn = -1
|
||||
}
|
||||
//如果依然找不到则查询system_org是否存在
|
||||
if prefixColumn > -1 && that.TableConfig[DefaultMenuParentName+"_"+oldTableName[prefixColumn+1:]] != nil {
|
||||
oldTableName = DefaultMenuParentName + "_" + oldTableName[prefixColumn+1:]
|
||||
}
|
||||
}
|
||||
|
||||
//普通方式查询不到,则转换为大型项目模块划分,暂时只支持一级模块划分,
|
||||
//比如表sys_user 字段org_id,查询不到sys_org表则查询org表,org表查询不到则查询默认前缀system_org表
|
||||
//都查询不到则找不到,
|
||||
prefix := strings.Index(fk, "_")
|
||||
tableName := oldTableName
|
||||
if prefix > 0 {
|
||||
//表模块前缀sys_user sys即为前缀 sys_org
|
||||
tableName = fk[:prefix+1] + oldTableName
|
||||
if that.TableConfig[tableName] == nil || that.TableConfig[oldTableName] != nil {
|
||||
//不存在则改为org
|
||||
tableName = oldTableName
|
||||
}
|
||||
//表前缀+去除字段前缀
|
||||
prefixColumn := strings.Index(oldTableName, "_")
|
||||
if prefixColumn > -1 {
|
||||
tableName = fk[:prefix+1] + oldTableName[prefixColumn+1:]
|
||||
if that.TableConfig[tableName] == nil {
|
||||
tableName = oldTableName
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//如果数据匹配则写入到配置中
|
||||
if that.TableConfig[tableName] != nil {
|
||||
v["link"] = tableName
|
||||
//一般查询name字段或者label字段,如果没有name字段则默认第二个地段
|
||||
if that.TableColumns[tableName]["name"] != nil {
|
||||
v["value"] = "name"
|
||||
continue
|
||||
}
|
||||
if that.TableColumns[tableName]["label"] != nil {
|
||||
v["value"] = "label"
|
||||
continue
|
||||
}
|
||||
tempC := that.TableConfig.GetMap(tableName).GetSlice("columns")
|
||||
isGet := true
|
||||
for k2, _ := range tempC {
|
||||
if strings.Contains(tempC.GetMap(k2).GetString("name"), "name") || strings.Contains(tempC.GetMap(k2).GetString("name"), "title") {
|
||||
v["value"] = tempC.GetMap(k2).GetString("name")
|
||||
isGet = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if isGet && len(that.TableConfig.GetMap(tableName).GetSlice("columns")) > 2 {
|
||||
v["value"] = that.TableConfig.GetMap(tableName).GetSlice("columns").GetMap(1).GetString("name")
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//搜索服务
|
||||
if that.SearchColumns[fk][v.GetString("name")] == nil &&
|
||||
v.GetString("type") == "select" {
|
||||
search := that.TableConfig.GetMap(fk).GetSlice("search")
|
||||
//search := that.TableConfig.GetMap(fk).GetSlice("search")
|
||||
sv := DeepCopyMap(v).(Map)
|
||||
sv["value"] = nil
|
||||
sv["options"] = append(sv.GetSlice("options"), Map{"name": "全部", "value": nil})
|
||||
that.TableConfig.GetMap(fk)["search"] = append(search, sv)
|
||||
search = append(search, sv)
|
||||
that.TableConfig.GetMap(fk)["search"] = search
|
||||
that.SearchColumns[fk][k] = sv
|
||||
}
|
||||
|
||||
//虚招后缀是_id结尾的表字段 假设org_id
|
||||
if len(k) <= 3 || strings.LastIndex(k, "_id") != len(k)-3 {
|
||||
continue
|
||||
//搜索关键字
|
||||
if strings.Contains(v.GetString("type"), "text") || v.GetString("name") == "id" {
|
||||
keyWordSearchData := search.GetMap(0)
|
||||
|
||||
keyWordSearchData["options"] = append(keyWordSearchData.GetSlice("options"), Map{"name": v.GetString("label"), "value": v.GetString("name")})
|
||||
search[0] = keyWordSearchData
|
||||
}
|
||||
//普通表匹配 org_id匹配为org
|
||||
oldTableName := k[:len(k)-3]
|
||||
//上级ID匹配
|
||||
if oldTableName == "parent" {
|
||||
oldTableName = fk
|
||||
}
|
||||
//如果本身匹配则不再继续精简匹配
|
||||
if that.TableConfig[oldTableName] == nil {
|
||||
if v.GetString("link") != "" &&
|
||||
v.GetString("name") != "parent_id" {
|
||||
|
||||
//如果依然找不到则查询system_org是否存在
|
||||
if that.TableConfig[DefaultMenuParentName+"_"+oldTableName] != nil {
|
||||
oldTableName = DefaultMenuParentName + "_" + oldTableName
|
||||
}
|
||||
|
||||
//字段有动词前缀,自动进行解析
|
||||
prefixColumn := strings.Index(oldTableName, "_")
|
||||
|
||||
//sys_org_id oldTableName即为sys此处判断为org表存在
|
||||
|
||||
if prefixColumn > -1 && that.TableConfig[oldTableName[prefixColumn+1:]] != nil {
|
||||
oldTableName = oldTableName[prefixColumn+1:]
|
||||
}
|
||||
if prefixColumn >= len(oldTableName) {
|
||||
prefixColumn = -1
|
||||
}
|
||||
//如果依然找不到则查询system_org是否存在
|
||||
if prefixColumn > -1 && that.TableConfig[DefaultMenuParentName+"_"+oldTableName[prefixColumn+1:]] != nil {
|
||||
oldTableName = DefaultMenuParentName + "_" + oldTableName[prefixColumn+1:]
|
||||
}
|
||||
keyWordSearchData := search.GetMap(0)
|
||||
name := strings.Replace(that.TableConfig.GetMap(v.GetString("link")).GetString("label"), "管理", "", -1)
|
||||
keyWordSearchData["options"] = append(keyWordSearchData.GetSlice("options"), Map{"name": name, "value": v.GetString("name")})
|
||||
search[0] = keyWordSearchData
|
||||
}
|
||||
|
||||
//普通方式查询不到,则转换为大型项目模块划分,暂时只支持一级模块划分,
|
||||
//比如表sys_user 字段org_id,查询不到sys_org表则查询org表,org表查询不到则查询默认前缀system_org表
|
||||
//都查询不到则找不到,
|
||||
prefix := strings.Index(fk, "_")
|
||||
tableName := oldTableName
|
||||
if prefix > 0 {
|
||||
//表模块前缀sys_user sys即为前缀 sys_org
|
||||
tableName = fk[:prefix+1] + oldTableName
|
||||
if that.TableConfig[tableName] == nil || that.TableConfig[oldTableName] != nil {
|
||||
//不存在则改为org
|
||||
tableName = oldTableName
|
||||
}
|
||||
//表前缀+去除字段前缀
|
||||
prefixColumn := strings.Index(oldTableName, "_")
|
||||
if prefixColumn > -1 {
|
||||
tableName = fk[:prefix+1] + oldTableName[prefixColumn+1:]
|
||||
if that.TableConfig[tableName] == nil {
|
||||
tableName = oldTableName
|
||||
}
|
||||
}
|
||||
}
|
||||
//搜索时间
|
||||
if strings.Contains(v.GetString("type"), "time") {
|
||||
daterangeData := search.GetMap(1)
|
||||
|
||||
//如果数据匹配则写入到配置中
|
||||
if that.TableConfig[tableName] != nil {
|
||||
v["link"] = tableName
|
||||
//一般查询name字段或者label字段,如果没有name字段则默认第二个地段
|
||||
if that.TableColumns[tableName]["name"] != nil {
|
||||
v["value"] = "name"
|
||||
continue
|
||||
}
|
||||
if that.TableColumns[tableName]["label"] != nil {
|
||||
v["value"] = "label"
|
||||
continue
|
||||
}
|
||||
tempC := that.TableConfig.GetMap(tableName).GetSlice("columns")
|
||||
isGet := true
|
||||
for k2, _ := range tempC {
|
||||
if strings.Contains(tempC.GetMap(k2).GetString("name"), "name") || strings.Contains(tempC.GetMap(k2).GetString("name"), "title") {
|
||||
v["value"] = tempC.GetMap(k2).GetString("name")
|
||||
isGet = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if isGet && len(that.TableConfig.GetMap(tableName).GetSlice("columns")) > 2 {
|
||||
v["value"] = that.TableConfig.GetMap(tableName).GetSlice("columns").GetMap(1).GetString("name")
|
||||
continue
|
||||
}
|
||||
daterangeData["options"] = append(daterangeData.GetSlice("options"), Map{"name": v.GetString("label"), "value": v.GetString("name")})
|
||||
search[1] = daterangeData
|
||||
|
||||
}
|
||||
|
||||
@@ -727,15 +731,18 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map {
|
||||
for _, v := range that.TableColumns[table] {
|
||||
//不可使用,未在前端展示,但在内存中保持有
|
||||
if v.GetBool("notUse") {
|
||||
if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
||||
data[v.GetString("name")] = ","
|
||||
}
|
||||
//if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
||||
// data[v.GetString("name")] = ","
|
||||
//}
|
||||
continue
|
||||
}
|
||||
|
||||
if v.Get("edit") == nil || v.GetBool("edit") {
|
||||
if len(req.Form[v.GetString("name")]) == 0 {
|
||||
continue
|
||||
}
|
||||
reqValue := req.FormValue(v.GetString("name"))
|
||||
if reqValue == "" || reqValue == "null" {
|
||||
if reqValue == "null" {
|
||||
continue
|
||||
}
|
||||
if v.GetString("type") == "password" {
|
||||
@@ -763,16 +770,16 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map {
|
||||
}
|
||||
func (that *MakeCode) Delete(table string, req *http.Request) Map {
|
||||
data := Map{}
|
||||
for _, v := range that.TableColumns[table] {
|
||||
//不可使用,未在前端展示,但在内存中保持有
|
||||
if v.GetBool("notUse") {
|
||||
if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
||||
data[v.GetString("name")] = ","
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
//for _, v := range that.TableColumns[table] {
|
||||
// //不可使用,未在前端展示,但在内存中保持有
|
||||
// if v.GetBool("notUse") {
|
||||
// //if v.GetString("type") == "index" && that.TableColumns[table]["parent_id"] != nil {
|
||||
// // data[v.GetString("name")] = ","
|
||||
// //}
|
||||
// continue
|
||||
// }
|
||||
//
|
||||
//}
|
||||
return data
|
||||
}
|
||||
|
||||
@@ -787,6 +794,8 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
hasUser := false
|
||||
|
||||
keywordStr := req.FormValue("keyword")
|
||||
keywordTableStr := req.FormValue("keywordtable")
|
||||
daterangeTableStr := req.FormValue("daterangetable")
|
||||
|
||||
testQu := []string{}
|
||||
testQuData := that.TableColumns[table]
|
||||
@@ -795,7 +804,6 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
testQu = append(testQu, key)
|
||||
}
|
||||
sort.Strings(testQu)
|
||||
|
||||
for _, k := range testQu {
|
||||
v := testQuData[k]
|
||||
//不可使用,未在前端展示,但在内存中保持有
|
||||
@@ -890,61 +898,44 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
|
||||
}
|
||||
|
||||
if v.GetString("type") == "text" {
|
||||
reqValue := req.FormValue(v.GetString("name"))
|
||||
if reqValue != "" {
|
||||
data[table+"."+v.GetString("name")+"[~]"] = reqValue
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if v.GetString("type") == "unixtime" {
|
||||
//fmt.Println(req.Form["daterange"])
|
||||
if len(req.Form[v.GetString("name")]) == 1 {
|
||||
daterange[table+"."+v.GetString("name")+"[>]"] = req.FormValue("daterange")
|
||||
} else if len(req.Form[v.GetString("name")]) == 2 {
|
||||
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||
}
|
||||
}
|
||||
|
||||
if v.GetString("type") == "time" {
|
||||
//fmt.Println(req.Form["daterange"])
|
||||
|
||||
if len(req.Form[v.GetString("name")]) == 1 {
|
||||
t := time.Unix(ObjToCeilInt64(req.FormValue(v.GetString("name"))), 0).Format("2006-01-02 15:04:05")
|
||||
|
||||
daterange[table+"."+v.GetString("name")+"[>]"] = t
|
||||
|
||||
} else if len(req.Form[v.GetString("name")]) == 2 {
|
||||
t1 := time.Unix(ObjToCeilInt64(req.Form[v.GetString("name")][0]), 0).Format("2006-01-02 15:04:05")
|
||||
t2 := time.Unix(ObjToCeilInt64(req.Form[v.GetString("name")][1]), 0).Format("2006-01-02 15:04:05")
|
||||
daterange[table+"."+v.GetString("name")+"[<>]"] = Slice{t1, t2}
|
||||
}
|
||||
}
|
||||
|
||||
if keywordStr != "" {
|
||||
if v.GetString("type") == "text" {
|
||||
keyword[table+"."+v.GetString("name")+"[~]"] = keywordStr
|
||||
|
||||
}
|
||||
if v.GetString("name") == "id" {
|
||||
keyword[table+"."+v.GetString("name")] = keywordStr
|
||||
}
|
||||
if v.GetString("link") != "" &&
|
||||
v.GetString("name") != "parent_id" {
|
||||
childs := db.Select(v.GetString("link"), "id", Map{v.GetString("value") + "[~]": keywordStr})
|
||||
childIds := Slice{}
|
||||
for _, cv := range childs {
|
||||
childIds = append(childIds, cv.GetString("id"))
|
||||
}
|
||||
if len(childIds) != 0 {
|
||||
keyword[v.GetString("link")+".id"] = childIds
|
||||
}
|
||||
|
||||
}
|
||||
if strings.Contains(v.GetString("type"), "text") {
|
||||
reqValue := req.FormValue(v.GetString("name"))
|
||||
if reqValue != "" {
|
||||
data[table+"."+v.GetString("name")+"[~]"] = reqValue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if v.GetString("type") == "unixtime" {
|
||||
|
||||
if len(req.Form[v.GetString("name")]) == 1 {
|
||||
daterange[table+"."+v.GetString("name")+"[>]"] = req.FormValue("daterange")
|
||||
} else if len(req.Form[v.GetString("name")]) == 2 {
|
||||
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||
}
|
||||
|
||||
//fmt.Println(req.Form["daterange"])
|
||||
|
||||
}
|
||||
|
||||
if v.GetString("type") == "time" {
|
||||
//fmt.Println(req.Form["daterange"])
|
||||
|
||||
if len(req.Form[v.GetString("name")]) == 1 {
|
||||
t := time.Unix(ObjToCeilInt64(req.FormValue(v.GetString("name"))), 0).Format("2006-01-02 15:04:05")
|
||||
|
||||
daterange[table+"."+v.GetString("name")+"[>]"] = t
|
||||
|
||||
} else if len(req.Form[v.GetString("name")]) == 2 {
|
||||
t1 := time.Unix(ObjToCeilInt64(req.Form[v.GetString("name")][0]), 0).Format("2006-01-02 15:04:05")
|
||||
t2 := time.Unix(ObjToCeilInt64(req.Form[v.GetString("name")][1]), 0).Format("2006-01-02 15:04:05")
|
||||
daterange[table+"."+v.GetString("name")+"[<>]"] = Slice{t1, t2}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if len(reStr) != 0 {
|
||||
reStr = reStr[:len(reStr)-1]
|
||||
@@ -954,47 +945,56 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
for k, _ := range search {
|
||||
searchItem := search.GetMap(k)
|
||||
searchItemName := searchItem.GetString("name")
|
||||
if data[table+"."+searchItemName] != nil {
|
||||
delete(data, table+"."+searchItemName)
|
||||
}
|
||||
reqValue := req.Form[searchItemName]
|
||||
parent_idsStr := ""
|
||||
parent_ids := that.TableColumns[searchItem.GetString("link")]["parent_ids"]
|
||||
if parent_ids != nil {
|
||||
parent_idsStr = "parent_ids[~]"
|
||||
}
|
||||
index := that.TableColumns[searchItem.GetString("link")]["index"]
|
||||
if index != nil {
|
||||
parent_idsStr = "index[~]"
|
||||
}
|
||||
|
||||
reqValue := req.Form[search.GetMap(k).GetString("name")]
|
||||
|
||||
//reqValue := req.FormValue(search.GetMap(k).GetString("name"))
|
||||
if len(reqValue) == 0 || reqValue[0] == "" {
|
||||
|
||||
if parent_idsStr != "" && userData[searchItem.GetString("name")] != nil {
|
||||
where := Map{parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ","}
|
||||
r := db.Select(searchItem.GetString("link"), "id", where)
|
||||
reqValue = []string{}
|
||||
for _, v := range r {
|
||||
reqValue = append(reqValue, v.GetString("id"))
|
||||
}
|
||||
|
||||
data[table+"."+searchItemName] = reqValue
|
||||
if searchItem.GetString("link") != "" {
|
||||
|
||||
parent_ids := that.TableColumns[searchItem.GetString("link")]["parent_ids"]
|
||||
if parent_ids != nil {
|
||||
parent_idsStr = "parent_ids[~]"
|
||||
}
|
||||
index := that.TableColumns[searchItem.GetString("link")]["index"]
|
||||
if index != nil {
|
||||
parent_idsStr = "index[~]"
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
//reqValue := req.FormValue(search.GetMap(k).GetString("name"))
|
||||
if len(reqValue) == 0 || reqValue[0] == "" {
|
||||
|
||||
if parent_idsStr != "" && userData[searchItem.GetString("name")] != nil {
|
||||
where := Map{parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ","}
|
||||
r := db.Select(searchItem.GetString("link"), "id", where)
|
||||
reqValue = []string{}
|
||||
for _, v := range r {
|
||||
reqValue = append(reqValue, v.GetString("id"))
|
||||
}
|
||||
|
||||
data[table+"."+searchItemName] = reqValue
|
||||
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
}
|
||||
//columns := that.TableConfig.GetMap(table).GetSlice("columns")
|
||||
if searchItem.GetString("type") == "search" {
|
||||
for _, v := range that.TableColumns[table] {
|
||||
if v["list"] == false {
|
||||
continue
|
||||
}
|
||||
//if v["list"] == false {
|
||||
// continue
|
||||
//}
|
||||
//日期类型
|
||||
if searchItemName == "daterange" {
|
||||
|
||||
if daterangeTableStr != "" && daterangeTableStr != v.GetString("name") {
|
||||
continue
|
||||
}
|
||||
if v.GetString("type") == "unixtime" {
|
||||
//fmt.Println(req.Form["daterange"])
|
||||
if len(req.Form["daterange"]) == 1 {
|
||||
if len(req.Form["daterange"]) == 1 && req.Form["daterange"][0] != "" {
|
||||
daterange[table+"."+v.GetString("name")+"[>]"] = req.FormValue("daterange")
|
||||
} else if len(req.Form["daterange"]) == 2 {
|
||||
|
||||
@@ -1004,7 +1004,7 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
if v.GetString("type") == "time" {
|
||||
//fmt.Println(req.Form["daterange"])
|
||||
|
||||
if len(req.Form["daterange"]) == 1 {
|
||||
if len(req.Form["daterange"]) == 1 && req.Form["daterange"][0] != "" {
|
||||
t := time.Unix(ObjToCeilInt64(req.FormValue("daterange")), 0).Format("2006-01-02 15:04:05")
|
||||
|
||||
daterange[table+"."+v.GetString("name")+"[>]"] = t
|
||||
@@ -1017,44 +1017,92 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if searchItemName == "keyword" && keywordStr != "" {
|
||||
|
||||
if keywordTableStr != "" {
|
||||
if keywordTableStr == v.GetString("name") {
|
||||
data[table+"."+keywordTableStr+"[~]"] = keywordStr
|
||||
}
|
||||
|
||||
if keywordTableStr == v.GetString("value") {
|
||||
childs := db.Select(v.GetString("link"), "id", Map{v.GetString("value") + "[~]": keywordStr})
|
||||
childIds := Slice{}
|
||||
for _, cv := range childs {
|
||||
childIds = append(childIds, cv.GetString("id"))
|
||||
}
|
||||
if len(childIds) != 0 {
|
||||
data[v.GetString("link")+".id"] = childIds
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if strings.Contains(v.GetString("type"), "text") {
|
||||
keyword[table+"."+v.GetString("name")+"[~]"] = keywordStr
|
||||
|
||||
}
|
||||
if v.GetString("name") == "id" {
|
||||
keyword[table+"."+v.GetString("name")] = keywordStr
|
||||
}
|
||||
if v.GetString("link") != "" &&
|
||||
v.GetString("name") != "parent_id" {
|
||||
childs := db.Select(v.GetString("link"), "id", Map{v.GetString("value") + "[~]": keywordStr})
|
||||
childIds := Slice{}
|
||||
for _, cv := range childs {
|
||||
childIds = append(childIds, cv.GetString("id"))
|
||||
}
|
||||
if len(childIds) != 0 {
|
||||
keyword[v.GetString("link")+".id"] = childIds
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if searchItem.GetString("name") == "sort" {
|
||||
if len(reqValue) != 0 && searchItem.GetString("name") == "sort" && reqValue[0] != "" {
|
||||
sortMap["ORDER"] = table + "." + reqValue[0]
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
//树节点模式搜索
|
||||
if searchItemName == "parent_id" {
|
||||
//if parent_idsStr != "" {
|
||||
//
|
||||
// where := Map{}
|
||||
//
|
||||
// for _, v := range reqValue {
|
||||
// if len(where) == 0 {
|
||||
// where[parent_idsStr] = "," + v + ","
|
||||
// continue
|
||||
// }
|
||||
// where = Map{"OR": where, parent_idsStr: "," + v + ","}
|
||||
// }
|
||||
// //用户
|
||||
// if userData[searchItem.GetString("name")] != nil {
|
||||
// where = Map{"AND": Map{parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ",", "OR": where}}
|
||||
// }
|
||||
// r := db.Select(searchItem.GetString("link"), "id", where)
|
||||
// for _, v := range r {
|
||||
// reqValue = append(reqValue, v.GetString("id"))
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
parentID := ObjToInt(req.FormValue("parent_id"))
|
||||
if parentID == 0 {
|
||||
parentID = userData.GetCeilInt(table + "_id")
|
||||
data["OR"] = Map{table + ".id": parentID, table + ".parent_id": nil}
|
||||
} else {
|
||||
data[table+".parent_id"] = reqValue
|
||||
//是否展示全部子级
|
||||
where := Map{}
|
||||
if req.FormValue("showall") == "1" {
|
||||
|
||||
for _, v := range reqValue {
|
||||
if len(where) == 0 {
|
||||
where[table+"."+parent_idsStr] = "," + v + ","
|
||||
continue
|
||||
}
|
||||
where = Map{"OR": where, table + "." + parent_idsStr: "," + v + ","}
|
||||
}
|
||||
|
||||
} else {
|
||||
where[table+".parent_id"] = reqValue
|
||||
}
|
||||
//是否展示自己
|
||||
if req.FormValue("showself") == "1" {
|
||||
if len(where) == 0 {
|
||||
data["OR"] = Map{table + ".id": reqValue}
|
||||
} else {
|
||||
data["OR"] = Map{"OR": where, table + ".id": reqValue}
|
||||
}
|
||||
} else {
|
||||
if len(where) != 0 {
|
||||
data["OR"] = where
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
continue
|
||||
}
|
||||
@@ -1064,28 +1112,39 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
if parent_idsStr != "" {
|
||||
|
||||
where := Map{}
|
||||
|
||||
for _, v := range reqValue {
|
||||
if len(where) == 0 {
|
||||
where[parent_idsStr] = "," + v + ","
|
||||
continue
|
||||
//是否全部展示
|
||||
if req.FormValue("showall") != "1" {
|
||||
where[table+"."+searchItem.GetString("name")] = reqValue
|
||||
} else {
|
||||
for _, v := range reqValue {
|
||||
if len(where) == 0 {
|
||||
where[searchItem.GetString("link")+"."+parent_idsStr] = "," + v + ","
|
||||
continue
|
||||
}
|
||||
where = Map{"OR": where, searchItem.GetString("link") + "." + parent_idsStr: "," + v + ","}
|
||||
}
|
||||
where = Map{"OR": where, parent_idsStr: "," + v + ","}
|
||||
}
|
||||
|
||||
//用户
|
||||
if userData[searchItem.GetString("name")] != nil {
|
||||
where = Map{"AND": Map{parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ",", "OR": where}}
|
||||
}
|
||||
r := db.Select(searchItem.GetString("link"), "id", where)
|
||||
for _, v := range r {
|
||||
reqValue = append(reqValue, v.GetString("id"))
|
||||
|
||||
where = Map{"AND": Map{searchItem.GetString("link") + "." + parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ",", "OR": where}}
|
||||
}
|
||||
data["OR"] = where
|
||||
|
||||
continue
|
||||
//r := db.Select(searchItem.GetString("link"), "id", where)
|
||||
//for _, v := range r {
|
||||
// reqValue = append(reqValue, v.GetString("id"))
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data[table+"."+searchItemName] = reqValue
|
||||
if len(reqValue) != 0 && reqValue[0] != "" {
|
||||
data[table+"."+searchItemName] = reqValue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if sortMap["ORDER"] == nil {
|
||||
@@ -1099,6 +1158,7 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
data[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
if len(keyword) > 1 {
|
||||
if data["OR"] != nil {
|
||||
data = Map{"AND": data, "OR": keyword}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/hex"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
//安全锁
|
||||
@@ -36,6 +37,42 @@ func StrFirstToUpper(str string) string {
|
||||
return strings.ToUpper(first) + other
|
||||
}
|
||||
|
||||
// 时间转字符串,第二个参数支持1-5对应显示年月日时分秒
|
||||
func Time2Str(t *time.Time, qu ...interface{}) string {
|
||||
if t == nil || t.Unix() < 0 {
|
||||
return ""
|
||||
}
|
||||
tp := 5
|
||||
if len(qu) != 0 {
|
||||
tp = (qu[0]).(int)
|
||||
}
|
||||
|
||||
switch tp {
|
||||
case 1:
|
||||
return t.Format("2006-01")
|
||||
case 2:
|
||||
return t.Format("2006-01-02")
|
||||
case 3:
|
||||
return t.Format("2006-01-02 15")
|
||||
case 4:
|
||||
return t.Format("2006-01-02 15:04")
|
||||
case 5:
|
||||
return t.Format("2006-01-02 15:04:05")
|
||||
case 12:
|
||||
return t.Format("01-02")
|
||||
case 14:
|
||||
return t.Format("01-02 15:04")
|
||||
case 15:
|
||||
return t.Format("01-02 15:04:05")
|
||||
case 34:
|
||||
return t.Format("15:04")
|
||||
case 35:
|
||||
return t.Format("15:04:05")
|
||||
}
|
||||
return t.Format("2006-01-02 15:04:05")
|
||||
|
||||
}
|
||||
|
||||
// StrLd 相似度计算 ld compares two strings and returns the levenshtein distance between them.
|
||||
func StrLd(s, t string, ignoreCase bool) int {
|
||||
if ignoreCase {
|
||||
|
||||
+14
@@ -5,6 +5,7 @@ import (
|
||||
. "code.hoteas.com/golang/hotime/db"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -74,6 +75,19 @@ func (that *Context) View() {
|
||||
if that.Session("user_id").Data != nil {
|
||||
that.Log["user_id"] = that.Session("user_id").ToCeilInt()
|
||||
}
|
||||
//负载均衡优化
|
||||
ipStr := ""
|
||||
if that.Req.Header.Get("X-Forwarded-For") != "" {
|
||||
ipStr = that.Req.Header.Get("X-Forwarded-For")
|
||||
} else if that.Req.Header.Get("X-Real-IP") != "" {
|
||||
ipStr = that.Req.Header.Get("X-Real-IP")
|
||||
}
|
||||
//负载均衡优化
|
||||
if ipStr == "" {
|
||||
//RemoteAddr := that.Req.RemoteAddr
|
||||
ipStr = Substr(that.Req.RemoteAddr, 0, strings.Index(that.Req.RemoteAddr, ":"))
|
||||
}
|
||||
that.Log["ip"] = ipStr
|
||||
that.Db.Insert("logs", that.Log)
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -81,7 +81,7 @@ func (that *HotimeDBBuilder) Update(qu ...interface{}) int64 {
|
||||
}
|
||||
if lth > 1 {
|
||||
for k := 1; k < lth; k++ {
|
||||
data[ObjToStr(k-1)] = qu[k]
|
||||
data[ObjToStr(qu[k-1])] = qu[k]
|
||||
k++
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func (that *HotimeDBBuilder) Join(qu ...interface{}) *HotimeDBBuilder {
|
||||
}
|
||||
if lth > 1 {
|
||||
for k := 1; k < lth; k++ {
|
||||
data[ObjToStr(k-1)] = qu[k]
|
||||
data[ObjToStr(qu[k-1])] = qu[k]
|
||||
k++
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (that *HotimeDBBuilder) And(qu ...interface{}) *HotimeDBBuilder {
|
||||
if lth > 1 {
|
||||
where = Map{}
|
||||
for k := 1; k < lth; k++ {
|
||||
where[ObjToStr(k-1)] = qu[k]
|
||||
where[ObjToStr(qu[k-1])] = qu[k]
|
||||
k++
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ func (that *HotimeDBBuilder) Or(qu ...interface{}) *HotimeDBBuilder {
|
||||
if lth > 1 {
|
||||
where = Map{}
|
||||
for k := 1; k < lth; k++ {
|
||||
where[ObjToStr(k-1)] = qu[k]
|
||||
where[ObjToStr(qu[k-1])] = qu[k]
|
||||
k++
|
||||
}
|
||||
}
|
||||
@@ -218,7 +218,7 @@ func (that *HotimeDBBuilder) Where(qu ...interface{}) *HotimeDBBuilder {
|
||||
if lth > 1 {
|
||||
where = Map{}
|
||||
for k := 1; k < lth; k++ {
|
||||
where[ObjToStr(k-1)] = qu[k]
|
||||
where[ObjToStr(qu[k-1])] = qu[k]
|
||||
k++
|
||||
}
|
||||
}
|
||||
@@ -703,9 +703,9 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
|
||||
}
|
||||
|
||||
if reflect.ValueOf(qu[0]).Type().String() == "common.Slice" {
|
||||
|
||||
for key, _ := range testQuData {
|
||||
v := testQuData.GetMap(key)
|
||||
qu0 := ObjToSlice(qu[0])
|
||||
for key, _ := range qu0 {
|
||||
v := qu0.GetMap(key)
|
||||
for k1, v1 := range v {
|
||||
testQu = append(testQu, k1)
|
||||
testQuData[k1] = v1
|
||||
|
||||
@@ -18,13 +18,13 @@ func Down(url, path, name string, e ...*Error) bool {
|
||||
}
|
||||
out, err := os.Create(path + name)
|
||||
|
||||
if err != nil && e[0] != nil {
|
||||
if err != nil && len(e) != 0 {
|
||||
e[0].SetError(err)
|
||||
return false
|
||||
}
|
||||
defer out.Close()
|
||||
resp, err := http.Get(url)
|
||||
if err != nil && e[0] != nil {
|
||||
if err != nil && len(e) != 0 {
|
||||
e[0].SetError(err)
|
||||
return false
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func Down(url, path, name string, e ...*Error) bool {
|
||||
|
||||
pix, err := ioutil.ReadAll(resp.Body)
|
||||
_, err = io.Copy(out, bytes.NewReader(pix))
|
||||
if err != nil && e[0] != nil {
|
||||
if err != nil && len(e) != 0 {
|
||||
e[0].SetError(err)
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package mongodb
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
"context"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
type MongoDb struct {
|
||||
Client *mongo.Client
|
||||
Ctx context.Context
|
||||
DataBase *mongo.Database
|
||||
Connect *mongo.Collection
|
||||
LastErr error
|
||||
}
|
||||
|
||||
func GetMongoDb(database, url string) (*MongoDb, error) {
|
||||
db := MongoDb{}
|
||||
clientOptions := options.Client().ApplyURI(url)
|
||||
|
||||
db.Ctx = context.TODO()
|
||||
// Connect to MongoDb
|
||||
var err error
|
||||
db.Client, err = mongo.Connect(db.Ctx, clientOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Check the connection
|
||||
err = db.Client.Ping(db.Ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println("Connected to MongoDb!")
|
||||
//databases, err := db.Client.ListDatabaseNames(db.Ctx, bson.M{})
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//fmt.Println(databases)
|
||||
db.DataBase = db.Client.Database(database)
|
||||
return &db, nil
|
||||
|
||||
}
|
||||
|
||||
func (that *MongoDb) Insert(table string, data interface{}) string {
|
||||
collection := that.DataBase.Collection(table)
|
||||
re, err := collection.InsertOne(that.Ctx, data)
|
||||
if err != nil {
|
||||
that.LastErr = err
|
||||
return ""
|
||||
}
|
||||
return ObjToStr(re.InsertedID)
|
||||
}
|
||||
|
||||
func (that *MongoDb) InsertMany(table string, data ...interface{}) Slice {
|
||||
collection := that.DataBase.Collection(table)
|
||||
re, err := collection.InsertMany(that.Ctx, data)
|
||||
if err != nil {
|
||||
that.LastErr = err
|
||||
return Slice{}
|
||||
}
|
||||
|
||||
return ObjToSlice(re.InsertedIDs)
|
||||
|
||||
}
|
||||
|
||||
func (that *MongoDb) Update(table string, data Map, where Map) int64 {
|
||||
collection := that.DataBase.Collection(table)
|
||||
re, err := collection.UpdateMany(that.Ctx, where, data)
|
||||
|
||||
if err != nil {
|
||||
that.LastErr = err
|
||||
return 0
|
||||
}
|
||||
|
||||
return re.ModifiedCount
|
||||
|
||||
}
|
||||
|
||||
func (that *MongoDb) Delete(table string, where Map) int64 {
|
||||
collection := that.DataBase.Collection(table)
|
||||
re, err := collection.DeleteMany(that.Ctx, where)
|
||||
|
||||
if err != nil {
|
||||
that.LastErr = err
|
||||
return 0
|
||||
}
|
||||
|
||||
return re.DeletedCount
|
||||
|
||||
}
|
||||
|
||||
func (that *MongoDb) Get(table string, where Map) Map {
|
||||
results := []Map{}
|
||||
var cursor *mongo.Cursor
|
||||
var err error
|
||||
collection := that.DataBase.Collection(table)
|
||||
if cursor, err = collection.Find(that.Ctx, where, options.Find().SetSkip(0), options.Find().SetLimit(2)); err != nil {
|
||||
that.LastErr = err
|
||||
return nil
|
||||
}
|
||||
//延迟关闭游标
|
||||
defer func() {
|
||||
if err := cursor.Close(that.Ctx); err != nil {
|
||||
that.LastErr = err
|
||||
|
||||
}
|
||||
}()
|
||||
//这里的结果遍历可以使用另外一种更方便的方式:
|
||||
if err = cursor.All(that.Ctx, &results); err != nil {
|
||||
that.LastErr = err
|
||||
return nil
|
||||
}
|
||||
if len(results) > 0 {
|
||||
|
||||
return results[0]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (that MongoDb) Select(table string, where Map, page, pageRow int64) []Map {
|
||||
page = (page - 1) * pageRow
|
||||
if page < 0 {
|
||||
page = 0
|
||||
}
|
||||
results := []Map{}
|
||||
var cursor *mongo.Cursor
|
||||
var err error
|
||||
collection := that.DataBase.Collection(table)
|
||||
if cursor, err = collection.Find(that.Ctx, where, options.Find().SetSkip(page), options.Find().SetLimit(pageRow)); err != nil {
|
||||
that.LastErr = err
|
||||
return results
|
||||
}
|
||||
//延迟关闭游标
|
||||
defer func() {
|
||||
if err := cursor.Close(that.Ctx); err != nil {
|
||||
that.LastErr = err
|
||||
|
||||
}
|
||||
}()
|
||||
//这里的结果遍历可以使用另外一种更方便的方式:
|
||||
|
||||
if err = cursor.All(that.Ctx, &results); err != nil {
|
||||
that.LastErr = err
|
||||
return results
|
||||
}
|
||||
return results
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
var ArticleCtr = Ctr{
|
||||
"info": func(that *Context) {
|
||||
sn := that.Req.FormValue("sn")
|
||||
article := that.Db.Get("article", Map{"[><]ctg_article": "article.id=ctg_article.article_id"}, "article.*,ctg_article.ctg_id AS sctg_id", Map{"ctg_article.sn": sn})
|
||||
if article == nil {
|
||||
that.Display(4, "找不到对应数据")
|
||||
return
|
||||
}
|
||||
ctgId := article.GetCeilInt64("sctg_id")
|
||||
ctg := that.Db.Get("ctg", "*", Map{"id": ctgId})
|
||||
parents := []Map{}
|
||||
parentId := ctg.GetCeilInt64("parent_id")
|
||||
article["tongji"] = that.Db.Select("ctg", "sn,name,img,parent_id", Map{"parent_id": parentId})
|
||||
for true {
|
||||
|
||||
if parentId == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
parent := that.Db.Get("ctg", "sn,name,img,parent_id", Map{"id": parentId})
|
||||
if parent == nil {
|
||||
break
|
||||
}
|
||||
|
||||
parents = append(parents, parent)
|
||||
parentId = parent.GetCeilInt64("parent_id")
|
||||
|
||||
}
|
||||
|
||||
ctg["parents"] = parents
|
||||
|
||||
article["ctg"] = ctg
|
||||
that.Display(0, article)
|
||||
},
|
||||
"list": func(that *Context) {
|
||||
sn := that.Req.FormValue("ctg_sn") //ctgsn
|
||||
page := ObjToInt(that.Req.FormValue("page"))
|
||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
||||
|
||||
if page == 0 {
|
||||
page = 1
|
||||
}
|
||||
if pageSize == 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
|
||||
lunbo := ObjToInt(that.Req.FormValue("lunbo"))
|
||||
|
||||
sort := that.Req.FormValue("sort")
|
||||
|
||||
where := Map{"article.push_time[<]": time.Now().Format("2006-01-02 15:04"), "article.state": 0}
|
||||
if sn != "" {
|
||||
ctg := that.Db.Get("ctg", "id", Map{"sn": sn})
|
||||
if ctg != nil {
|
||||
where["ctg_article.ctg_id"] = ctg.GetCeilInt("id")
|
||||
}
|
||||
}
|
||||
|
||||
startTime := that.Req.FormValue("start_time") //ctgsn
|
||||
finishTime := that.Req.FormValue("finish_time") //ctgsn
|
||||
|
||||
if lunbo != 0 {
|
||||
where["article.lunbo"] = lunbo
|
||||
}
|
||||
|
||||
if len(startTime) > 5 {
|
||||
where["article.push_time[>=]"] = startTime
|
||||
}
|
||||
if len(finishTime) > 5 {
|
||||
where["article.push_time[<=]"] = finishTime
|
||||
}
|
||||
|
||||
if keywords != "" {
|
||||
where["OR"] = Map{"article.title[~]": keywords, "article.description[~]": keywords, "article.author[~]": keywords, "article.sn[~]": keywords, "article.origin[~]": keywords, "article.url[~]": keywords}
|
||||
}
|
||||
|
||||
if len(where) > 1 {
|
||||
where = Map{"AND": where}
|
||||
}
|
||||
|
||||
if sort == "" {
|
||||
where["ORDER"] = Slice{"article.sort DESC", "article.push_time DESC"}
|
||||
}
|
||||
|
||||
if sort == "time" {
|
||||
where["ORDER"] = "article.push_time DESC"
|
||||
}
|
||||
count := that.Db.Count("article", Map{"[><]ctg_article": "article.id=ctg_article.article_id"}, where)
|
||||
article := that.Db.Page(page, pageSize).PageSelect("article", Map{"[><]ctg_article": "article.id=ctg_article.article_id"}, "ctg_article.sn,article.img,article.title,article.description,article.push_time,article.lunbo,article.author,article.origin,article.url", where)
|
||||
|
||||
that.Display(0, Map{"count": count, "data": article})
|
||||
|
||||
},
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
)
|
||||
|
||||
var CtgCtr = Ctr{
|
||||
"info": func(that *Context) {
|
||||
sn := that.Req.FormValue("sn")
|
||||
ctg := that.Db.Get("ctg", "*", Map{"sn": sn})
|
||||
parents := []Map{}
|
||||
parentId := ctg.GetCeilInt64("parent_id")
|
||||
ctg["tongji"] = that.Db.Select("ctg", "sn,name,img,parent_id", Map{"parent_id": parentId})
|
||||
for true {
|
||||
|
||||
if parentId == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
parent := that.Db.Get("ctg", "sn,name,img,parent_id", Map{"id": parentId})
|
||||
if parent == nil {
|
||||
break
|
||||
}
|
||||
|
||||
parents = append(parents, parent)
|
||||
parentId = parent.GetCeilInt64("parent_id")
|
||||
|
||||
}
|
||||
|
||||
if ctg.GetCeilInt64("article_id") != 0 {
|
||||
ctg["article"] = that.Db.Get("article", "*", Map{"id": ctg.GetCeilInt64("article_id")})
|
||||
}
|
||||
|
||||
ctg["parents"] = parents
|
||||
that.Display(0, ctg)
|
||||
},
|
||||
"list": func(that *Context) {
|
||||
sn := that.Req.FormValue("sn") //ctgsn
|
||||
page := ObjToInt(that.Req.FormValue("page"))
|
||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
||||
|
||||
if page == 0 {
|
||||
page = 1
|
||||
}
|
||||
if pageSize == 0 {
|
||||
pageSize = 50
|
||||
}
|
||||
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
|
||||
//sort:=that.Req.FormValue("sort")
|
||||
|
||||
where := Map{"state": 0}
|
||||
if sn != "" {
|
||||
ctg := that.Db.Get("ctg", "id", Map{"sn": sn})
|
||||
if ctg != nil {
|
||||
where["parent_id"] = ctg.GetCeilInt("id")
|
||||
}
|
||||
}
|
||||
|
||||
if keywords != "" {
|
||||
where["OR"] = Map{"name[~]": keywords, "url[~]": keywords, "sn[~]": keywords}
|
||||
}
|
||||
|
||||
if len(where) > 1 {
|
||||
where = Map{"AND": where}
|
||||
}
|
||||
|
||||
where["ORDER"] = Slice{"sort DESC", "id DESC"}
|
||||
|
||||
article := that.Db.Page(page, pageSize).PageSelect("ctg", "name,sn,sort,url,img", where)
|
||||
|
||||
that.Display(0, article)
|
||||
|
||||
},
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
var AppProj = Proj{
|
||||
"article": ArticleCtr,
|
||||
"org": OrgCtr,
|
||||
"ctg": CtgCtr,
|
||||
"mail": MailCtr,
|
||||
"test": {
|
||||
"test": func(that *Context) {
|
||||
//data:=that.Db.Table("admin").Order("id DESC").Select("*")
|
||||
//data1:=that.Db.Table("admin").Where(Map{"name[~]":"m"}).Order("id DESC").Select("*")
|
||||
//
|
||||
//data3:=that.Db.Select("admin","*",Map{"name[~]":"m"})
|
||||
data2 := that.Db.Table("article").Where(Map{"title[~]": "m"}).Order("id DESC").Page(1, 10).Select("*")
|
||||
c := that.Db.Table("article").Where(Map{"title[~]": "m"}).Order("id DESC").Group("title").Select("*")
|
||||
//that.Display(0,Slice{data1,data,data3,data2})
|
||||
that.Display(0, Slice{data2, c})
|
||||
},
|
||||
"res": func(that *Context) {
|
||||
ebw_res := that.Db.Select("ebw_res", "*")
|
||||
|
||||
for _, v := range ebw_res {
|
||||
data := Map{"id": v.GetCeilInt("id"), "name": v.GetString("name"),
|
||||
"parent_id": v.GetCeilInt64("pid"),
|
||||
"sn": v.GetString("url"), "create_time": time.Now().Format("2006-01-02 15:04"),
|
||||
"modify_time": time.Now().Format("2006-01-02 15:04"), "admin_id": 1}
|
||||
if data.GetCeilInt("parent_id") == 0 {
|
||||
data["parent_id"] = nil
|
||||
}
|
||||
that.Db.Insert("ctg", data)
|
||||
}
|
||||
|
||||
that.Db.Exec("UPDATE ctg SET parent_id =NULL WHERE parent_id=id")
|
||||
|
||||
ss(0, that)
|
||||
|
||||
that.Display(0, len(ebw_res))
|
||||
|
||||
},
|
||||
"news": func(that *Context) {
|
||||
ebw_news := that.Db.Select("ebw_news", "*")
|
||||
|
||||
for _, v := range ebw_news {
|
||||
ctg := that.Db.Get("ctg", "*", Map{"sn": v.GetString("type")})
|
||||
data := Map{"sn": v.GetString("id"), "title": v.GetString("title"),
|
||||
"content": v.GetString("content"), "push_time": v.GetString("timedate"),
|
||||
"author": v.GetString("owner"), "origin": v.GetString("source"), "click_num": v.GetString("readtime"),
|
||||
"sort": v.GetCeilInt("zhiding"), "create_time": time.Now().Format("2006-01-02 15:04"),
|
||||
"modify_time": time.Now().Format("2006-01-02 15:04"), "admin_id": 1}
|
||||
if ctg != nil {
|
||||
data["ctg_id"] = ctg.GetCeilInt("id")
|
||||
}
|
||||
that.Db.Insert("article", data)
|
||||
}
|
||||
|
||||
that.Display(0, len(ebw_news))
|
||||
|
||||
},
|
||||
"res2news": func(that *Context) {
|
||||
ebw_news_addition_res := that.Db.Select("ebw_news_addition_res", "*")
|
||||
|
||||
for _, v := range ebw_news_addition_res {
|
||||
ctg := that.Db.Get("ctg", "*", Map{"sn": v.GetString("fk_res")})
|
||||
article := that.Db.Get("article", "*", Map{"sn": v.GetString("fk_newsid")})
|
||||
data := Map{"sn": Md5(ObjToStr(time.Now().UnixNano()) + ObjToStr(RandX(10000, 100000))),
|
||||
"create_time": time.Now().Format("2006-01-02 15:04"),
|
||||
"modify_time": time.Now().Format("2006-01-02 15:04"), "admin_id": 1}
|
||||
if ctg != nil {
|
||||
data["ctg_id"] = ctg.GetCeilInt("id")
|
||||
}
|
||||
if article != nil {
|
||||
data["article_id"] = article.GetCeilInt("id")
|
||||
}
|
||||
that.Db.Insert("ctg_article", data)
|
||||
}
|
||||
|
||||
that.Display(0, len(ebw_news_addition_res))
|
||||
},
|
||||
//将文章没有关联的ctg_article进行关联
|
||||
"article": func(that *Context) {
|
||||
articles := that.Db.Select("article", "id,ctg_id")
|
||||
for _, v := range articles {
|
||||
ctg_article := that.Db.Get("ctg_article", "id", Map{"article_id": v.GetCeilInt("id")})
|
||||
if ctg_article == nil {
|
||||
|
||||
data := Map{"sn": Md5(ObjToStr(time.Now().UnixNano()) + ObjToStr(RandX(10000, 100000))),
|
||||
"create_time": time.Now().Format("2006-01-02 15:04"),
|
||||
"modify_time": time.Now().Format("2006-01-02 15:04"), "admin_id": 1}
|
||||
if v.GetCeilInt("ctg_id") == 0 || v.GetCeilInt("id") == 0 {
|
||||
continue
|
||||
}
|
||||
data["ctg_id"] = v.GetCeilInt("ctg_id")
|
||||
data["article_id"] = v.GetCeilInt("id")
|
||||
that.Db.Insert("ctg_article", data)
|
||||
}
|
||||
|
||||
}
|
||||
that.Display(0, len(articles))
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func ss(parent_id int, that *Context) {
|
||||
var ctgs []Map
|
||||
ctg := that.Db.Get("ctg", "*", Map{"id": parent_id})
|
||||
if parent_id == 0 {
|
||||
ctgs = that.Db.Select("ctg", "*", Map{"parent_id": nil})
|
||||
} else {
|
||||
ctgs = that.Db.Select("ctg", "*", Map{"parent_id": parent_id})
|
||||
}
|
||||
|
||||
for _, v := range ctgs {
|
||||
if ctg == nil {
|
||||
ctg = Map{"parent_ids": ","}
|
||||
}
|
||||
ids := ctg.GetString("parent_ids") + ObjToStr(v.GetCeilInt("id")) + ","
|
||||
that.Db.Update("ctg", Map{"parent_ids": ids}, Map{"id": v.GetCeilInt("id")})
|
||||
ss(v.GetCeilInt("id"), that)
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
var MailCtr = Ctr{
|
||||
"add": func(that *Context) {
|
||||
title := that.Req.FormValue("title")
|
||||
name := that.Req.FormValue("name")
|
||||
phone := that.Req.FormValue("phone")
|
||||
content := that.Req.FormValue("content")
|
||||
|
||||
tp := ObjToInt(that.Req.FormValue("type"))
|
||||
show := ObjToInt(that.Req.FormValue("show"))
|
||||
|
||||
if len(title) < 5 {
|
||||
that.Display(3, "标题过短")
|
||||
return
|
||||
}
|
||||
if len(name) < 2 {
|
||||
that.Display(3, "姓名错误")
|
||||
return
|
||||
}
|
||||
if len(phone) < 8 {
|
||||
that.Display(3, "联系方式错误")
|
||||
return
|
||||
}
|
||||
if len(content) < 10 {
|
||||
that.Display(3, "内容过短")
|
||||
return
|
||||
}
|
||||
|
||||
data := Map{
|
||||
"sn": Md5(ObjToStr(time.Now().UnixNano()) + ObjToStr(RandX(10000, 100000))),
|
||||
"name": name, "title": title, "phone": phone, "content": content, "type": tp, "show": show,
|
||||
"modify_time[#]": "NOW()", "create_time[#]": "NOW()",
|
||||
}
|
||||
id := that.Db.Insert("mail", data)
|
||||
if id == 0 {
|
||||
that.Display(4, "创建失败")
|
||||
return
|
||||
}
|
||||
|
||||
that.Display(0, "成功")
|
||||
return
|
||||
|
||||
},
|
||||
"info": func(that *Context) {
|
||||
sn := that.Req.FormValue("sn")
|
||||
|
||||
mail := that.Db.Get("mail", "*", Map{"sn": sn})
|
||||
|
||||
that.Display(0, mail)
|
||||
},
|
||||
"list": func(that *Context) {
|
||||
page := ObjToInt(that.Req.FormValue("page"))
|
||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
||||
|
||||
if page == 0 {
|
||||
page = 1
|
||||
}
|
||||
if pageSize == 0 {
|
||||
pageSize = 10
|
||||
}
|
||||
|
||||
//keywords:=that.Req.FormValue("keywords")
|
||||
|
||||
//sort:=that.Req.FormValue("sort")
|
||||
|
||||
where := Map{"state": 0, "show": 1}
|
||||
|
||||
//if keywords!=""{
|
||||
// where["OR"]=Map{"title[~]":keywords,"description[~]":keywords,"author[~]":keywords,"sn[~]":keywords,"origin[~]":keywords,"url[~]":keywords}
|
||||
//}
|
||||
|
||||
if len(where) > 1 {
|
||||
where = Map{"AND": where}
|
||||
}
|
||||
|
||||
//if sort==""{
|
||||
// where["ORDER"]=Slice{"sort DESC","push_time DESC"}
|
||||
//}
|
||||
//
|
||||
//if sort=="time"{
|
||||
where["ORDER"] = "create_time DESC"
|
||||
//}
|
||||
count := that.Db.Count("mail", where)
|
||||
mail := that.Db.Page(page, pageSize).PageSelect("mail", "*", where)
|
||||
|
||||
that.Display(0, Map{"count": count, "data": mail})
|
||||
|
||||
},
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
. "code.hoteas.com/golang/hotime/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
var OrgCtr = Ctr{
|
||||
"info": func(that *Context) {
|
||||
sn := that.Req.FormValue("sn")
|
||||
article := that.Db.Get("article", "*", Map{"sn": sn})
|
||||
that.Display(0, article)
|
||||
},
|
||||
"list": func(that *Context) {
|
||||
sn := that.Req.FormValue("sn") //orgsn
|
||||
page := ObjToInt(that.Req.FormValue("page"))
|
||||
pageSize := ObjToInt(that.Req.FormValue("pageSize"))
|
||||
|
||||
if page == 0 {
|
||||
page = 1
|
||||
}
|
||||
if pageSize == 0 {
|
||||
pageSize = 50
|
||||
}
|
||||
|
||||
keywords := that.Req.FormValue("keywords")
|
||||
|
||||
sort := that.Req.FormValue("sort")
|
||||
|
||||
where := Map{"push_time[<=]": time.Now().Format("2006-01-02 15:04"), "state": 0}
|
||||
if sn != "" {
|
||||
org := that.Db.Get("org", "id", Map{"sn": sn})
|
||||
if org != nil {
|
||||
where["org_id"] = org.GetCeilInt("id")
|
||||
}
|
||||
}
|
||||
|
||||
if keywords != "" {
|
||||
where["OR"] = Map{"title[~]": keywords, "description[~]": keywords, "author[~]": keywords, "sn[~]": keywords, "origin[~]": keywords, "url[~]": keywords}
|
||||
}
|
||||
|
||||
if len(where) > 1 {
|
||||
where = Map{"AND": where}
|
||||
}
|
||||
|
||||
if sort == "" {
|
||||
where["ORDER"] = Slice{"sort DESC", "id DESC"}
|
||||
}
|
||||
|
||||
if sort == "time" {
|
||||
where["ORDER"] = "push_time DESC"
|
||||
}
|
||||
|
||||
article := that.Db.Page(page, pageSize).PageSelect("article", "sn,title,description,push_time,lunbo,author,origin,url", where)
|
||||
|
||||
that.Display(0, article)
|
||||
|
||||
},
|
||||
}
|
||||
@@ -23,11 +23,10 @@
|
||||
],
|
||||
"db": {
|
||||
"mysql": {
|
||||
"host": "192.168.2.20",
|
||||
"name": "gov_crawler",
|
||||
"password": "fh22y8b882d",
|
||||
"host": "192.168.6.253",
|
||||
"name": "dgs-cms",
|
||||
"password": "dasda8454456",
|
||||
"port": "3306",
|
||||
"prefix": "",
|
||||
"user": "root"
|
||||
}
|
||||
},
|
||||
|
||||
+1
-2
@@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
. "code.hoteas.com/golang/hotime"
|
||||
"code.hoteas.com/golang/hotime/example/app"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -13,6 +12,6 @@ func main() {
|
||||
return isFinished
|
||||
})
|
||||
|
||||
appIns.Run(Router{"app": app.AppProj})
|
||||
appIns.Run(Router{})
|
||||
|
||||
}
|
||||
|
||||
@@ -12,5 +12,6 @@ require (
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.364
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364
|
||||
go.mongodb.org/mongo-driver v1.10.1
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f
|
||||
)
|
||||
|
||||
@@ -14,10 +14,16 @@ github.com/go-pay/gopay v1.5.78 h1:wIHp8g/jK0ik5bZo2MWt3jAQsktT3nkdXZxlRZvljko=
|
||||
github.com/go-pay/gopay v1.5.78/go.mod h1:M6Nlk2VdZHCbWphOw3rtbnz4SiOk6Xvxg6mxwDfg+Ps=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
|
||||
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomodule/redigo v1.8.5 h1:nRAxCa+SVsyjSBrtZmG/cqb6VbTmuRzpg/PoTFlpumc=
|
||||
github.com/gomodule/redigo v1.8.5/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
|
||||
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
|
||||
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
|
||||
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
@@ -25,8 +31,12 @@ github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ
|
||||
github.com/mattn/go-sqlite3 v1.14.12/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
|
||||
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe h1:iruDEfMl2E6fbMZ9s0scYfZQ84/6SPL6zC8ACM2oIL0=
|
||||
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
|
||||
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/silenceper/wechat/v2 v2.1.2 h1:+QfIMiYfwST2ZloTwmYp0O0p5Y1LYRZxfLWfMuSE30k=
|
||||
@@ -39,20 +49,36 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.2.3-0.20181224173747-660f15d67dbb/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.364 h1:X1Jws4XqrTH+p7FBQ7BpjW4qFXObKHWm0/XhW/GvqRs=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.364/go.mod h1:7sCQWVkxcsR38nffDW057DRGk8mUjK1Ing/EFOK8s8Y=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364 h1:kbor60vo37v7Hu+i17gooox9Rw281fVHNna8zwtDG1w=
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364/go.mod h1:LeIUBOLhc+Y5YCEpZrULPD9lgoXXV4/EmIcoEvmHz9c=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
|
||||
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
|
||||
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
|
||||
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
|
||||
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
|
||||
go.mongodb.org/mongo-driver v1.10.1 h1:NujsPveKwHaWuKUer/ceo9DzEe7HIj1SlJ6uvXZG0S4=
|
||||
go.mongodb.org/mongo-driver v1.10.1/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29 h1:tkVvjkPTB7pnW3jnid7kNyAMPVWllTNOf/qKDze4p9o=
|
||||
golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
|
||||
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
@@ -66,12 +92,16 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/h2non/gock.v1 v1.0.15 h1:SzLqcIlb/fDfg7UvukMpNcWsu7sI5tWwL+KCATZqks0=
|
||||
gopkg.in/h2non/gock.v1 v1.0.15/go.mod h1:sX4zAkdYX1TRGJ2JY156cFspQn4yRWn6p9EMdODlynE=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
Vendored
+66
-1
@@ -23,13 +23,26 @@ github.com/go-pay/gopay/wechat/v3
|
||||
# github.com/go-sql-driver/mysql v1.6.0
|
||||
## explicit
|
||||
github.com/go-sql-driver/mysql
|
||||
# github.com/golang/snappy v0.0.1
|
||||
github.com/golang/snappy
|
||||
# github.com/gomodule/redigo v1.8.5
|
||||
github.com/gomodule/redigo/redis
|
||||
# github.com/klauspost/compress v1.13.6
|
||||
github.com/klauspost/compress
|
||||
github.com/klauspost/compress/fse
|
||||
github.com/klauspost/compress/huff0
|
||||
github.com/klauspost/compress/internal/snapref
|
||||
github.com/klauspost/compress/zstd
|
||||
github.com/klauspost/compress/zstd/internal/xxhash
|
||||
# github.com/mattn/go-sqlite3 v1.14.12
|
||||
## explicit
|
||||
github.com/mattn/go-sqlite3
|
||||
# github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
|
||||
github.com/mohae/deepcopy
|
||||
# github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe
|
||||
github.com/montanaflynn/stats
|
||||
# github.com/pkg/errors v0.9.1
|
||||
github.com/pkg/errors
|
||||
# github.com/silenceper/wechat/v2 v2.1.2
|
||||
## explicit
|
||||
github.com/silenceper/wechat/v2
|
||||
@@ -106,13 +119,65 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/regions
|
||||
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr v1.0.364
|
||||
## explicit
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/ocr/v20181119
|
||||
# golang.org/x/crypto v0.0.0-20220331220935-ae2d96664a29
|
||||
# github.com/xdg-go/pbkdf2 v1.0.0
|
||||
github.com/xdg-go/pbkdf2
|
||||
# github.com/xdg-go/scram v1.1.1
|
||||
github.com/xdg-go/scram
|
||||
# github.com/xdg-go/stringprep v1.0.3
|
||||
github.com/xdg-go/stringprep
|
||||
# github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d
|
||||
github.com/youmark/pkcs8
|
||||
# go.mongodb.org/mongo-driver v1.10.1
|
||||
## explicit
|
||||
go.mongodb.org/mongo-driver/bson
|
||||
go.mongodb.org/mongo-driver/bson/bsoncodec
|
||||
go.mongodb.org/mongo-driver/bson/bsonoptions
|
||||
go.mongodb.org/mongo-driver/bson/bsonrw
|
||||
go.mongodb.org/mongo-driver/bson/bsontype
|
||||
go.mongodb.org/mongo-driver/bson/primitive
|
||||
go.mongodb.org/mongo-driver/event
|
||||
go.mongodb.org/mongo-driver/internal
|
||||
go.mongodb.org/mongo-driver/internal/randutil
|
||||
go.mongodb.org/mongo-driver/internal/randutil/rand
|
||||
go.mongodb.org/mongo-driver/internal/uuid
|
||||
go.mongodb.org/mongo-driver/mongo
|
||||
go.mongodb.org/mongo-driver/mongo/address
|
||||
go.mongodb.org/mongo-driver/mongo/description
|
||||
go.mongodb.org/mongo-driver/mongo/options
|
||||
go.mongodb.org/mongo-driver/mongo/readconcern
|
||||
go.mongodb.org/mongo-driver/mongo/readpref
|
||||
go.mongodb.org/mongo-driver/mongo/writeconcern
|
||||
go.mongodb.org/mongo-driver/tag
|
||||
go.mongodb.org/mongo-driver/version
|
||||
go.mongodb.org/mongo-driver/x/bsonx
|
||||
go.mongodb.org/mongo-driver/x/bsonx/bsoncore
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/auth
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/awsv4
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/connstring
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/dns
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/mongocrypt/options
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/ocsp
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/operation
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/session
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/topology
|
||||
go.mongodb.org/mongo-driver/x/mongo/driver/wiremessage
|
||||
# golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d
|
||||
golang.org/x/crypto/ocsp
|
||||
golang.org/x/crypto/pbkdf2
|
||||
golang.org/x/crypto/pkcs12
|
||||
golang.org/x/crypto/pkcs12/internal/rc2
|
||||
# golang.org/x/net v0.0.0-20220225172249-27dd8689420f
|
||||
## explicit
|
||||
golang.org/x/net/websocket
|
||||
# golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||
golang.org/x/sync/errgroup
|
||||
# golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e
|
||||
golang.org/x/sys/internal/unsafeheader
|
||||
golang.org/x/sys/unix
|
||||
golang.org/x/sys/windows
|
||||
# golang.org/x/text v0.3.7
|
||||
golang.org/x/text/transform
|
||||
golang.org/x/text/unicode/norm
|
||||
|
||||
Reference in New Issue
Block a user