Compare commits

...

18 Commits

Author SHA1 Message Date
hoteas
2cf20e7206 增加数据库must设置 2023-04-06 11:37:03 +08:00
hoteas
8cac1f5393 修复部分bug,增加DB SUM函数,以及优化IN性能,增加分析接口 2023-03-22 03:17:33 +08:00
hoteas
8337cdec0c 修复部分bug,增加DB SUM函数,以及优化IN性能,增加分析接口 2023-03-10 15:22:03 +08:00
hoteas
46cecc47ea 修复部分bug 2022-12-31 22:28:12 +08:00
hoteas
7535300107 修复部分bug 2022-11-17 17:17:07 +08:00
hoteas
be41a70c76 修复部分bug 2022-11-14 16:49:37 +08:00
hoteas
5b407824a5 修复部分bug 2022-11-14 10:38:15 +08:00
hoteas
56f66fcaed 修复部分bug 2022-11-08 16:05:47 +08:00
hoteas
a298cb3d52 修复部分bug 2022-11-07 01:41:22 +08:00
hoteas
68f2c0fd8f 修复部分bug 2022-11-07 01:40:24 +08:00
hoteas
d314891126 修复部分bug 2022-11-06 06:37:44 +08:00
hoteas
c0ae31f499 修复部分bug 2022-11-05 01:55:11 +08:00
hoteas
25edb6b5b7 修复部分bug 2022-11-04 03:22:00 +08:00
hoteas
ead64dc776 修复bug 2022-11-04 02:55:58 +08:00
hoteas
876e3b1f45 优化性能 2022-11-04 02:34:48 +08:00
hoteas
d6e940803d 优化性能 2022-11-04 02:25:33 +08:00
hoteas
203e72f8a2 优化性能 2022-11-04 02:12:07 +08:00
hoteas
541c82410e 修正bug 2022-10-21 04:28:51 +08:00
12 changed files with 4504 additions and 5261 deletions

View File

@ -68,18 +68,20 @@ func (that *Application) Run(router Router) {
if that.Router == nil { if that.Router == nil {
that.Router = Router{} that.Router = Router{}
} }
for k, v := range router { for k, _ := range router {
v := router[k]
if that.Router[k] == nil { if that.Router[k] == nil {
that.Router[k] = v that.Router[k] = v
} }
//直达接口层复用 //直达接口层复用
for k1, v1 := range v { for k1, _ := range v {
v1 := v[k1]
if that.Router[k][k1] == nil { if that.Router[k][k1] == nil {
that.Router[k][k1] = v1 that.Router[k][k1] = v1
} }
for k2, v2 := range v1 { for k2, _ := range v1 {
v2 := v1[k2]
that.Router[k][k1][k2] = v2 that.Router[k][k1][k2] = v2
} }
} }
@ -329,6 +331,9 @@ func (that *Application) handler(w http.ResponseWriter, req *http.Request) {
if len(token) == 32 { if len(token) == 32 {
sessionId = token sessionId = token
//没有token则查阅session //没有token则查阅session
if cookie == nil || cookie.Value != sessionId {
needSetCookie = sessionId
}
} else if err == nil && cookie.Value != "" { } else if err == nil && cookie.Value != "" {
sessionId = cookie.Value sessionId = cookie.Value
//session也没有则判断是否创建cookie //session也没有则判断是否创建cookie
@ -582,15 +587,27 @@ func Init(config string) *Application {
//appIns.Router[codeMake.GetString("name")] = TptProject //appIns.Router[codeMake.GetString("name")] = TptProject
appIns.Router[codeMake.GetString("name")] = Proj{} appIns.Router[codeMake.GetString("name")] = Proj{}
for k2, _ := range TptProject { for k2, _ := range TptProject {
appIns.Router[codeMake.GetString("name")][k2] = Ctr{} if appIns.Router[codeMake.GetString("name")][k2] == nil {
for k3, v3 := range TptProject[k2] { appIns.Router[codeMake.GetString("name")][k2] = Ctr{}
}
for k3, _ := range TptProject[k2] {
v3 := TptProject[k2][k3]
appIns.Router[codeMake.GetString("name")][k2][k3] = v3 appIns.Router[codeMake.GetString("name")][k2][k3] = v3
} }
} }
for k1, _ := range appIns.MakeCodeRouter[codeMake.GetString("name")].TableColumns { for k1, _ := range appIns.MakeCodeRouter[codeMake.GetString("name")].TableColumns {
appIns.Router[codeMake.GetString("name")][k1] = appIns.Router[codeMake.GetString("name")]["hotimeCommon"] if appIns.Router[codeMake.GetString("name")][k1] == nil {
appIns.Router[codeMake.GetString("name")][k1] = Ctr{}
}
for k2, _ := range appIns.Router[codeMake.GetString("name")]["hotimeCommon"] {
//golang毛病
v2 := appIns.Router[codeMake.GetString("name")]["hotimeCommon"][k2]
appIns.Router[codeMake.GetString("name")][k1][k2] = v2
}
} }
setMakeCodeListener(codeMake.GetString("name"), &appIns) setMakeCodeListener(codeMake.GetString("name"), &appIns)
@ -728,6 +745,16 @@ func setMakeCodeListener(name string, appIns *Application) {
context.Req.Method == "POST" { context.Req.Method == "POST" {
return isFinished return isFinished
} }
//分析
if len(context.RouterString) == 3 && context.RouterString[2] == "analyse" &&
context.Req.Method == "GET" {
if context.Router[context.RouterString[0]][context.RouterString[1]]["analyse"] == nil {
return isFinished
}
context.Router[context.RouterString[0]][context.RouterString[1]]["analyse"](context)
}
//查询单条 //查询单条
if len(context.RouterString) == 3 && if len(context.RouterString) == 3 &&
context.Req.Method == "GET" { context.Req.Method == "GET" {

295
code.go
View File

@ -8,6 +8,7 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"os" "os"
"sort"
"strings" "strings"
"time" "time"
) )
@ -22,16 +23,18 @@ var TptProject = Proj{
tableName := that.RouterString[1] tableName := that.RouterString[1]
data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()}) data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
str, inData := that.MakeCodeRouter[hotimeName].Info(tableName, data, that.Db) //str, inData := that.MakeCodeRouter[hotimeName].Info(tableName, data, that.Db)
str, _ := that.MakeCodeRouter[hotimeName].Info(tableName, data, that.Db)
where := Map{"id": that.RouterString[2]} where := Map{"id": that.RouterString[2]}
if len(inData) == 1 { //权限控制,暂时取消
inData["id"] = where["id"] //if len(inData) == 1 {
where = Map{"AND": inData} // inData["id"] = where["id"]
} else if len(inData) > 1 { // where = Map{"AND": inData}
where["OR"] = inData //} else if len(inData) > 1 {
where = Map{"AND": where} // where["OR"] = inData
} // where = Map{"AND": where}
//}
re := that.Db.Get(tableName, str, where) re := that.Db.Get(tableName, str, where)
@ -46,7 +49,7 @@ var TptProject = Proj{
continue continue
} }
if (column["list"] == nil || column.GetBool("list")) && column.GetString("link") != "" { if (column["info"] == nil || column.GetBool("info")) && column.GetString("link") != "" {
seStr := "id," + column.GetString("value") seStr := "id," + column.GetString("value")
if that.MakeCodeRouter[hotimeName].TableColumns[column.GetString("link")]["phone"] != nil { if that.MakeCodeRouter[hotimeName].TableColumns[column.GetString("link")]["phone"] != nil {
seStr = seStr + ",phone" seStr = seStr + ",phone"
@ -218,6 +221,9 @@ var TptProject = Proj{
} }
inData["parent_ids"] = parent_ids + ObjToStr(re) + "," inData["parent_ids"] = parent_ids + ObjToStr(re) + ","
that.Db.Update(tableName, Map{"parent_ids": inData["parent_ids"]}, Map{"id": re}) that.Db.Update(tableName, Map{"parent_ids": inData["parent_ids"]}, Map{"id": re})
} else {
inData["parent_ids"] = "," + ObjToStr(re) + ","
that.Db.Update(tableName, Map{"parent_ids": inData["parent_ids"]}, Map{"id": re})
} }
that.Log["table_id"] = re that.Log["table_id"] = re
@ -365,22 +371,28 @@ var TptProject = Proj{
} }
if inData.Get("parent_id") != nil { if _, ok := inData["parent_id"]; ok {
//1 //1
//12 62 //12 62
//123 623 //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") { if inData.GetCeilInt64("parent_id") == 0 {
parentIndex := that.Db.Get(tableName, "`parent_ids`", Map{"id": inData.Get("parent_id")}) that.Db.Update(tableName, Map{"parent_ids": "," + that.RouterString[2] + ","}, Map{"id": that.RouterString[2]})
if strings.Contains(parentIndex.GetString("parent_ids"), ","+that.RouterString[2]+",") { } else {
that.Display(4, "不能将子级设置为父级")
return Index := that.Db.Get(tableName, "parent_id,`parent_ids`", Map{"id": that.RouterString[2]})
} if inData.GetCeilInt64("parent_id") != Index.GetCeilInt64("parent_id") {
parent_ids := parentIndex.GetString("parent_ids") + that.RouterString[2] + "," parentIndex := that.Db.Get(tableName, "`parent_ids`", Map{"id": inData.Get("parent_id")})
childNodes := that.Db.Select(tableName, "id,`parent_ids`", Map{"parent_ids[~]": "," + that.RouterString[2] + ","}) if strings.Contains(parentIndex.GetString("parent_ids"), ","+that.RouterString[2]+",") {
for _, v := range childNodes { that.Display(4, "不能将子级设置为父级")
v["parent_ids"] = strings.Replace(v.GetString("parent_ids"), Index.GetString("parent_ids"), parent_ids, -1) return
that.Db.Update(tableName, Map{"parent_ids": v["parent_ids"]}, Map{"id": v.GetCeilInt("id")}) }
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"), parent_ids, -1)
that.Db.Update(tableName, Map{"parent_ids": v["parent_ids"]}, Map{"id": v.GetCeilInt("id")})
}
} }
} }
@ -490,7 +502,7 @@ var TptProject = Proj{
} }
//} //}
columnStr, leftJoin, where := that.MakeCodeRouter[hotimeName].Search(tableName, data, where, that.Req, that.Db) columnStr, where := that.MakeCodeRouter[hotimeName].Search(tableName, data, where, that.Req, that.Db)
page := ObjToInt(that.Req.FormValue("page")) page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize")) pageSize := ObjToInt(that.Req.FormValue("pageSize"))
@ -509,12 +521,12 @@ var TptProject = Proj{
var reData []Map var reData []Map
//是否下载 //是否下载
if download == 0 { if download == 0 {
count = that.Db.Count(tableName, leftJoin, where) count = that.Db.Count(tableName, where)
reData = that.Db.Page(page, pageSize). reData = that.Db.Page(page, pageSize).
PageSelect(tableName, leftJoin, columnStr, where) PageSelect(tableName, columnStr, where)
} }
if download == 1 { if download == 1 {
reData = that.Db.Select(tableName, leftJoin, columnStr, where) reData = that.Db.Select(tableName, columnStr, where)
} }
for _, v := range reData { for _, v := range reData {
@ -546,11 +558,11 @@ var TptProject = Proj{
column := that.MakeCodeRouter[hotimeName].TableColumns[tableName][k] column := that.MakeCodeRouter[hotimeName].TableColumns[tableName][k]
if column == nil { if column == nil || column["link"] == nil || !(column["list"] == nil || column["list"] == true) || v.GetCeilInt64(column.GetString("name")) == 0 {
break continue
} }
if (column["list"] == nil || column["list"] == true) && column["name"] == "parent_id" && column.GetString("link") != "" { if column["name"] == "parent_id" {
parentC := that.Db.Get(column.GetString("link"), column.GetString("value"), Map{"id": v.GetCeilInt(k)}) 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")] = "" v[column.GetString("link")+"_"+column.GetString("name")+"_"+column.GetString("value")] = ""
@ -559,6 +571,29 @@ var TptProject = Proj{
} }
} }
if column.GetString("name") != "parent_id" {
reStr := ""
if column.GetString("value") == "name" && that.MakeCodeRouter[hotimeName].TableColumns[column.GetString("link")]["nickname"] != nil {
reStr += "nickname,"
}
if that.MakeCodeRouter[hotimeName].TableColumns[column.GetString("link")]["phone"] != nil {
reStr += "phone,"
}
reStr += column.GetString("value")
joinData := that.Db.Get(column.GetString("link"), reStr, Map{"id": v.GetCeilInt64(column.GetString("name"))})
if joinData != nil {
for kj, vj := range joinData {
v[column.GetString("link")+"_"+column.GetString("name")+"_"+kj] = vj
}
}
}
//return isEnd //return isEnd
} }
} }
@ -652,6 +687,173 @@ var TptProject = Proj{
that.Display(0, Map{"count": count, "data": reData}) that.Display(0, Map{"count": count, "data": reData})
}, },
"analyse": func(that *Context) {
hotimeName := that.RouterString[0]
//hotimeName := "super"
fileConfig := that.MakeCodeRouter[hotimeName].FileConfig
tableName := that.RouterString[1]
data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
where := Map{}
//树状结构不允许修改自身的属性,修改别人的可以
btes, err := ioutil.ReadFile(fileConfig.GetString("config"))
if err != nil {
that.Display(4, "找不到权限配置文件")
return
}
conf := ObjToMap(string(btes))
//相同则
//if tableName!=fileConfig.GetString("table"){
flow := conf.GetMap("flow").GetMap(tableName)
if flow != nil && flow.GetMap("sql") != nil {
sql := ObjToMap(DeepCopyMap(flow.GetMap("sql")))
for k, _ := range sql {
//for uk,_:=range data{
// if sql[uk]==nil{
// continue
// }
// uv:=data.GetString(uk)
//
// tv:=strings.Replace(sql.GetString(uk),uk,uv,-1)
// if tv!=uv{
// where[k]=tv
// break
// }
//}
if k == "parent_ids[~]" && tableName == fileConfig.GetString("table") {
where[k] = strings.Replace(sql.GetString(k), "id", data.GetString("id"), -1)
continue
}
if k == "parent_ids[~]" && data[tableName+"_id"] != nil {
where[k] = strings.Replace(sql.GetString(k), tableName+"_id", data.GetString(tableName+"_id"), -1)
continue
}
if data[sql.GetString(k)] != nil {
where[k] = data[sql.GetString(k)]
}
}
}
//}
_, where = that.MakeCodeRouter[hotimeName].Search(tableName, data, where, that.Req, that.Db)
delete(where, "ORDER")
//page := ObjToInt(that.Req.FormValue("page"))
//pageSize := ObjToInt(that.Req.FormValue("pageSize"))
//download := ObjToInt(that.Req.FormValue("download"))
//
//if page < 1 {
// page = 1
//}
//
//if pageSize <= 0 {
// pageSize = 20
//}
redData := Map{}
data["count"] = that.Db.Count(tableName, where)
testQu := []string{}
testQuData := that.MakeCodeRouter[hotimeName].TableColumns[tableName]
for key, _ := range testQuData {
//fmt.Println(key, ":", value)
testQu = append(testQu, key)
}
sort.Strings(testQu)
for _, k := range testQu {
v := testQuData[k]
//不可使用,未在前端展示,但在内存中保持有
if v.GetBool("notUse") {
continue
}
if strings.Contains(k, "state") {
continue
}
if strings.Contains(k, "scope") {
continue
}
if strings.Contains(k, "_code") {
continue
}
//检索查询
if v.GetString("type") == "select" {
ops := v.GetSlice("options")
for k1, _ := range ops {
v1 := ops.GetMap(k1)
where1 := DeepCopyMap(where).(Map)
if where1["AND"] != nil {
and := where1.GetMap("AND")
and[k] = v1.GetString("value")
} else {
where1[k] = v1.GetString("value")
where1 = Map{"AND": where1}
}
v1["count"] = that.Db.Count(tableName, where1)
ops[k1] = v1
}
redData[k] = ops
}
//检索查询
if v.GetString("type") == "number" {
if strings.Contains(k, "area_id") {
areas := that.Db.Select("area", "id,name", Map{"parent_id": 533301})
for ak, av := range areas {
where1 := DeepCopyMap(where).(Map)
if where1["AND"] != nil {
and := where1.GetMap("AND")
and["area_id"] = av.GetCeilInt64("id")
} else {
where1["area_id"] = av.GetCeilInt64("id")
where1 = Map{"AND": where1}
}
av["count"] = that.Db.Count(tableName, where1)
areas[ak] = av
}
redData["area"] = areas
continue
}
if strings.Contains(k, "_id") {
continue
}
if k == "id" {
continue
}
if strings.Contains(k, "percent") {
continue
}
if strings.Contains(k, "exp_") {
continue
}
if strings.Contains(k, "side") {
continue
}
if strings.Contains(k, "lat") {
continue
}
if strings.Contains(k, "lng") {
continue
}
if strings.Contains(k, "distance") {
continue
}
where1 := DeepCopyMap(where).(Map)
redData[k] = that.Db.Sum(tableName, k, where1)
}
}
that.Display(0, redData)
},
}, },
"hotime": Ctr{ "hotime": Ctr{
"file": func(that *Context) { "file": func(that *Context) {
@ -843,11 +1045,12 @@ var TptProject = Proj{
} }
linkAuthMap := that.Db.Get(v.GetString("link"), "auth", Map{"id": user.GetCeilInt(v.GetString("name"))}) linkAuthMap := that.Db.Get(v.GetString("link"), "auth", Map{"id": user.GetCeilInt(v.GetString("name"))})
linkAuth := linkAuthMap.GetMap("auth") oldLinkAuth := linkAuthMap.GetMap("auth")
linkAuth := Map{}
//conf := ObjToMap(string(btes)) //conf := ObjToMap(string(btes))
//menus := conf.GetSlice("menus") //menus := conf.GetSlice("menus")
if linkAuth == nil { if oldLinkAuth != nil {
linkAuth = Map{} linkAuth = oldLinkAuth
} }
for k1, _ := range menus { for k1, _ := range menus {
@ -858,7 +1061,7 @@ var TptProject = Proj{
} }
if v1["auth"] != nil { if v1["auth"] != nil {
if linkAuth[name] == nil { if oldLinkAuth == nil {
linkAuth[name] = v1["auth"] linkAuth[name] = v1["auth"]
} else { } else {
newAuth := Slice{} newAuth := Slice{}
@ -881,7 +1084,7 @@ var TptProject = Proj{
} }
if v2["auth"] != nil { if v2["auth"] != nil {
if linkAuth[name] == nil { if oldLinkAuth == nil {
linkAuth[name] = v2["auth"] linkAuth[name] = v2["auth"]
} else { } else {
@ -903,32 +1106,36 @@ var TptProject = Proj{
for k1, _ := range menus { for k1, _ := range menus {
v1 := menus.GetMap(k1) v1 := menus.GetMap(k1)
//保证个人权限可用
if fileConfig.GetString("table") == v1.GetString("table") {
v1["auth"] = Slice{"info", "edit"}
}
name := v1.GetString("name") name := v1.GetString("name")
if name == "" { if name == "" {
name = v1.GetString("table") name = v1.GetString("table")
} }
if linkAuth[name] != nil { if len(linkAuth.GetSlice(name)) != 0 {
v1["auth"] = linkAuth[name]
} else
//保证个人权限可用
if fileConfig.GetString("table") == v1.GetString("table") {
v1["auth"] = Slice{"info", "edit"}
} else {
v1["auth"] = linkAuth[name] v1["auth"] = linkAuth[name]
} }
v1menus := v1.GetSlice("menus") v1menus := v1.GetSlice("menus")
for k2, _ := range v1menus { for k2, _ := range v1menus {
v2 := v1menus.GetMap(k2) v2 := v1menus.GetMap(k2)
//保证个人权限可用 //保证个人权限可用
if fileConfig.GetString("table") == v2.GetString("table") {
v2["auth"] = Slice{"info", "edit"}
}
name := v2.GetString("name") name := v2.GetString("name")
if name == "" { if name == "" {
name = v2.GetString("table") name = v2.GetString("table")
} }
if linkAuth[name] != nil { if len(linkAuth.GetSlice(name)) != 0 {
v2["auth"] = linkAuth[name]
} else if fileConfig.GetString("table") == v2.GetString("table") {
v2["auth"] = Slice{"info", "edit"}
} else {
v2["auth"] = linkAuth[name] v2["auth"] = linkAuth[name]
} }

View File

@ -116,7 +116,7 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
nowTables = db.Select("INFORMATION_SCHEMA.TABLES", "TABLE_NAME as name,TABLE_COMMENT as label", Map{"TABLE_SCHEMA": db.DBName}) nowTables = db.Select("INFORMATION_SCHEMA.TABLES", "TABLE_NAME as name,TABLE_COMMENT as label", Map{"TABLE_SCHEMA": db.DBName})
} }
if db.Type == "sqlite" { if db.Type == "sqlite" {
nowTables = db.Select("sqlite_sequence", "name") nowTables = db.Select("sqlite_master", "name", Map{"type": "table"})
} }
//idSlice=append(idSlice,nowTables) //idSlice=append(idSlice,nowTables)
for _, v := range nowTables { for _, v := range nowTables {
@ -158,7 +158,7 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
tableInfo := make([]Map, 0) tableInfo := make([]Map, 0)
if db.Type == "mysql" { if db.Type == "mysql" {
tableInfo = db.Select("INFORMATION_SCHEMA.COLUMNS", "COLUMN_NAME AS name,COLUMN_TYPE AS type,COLUMN_COMMENT AS label", Map{"AND": Map{"TABLE_SCHEMA": db.DBName, "TABLE_NAME": v.GetString("name")}}) tableInfo = db.Select("INFORMATION_SCHEMA.COLUMNS", "COLUMN_NAME AS name,COLUMN_TYPE AS type,COLUMN_COMMENT AS label,IS_NULLABLE AS must,COLUMN_DEFAULT AS dflt_value", Map{"AND": Map{"TABLE_SCHEMA": db.DBName, "TABLE_NAME": v.GetString("name")}})
} }
if db.Type == "sqlite" { if db.Type == "sqlite" {
tableInfo = db.Query("pragma table_info([" + v.GetString("name") + "]);") tableInfo = db.Query("pragma table_info([" + v.GetString("name") + "]);")
@ -175,8 +175,9 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
if coloum == nil { if coloum == nil {
//根据类型判断真实类型 //根据类型判断真实类型
for k, v1 := range ColumnDataType { for k, v1 := range ColumnDataType {
if strings.Contains(info.GetString("name"), k) || strings.Contains(info.GetString("type"), k) { if strings.Contains(info.GetString("type"), k) {
info["type"] = v1 info["type"] = v1
break
} }
} }
@ -188,6 +189,18 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
//"must": false, //"must": false,
} }
if info.GetString("must") == "NO" {
coloum["must"] = true
}
if info["dflt_value"] != nil {
coloum["default"] = info["dflt_value"]
}
if info["pk"] != nil && info.GetCeilInt64("pk") == 1 {
coloum["must"] = true
}
//备注以空格隔开,空格后的是其他备注 //备注以空格隔开,空格后的是其他备注
indexNum := strings.Index(info.GetString("label"), " ") indexNum := strings.Index(info.GetString("label"), " ")
if indexNum > -1 { if indexNum > -1 {
@ -208,7 +221,7 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
for _, ColumnName := range that.RuleConfig { for _, ColumnName := range that.RuleConfig {
if (ColumnName.GetBool("strict") && coloum.GetString("name") == ColumnName.GetString("name")) || if (ColumnName.GetBool("strict") && coloum.GetString("name") == ColumnName.GetString("name")) ||
(!ColumnName.GetBool("strict") && strings.Contains(coloum.GetString("name"), ColumnName.GetString("name"))) || (!ColumnName.GetBool("strict") && strings.Contains(coloum.GetString("name"), ColumnName.GetString("name"))) ||
(info.GetString("name")+"."+coloum.GetString("name") == ColumnName.GetString("name")) { (v.GetString("name")+"."+coloum.GetString("name") == ColumnName.GetString("name")) {
//全部都不需要则不加入 //全部都不需要则不加入
if ColumnName.GetBool("edit") == false && ColumnName.GetBool("list") == false && ColumnName.GetBool("info") == false { if ColumnName.GetBool("edit") == false && ColumnName.GetBool("list") == false && ColumnName.GetBool("info") == false {
coloum["notUse"] = true coloum["notUse"] = true
@ -218,7 +231,15 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
coloum["edit"] = ColumnName.GetBool("edit") coloum["edit"] = ColumnName.GetBool("edit")
coloum["add"] = ColumnName["add"] coloum["add"] = ColumnName["add"]
coloum["list"] = ColumnName.GetBool("list") coloum["list"] = ColumnName.GetBool("list")
coloum["must"] = ColumnName.GetBool("must") //coloum["must"] = ColumnName.GetBool("must")
if coloum["must"] == nil {
coloum["must"] = ColumnName.GetBool("must")
} else {
if ColumnName["must"] != nil {
coloum["must"] = ColumnName.GetBool("must")
}
}
if ColumnName.GetBool("info") { if ColumnName.GetBool("info") {
delete(coloum, "info") delete(coloum, "info")
@ -539,7 +560,7 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
} }
sql := flow.GetMap(fk).GetMap("sql") sql := flow.GetMap(fk).GetMap("sql")
if k == "parent_id" { if k == "parent_id" {
sql["parent_ids[~]"] = "%," + av.GetString("name") + ",%" sql["parent_ids[~]"] = "," + av.GetString("name") + ","
} else { } else {
sql[k] = k sql[k] = k
} }
@ -580,7 +601,7 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
flow[fk] = Map{"table": fk, "stop": false, "sql": Map{}} flow[fk] = Map{"table": fk, "stop": false, "sql": Map{}}
} }
sql := flow.GetMap(fk).GetMap("sql") sql := flow.GetMap(fk).GetMap("sql")
sql["parent_ids[~]"] = "%,id,%" sql["parent_ids[~]"] = ",id,"
flow.GetMap(fk)["sql"] = sql flow.GetMap(fk)["sql"] = sql
} }
@ -743,17 +764,23 @@ func (that *MakeCode) Add(table string, user Map, req *http.Request) Map {
} }
reqValue := req.FormValue(v.GetString("name")) if req.Form[v.GetString("name")] == nil {
if (reqValue == "" || reqValue == "null") && strings.Contains(v.GetString("name"), "id") { continue
data[v.GetString("name")] = nil
} else {
if v.GetString("type") == "password" {
data[v.GetString("name")] = Md5(reqValue)
} else {
data[v.GetString("name")] = reqValue
}
} }
reqValue := req.FormValue(v.GetString("name"))
if reqValue == "null" {
data[v.GetString("name")] = nil
continue
}
if v.GetString("type") == "password" {
data[v.GetString("name")] = Md5(reqValue)
continue
}
data[v.GetString("name")] = reqValue
} }
//sn则自动生成 //sn则自动生成
if v.GetString("name") == "sn" { if v.GetString("name") == "sn" {
@ -802,13 +829,21 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map {
} }
if v.Get("edit") == nil || v.GetBool("edit") { if v.Get("edit") == nil || v.GetBool("edit") {
if len(req.Form[v.GetString("name")]) == 0 { if len(req.Form[v.GetString("name")]) == 0 {
continue continue
} }
reqValue := req.FormValue(v.GetString("name")) reqValue := req.FormValue(v.GetString("name"))
if reqValue == "null" { if reqValue == "null" {
data[v.GetString("name")] = nil
continue continue
} }
if v.GetString("type") == "number" && reqValue == "" {
data[v.GetString("name")] = nil
continue
}
if v.GetString("type") == "password" { if v.GetString("type") == "password" {
data[v.GetString("name")] = Md5(reqValue) data[v.GetString("name")] = Md5(reqValue)
} else { } else {
@ -847,9 +882,9 @@ func (that *MakeCode) Delete(table string, req *http.Request) Map {
return data return data
} }
func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Request, db *db.HoTimeDB) (string, Map, Map) { func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Request, db *db.HoTimeDB) (string, Map) {
reStr := "" reStr := ""
leftJoin := Map{} //leftJoin := Map{}
//data := Map{} //data := Map{}
if data == nil { if data == nil {
data = Map{} data = Map{}
@ -881,46 +916,48 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if v["list"] != false { if v["list"] != false {
if v.GetString("link") != "" && //if v.GetString("link") != "" &&
v.GetString("name") != "parent_id" { // v.GetString("name") != "parent_id" {
//
reStr += table + "." + v.GetString("name") + "," + // reStr += table + "." + v.GetString("name") + ","
v.GetString("link") + "." + v.GetString("value") + " AS " + // //+
v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + "," // // v.GetString("link") + "." + v.GetString("value") + " AS " +
// // v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
if v.GetString("value") == "name" && that.TableColumns[v.GetString("link")]["nickname"] != nil { //
reStr += v.GetString("link") + ".nickname AS " + // if v.GetString("value") == "name" && that.TableColumns[v.GetString("link")]["nickname"] != nil {
v.GetString("link") + "_" + v.GetString("name") + "_nickname," // reStr += v.GetString("link") + ".nickname AS " +
} // v.GetString("link") + "_" + v.GetString("name") + "_nickname,"
// }
if that.TableColumns[v.GetString("link")]["phone"] != nil { //
reStr += v.GetString("link") + ".phone AS " + // if that.TableColumns[v.GetString("link")]["phone"] != nil {
v.GetString("link") + "_" + v.GetString("name") + "_phone," // reStr += v.GetString("link") + ".phone AS " +
} // v.GetString("link") + "_" + v.GetString("name") + "_phone,"
// }
leftJoin["[>]"+v.GetString("link")] = //
table + "." + v.GetString("name") + "=" + // leftJoin["[>]"+v.GetString("link")] =
v.GetString("link") + ".id" // table + "." + v.GetString("name") + "=" +
if v.GetString("link") == "admin" { // v.GetString("link") + ".id"
hasUser = true //
} // if v.GetString("link") == "admin" {
// hasUser = true
reqValue := req.FormValue(v.GetString("name")) // }
if reqValue != "" { //
data[table+"."+v.GetString("name")] = reqValue reqValue := req.FormValue(v.GetString("name"))
} if v.GetString("name") != "parent_id" && reqValue != "" {
data[v.GetString("name")] = reqValue
} else {
reStr += table + "." + v.GetString("name") + ","
} }
//
//} else {
if v["name"] == "parent_id" && v.GetString("link") != "" { reStr += "`" + v.GetString("name") + "`,"
leftJoin["[>]"+v.GetString("link")+" selfParent"] = //}
"selfParent.id=" +
v.GetString("link") + "." + v.GetString("name") //if v["name"] == "parent_id" && v.GetString("link") != "" {
reStr += "selfParent." + v.GetString("value") + " AS " + v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + "," // leftJoin["[>]"+v.GetString("link")+" selfParent"] =
} // "selfParent.id=" +
// v.GetString("link") + "." + v.GetString("name")
// reStr += "selfParent." + v.GetString("value") + " AS " + v.GetString("link") + "_" + v.GetString("name") + "_" + v.GetString("value") + ","
//}
//准备加入索引权限 //准备加入索引权限
if v.GetString("link") != "" && if v.GetString("link") != "" &&
@ -970,7 +1007,7 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if strings.Contains(v.GetString("type"), "text") { if strings.Contains(v.GetString("type"), "text") {
reqValue := req.FormValue(v.GetString("name")) reqValue := req.FormValue(v.GetString("name"))
if reqValue != "" { if reqValue != "" {
data[table+"."+v.GetString("name")+"[~]"] = reqValue data[v.GetString("name")+"[~]"] = reqValue
} }
} }
@ -978,9 +1015,9 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if v.GetString("type") == "unixtime" { if v.GetString("type") == "unixtime" {
if len(req.Form[v.GetString("name")]) == 1 { if len(req.Form[v.GetString("name")]) == 1 {
daterange[table+"."+v.GetString("name")+"[>]"] = req.FormValue("daterange") daterange[v.GetString("name")+"[>]"] = req.FormValue("daterange")
} else if len(req.Form[v.GetString("name")]) == 2 { } else if len(req.Form[v.GetString("name")]) == 2 {
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"]) daterange[v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
} }
//fmt.Println(req.Form["daterange"]) //fmt.Println(req.Form["daterange"])
@ -993,12 +1030,12 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if len(req.Form[v.GetString("name")]) == 1 { 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") t := time.Unix(ObjToCeilInt64(req.FormValue(v.GetString("name"))), 0).Format("2006-01-02 15:04:05")
daterange[table+"."+v.GetString("name")+"[>]"] = t daterange[v.GetString("name")+"[>]"] = t
} else if len(req.Form[v.GetString("name")]) == 2 { } 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") 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") 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} daterange[v.GetString("name")+"[<>]"] = Slice{t1, t2}
} }
} }
@ -1032,15 +1069,18 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if len(reqValue) == 0 || reqValue[0] == "" { if len(reqValue) == 0 || reqValue[0] == "" {
if parent_idsStr != "" && userData[searchItem.GetString("name")] != nil { if parent_idsStr != "" && userData[searchItem.GetString("name")] != nil {
if data[searchItemName] == nil {
continue
}
where := Map{parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ","} where := Map{parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ","}
r := db.Select(searchItem.GetString("link"), "id", where) r := db.Select(searchItem.GetString("link"), "id", where)
reqValue = []string{} reqValue = []string{}
for _, v := range r { for _, v := range r {
reqValue = append(reqValue, v.GetString("id")) reqValue = append(reqValue, v.GetString("id"))
} }
if data[table+"."+searchItemName] != nil {
data[table+"."+searchItemName] = reqValue data[searchItemName] = reqValue
}
} }
@ -1063,10 +1103,10 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if v.GetString("type") == "unixtime" { if v.GetString("type") == "unixtime" {
//fmt.Println(req.Form["daterange"]) //fmt.Println(req.Form["daterange"])
if len(req.Form["daterange"]) == 1 && req.Form["daterange"][0] != "" { if len(req.Form["daterange"]) == 1 && req.Form["daterange"][0] != "" {
daterange[table+"."+v.GetString("name")+"[>]"] = req.FormValue("daterange") daterange[v.GetString("name")+"[>]"] = req.FormValue("daterange")
} else if len(req.Form["daterange"]) == 2 { } else if len(req.Form["daterange"]) == 2 {
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"]) daterange[v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
} }
} }
if v.GetString("type") == "time" { if v.GetString("type") == "time" {
@ -1075,12 +1115,12 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if len(req.Form["daterange"]) == 1 && req.Form["daterange"][0] != "" { 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") t := time.Unix(ObjToCeilInt64(req.FormValue("daterange")), 0).Format("2006-01-02 15:04:05")
daterange[table+"."+v.GetString("name")+"[>]"] = t daterange[v.GetString("name")+"[>]"] = t
} else if len(req.Form["daterange"]) == 2 { } else if len(req.Form["daterange"]) == 2 {
t1 := time.Unix(ObjToCeilInt64(req.Form["daterange"][0]), 0).Format("2006-01-02 15:04:05") t1 := time.Unix(ObjToCeilInt64(req.Form["daterange"][0]), 0).Format("2006-01-02 15:04:05")
t2 := time.Unix(ObjToCeilInt64(req.Form["daterange"][1]), 0).Format("2006-01-02 15:04:05") t2 := time.Unix(ObjToCeilInt64(req.Form["daterange"][1]), 0).Format("2006-01-02 15:04:05")
daterange[table+"."+v.GetString("name")+"[<>]"] = Slice{t1, t2} daterange[v.GetString("name")+"[<>]"] = Slice{t1, t2}
} }
} }
@ -1090,38 +1130,40 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if keywordTableStr != "" { if keywordTableStr != "" {
if keywordTableStr == v.GetString("name") { if keywordTableStr == v.GetString("name") {
data[table+"."+keywordTableStr+"[~]"] = keywordStr data[keywordTableStr+"[~]"] = keywordStr
} }
if keywordTableStr == v.GetString("value") { if keywordTableStr == v.GetString("value") {
childs := db.Select(v.GetString("link"), "id", Map{v.GetString("value") + "[~]": keywordStr}) childs := db.Select(v.GetString("link"), "id", Map{v.GetString("value") + "[~]": keywordStr})
childIds := Slice{} childIds := Slice{}
for _, cv := range childs { for _, cv := range childs {
childIds = append(childIds, cv.GetString("id"))
childIds = append(childIds, cv.GetCeilInt64("id"))
} }
if len(childIds) != 0 { if len(childIds) != 0 {
data[v.GetString("link")+".id"] = childIds data[v.GetString("name")] = childIds
} }
} }
continue continue
} }
if strings.Contains(v.GetString("type"), "text") { if strings.Contains(v.GetString("type"), "text") {
keyword[table+"."+v.GetString("name")+"[~]"] = keywordStr keyword[v.GetString("name")+"[~]"] = keywordStr
} }
if v.GetString("name") == "id" { if v.GetString("name") == "id" {
keyword[table+"."+v.GetString("name")] = keywordStr keyword[v.GetString("name")] = keywordStr
} }
if v.GetString("link") != "" && if v.GetString("link") != "" &&
v.GetString("name") != "parent_id" { v.GetString("name") != "parent_id" {
childs := db.Select(v.GetString("link"), "id", Map{v.GetString("value") + "[~]": keywordStr}) childs := db.Select(v.GetString("link"), "id", Map{v.GetString("value") + "[~]": keywordStr})
childIds := Slice{} childIds := Slice{}
for _, cv := range childs { for _, cv := range childs {
childIds = append(childIds, cv.GetString("id")) childIds = append(childIds, cv.GetCeilInt64("id"))
} }
if len(childIds) != 0 { if len(childIds) != 0 {
keyword[v.GetString("link")+".id"] = childIds keyword[v.GetString("name")] = childIds
} }
} }
@ -1130,7 +1172,7 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
} }
if len(reqValue) != 0 && searchItem.GetString("name") == "sort" && reqValue[0] != "" { if len(reqValue) != 0 && searchItem.GetString("name") == "sort" && reqValue[0] != "" {
sortMap["ORDER"] = table + "." + reqValue[0] sortMap["ORDER"] = reqValue[0]
} }
continue continue
@ -1141,7 +1183,7 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
parentID := ObjToInt(req.FormValue("parent_id")) parentID := ObjToInt(req.FormValue("parent_id"))
if parentID == 0 { if parentID == 0 {
parentID = userData.GetCeilInt(table + "_id") parentID = userData.GetCeilInt(table + "_id")
data["OR"] = Map{table + ".id": parentID, table + ".parent_id": nil} data["OR"] = Map{"id": parentID, "parent_id": nil}
} else { } else {
//是否展示全部子级 //是否展示全部子级
where := Map{} where := Map{}
@ -1149,21 +1191,21 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
for _, v := range reqValue { for _, v := range reqValue {
if len(where) == 0 { if len(where) == 0 {
where[table+"."+parent_idsStr] = "," + v + "," where[parent_idsStr] = "," + v + ","
continue continue
} }
where = Map{"OR": where, table + "." + parent_idsStr: "," + v + ","} where = Map{"OR": where, parent_idsStr: "," + v + ","}
} }
} else { } else {
where[table+".parent_id"] = reqValue where["parent_id"] = reqValue
} }
//是否展示自己 //是否展示自己
if req.FormValue("showself") == "1" { if req.FormValue("showself") == "1" {
if len(where) == 0 { if len(where) == 0 {
data["OR"] = Map{table + ".id": reqValue} data["OR"] = Map{"id": reqValue}
} else { } else {
data["OR"] = Map{"OR": where, table + ".id": reqValue} data["OR"] = Map{"OR": where, "id": reqValue}
} }
} else { } else {
if len(where) != 0 { if len(where) != 0 {
@ -1179,26 +1221,37 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
if parent_idsStr != "" { if parent_idsStr != "" {
where := Map{} //where := Map{}
//是否全部展示 //是否全部展示
if req.FormValue("showall") != "1" { if req.FormValue("showall") != "1" {
where[table+"."+searchItem.GetString("name")] = reqValue if len(reqValue) != 0 {
data[searchItem.GetString("name")] = reqValue
}
} else { } else {
ls := []int64{}
for _, v := range reqValue { for _, v := range reqValue {
if len(where) == 0 {
where[searchItem.GetString("link")+"."+parent_idsStr] = "," + v + "," ls1 := db.Select(searchItem.GetString("link"), "id", Map{"OR": Map{parent_idsStr: "," + v + ",", "id": v}})
continue for _, vls1 := range ls1 {
ls = append(ls, vls1.GetCeilInt64("id"))
} }
where = Map{"OR": where, searchItem.GetString("link") + "." + parent_idsStr: "," + v + ","} }
if len(ls) != 0 {
data[searchItem.GetString("name")] = ls
} }
} }
//用户 //用户
if userData[searchItem.GetString("name")] != nil { //if userData[searchItem.GetString("name")] != nil {
//
where = Map{"AND": Map{searchItem.GetString("link") + "." + parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ",", "OR": where}} // where = Map{"AND": Map{searchItem.GetString("link") + "." + parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ",", "OR": where}}
} //}
data["OR"] = where //if len(where)!=0{
// data["OR"] = where
//}
continue continue
//r := db.Select(searchItem.GetString("link"), "id", where) //r := db.Select(searchItem.GetString("link"), "id", where)
@ -1210,13 +1263,13 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
} }
if len(reqValue) != 0 && reqValue[0] != "" { if len(reqValue) != 0 && reqValue[0] != "" {
data[table+"."+searchItemName] = reqValue data[searchItemName] = reqValue
} }
} }
if sortMap["ORDER"] == nil { if sortMap["ORDER"] == nil {
sortMap["ORDER"] = table + ".id DESC" sortMap["ORDER"] = "id DESC"
} }
where := Map{} where := Map{}
@ -1273,5 +1326,5 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
} }
} }
return reStr, leftJoin, where return reStr, where
} }

View File

@ -8,10 +8,10 @@ import (
"time" "time"
) )
//hotime的常用map // hotime的常用map
type Map map[string]interface{} type Map map[string]interface{}
//获取string // 获取string
func (that Map) GetString(key string, err ...*Error) string { func (that Map) GetString(key string, err ...*Error) string {
if len(err) != 0 { if len(err) != 0 {
@ -26,7 +26,7 @@ func (that *Map) Pointer() *Map {
return that return that
} }
//增加接口 // 增加接口
func (that Map) Put(key string, value interface{}) { func (that Map) Put(key string, value interface{}) {
//if that==nil{ //if that==nil{
// that=Map{} // that=Map{}
@ -34,13 +34,13 @@ func (that Map) Put(key string, value interface{}) {
that[key] = value that[key] = value
} }
//删除接口 // 删除接口
func (that Map) Delete(key string) { func (that Map) Delete(key string) {
delete(that, key) delete(that, key)
} }
//获取Int // 获取Int
func (that Map) GetInt(key string, err ...*Error) int { func (that Map) GetInt(key string, err ...*Error) int {
v := ObjToInt((that)[key], err...) v := ObjToInt((that)[key], err...)
@ -48,35 +48,35 @@ func (that Map) GetInt(key string, err ...*Error) int {
} }
//获取Int // 获取Int
func (that Map) GetInt64(key string, err ...*Error) int64 { func (that Map) GetInt64(key string, err ...*Error) int64 {
v := ObjToInt64((that)[key], err...) v := ObjToInt64((that)[key], err...)
return v return v
} }
//获取向上取整Int64 // 获取向上取整Int64
func (that Map) GetCeilInt64(key string, err ...*Error) int64 { func (that Map) GetCeilInt64(key string, err ...*Error) int64 {
v := ObjToCeilInt64((that)[key], err...) v := ObjToCeilInt64((that)[key], err...)
return v return v
} }
//获取向上取整Int // 获取向上取整Int
func (that Map) GetCeilInt(key string, err ...*Error) int { func (that Map) GetCeilInt(key string, err ...*Error) int {
v := ObjToCeilInt((that)[key], err...) v := ObjToCeilInt((that)[key], err...)
return v return v
} }
//获取向上取整float64 // 获取向上取整float64
func (that Map) GetCeilFloat64(key string, err ...*Error) float64 { func (that Map) GetCeilFloat64(key string, err ...*Error) float64 {
v := ObjToCeilFloat64((that)[key], err...) v := ObjToCeilFloat64((that)[key], err...)
return v return v
} }
//获取Float64 // 获取Float64
func (that Map) GetFloat64(key string, err ...*Error) float64 { func (that Map) GetFloat64(key string, err ...*Error) float64 {
v := ObjToFloat64((that)[key], err...) v := ObjToFloat64((that)[key], err...)
@ -102,7 +102,7 @@ func (that Map) GetBool(key string, err ...*Error) bool {
} }
func (that Map) GetTime(key string, err ...*Error) time.Time { func (that Map) GetTime(key string, err ...*Error) *time.Time {
v := ObjToTime((that)[key], err...) v := ObjToTime((that)[key], err...)
return v return v
@ -149,7 +149,7 @@ func (that Map) Get(key string, err ...*Error) interface{} {
return nil return nil
} }
//请传递指针过来 // 请传递指针过来
func (that Map) ToStruct(stct interface{}) { func (that Map) ToStruct(stct interface{}) {
data := reflect.ValueOf(stct).Elem() data := reflect.ValueOf(stct).Elem()

View File

@ -2,7 +2,7 @@ package common
import "time" import "time"
//对象封装方便取用 // 对象封装方便取用
type Obj struct { type Obj struct {
Data interface{} Data interface{}
Error Error
@ -20,7 +20,7 @@ func (that *Obj) ToInt(err ...Error) int {
return ObjToInt(that.Data, &that.Error) return ObjToInt(that.Data, &that.Error)
} }
func (that *Obj) ToTime(err ...Error) time.Time { func (that *Obj) ToTime(err ...Error) *time.Time {
if len(err) != 0 { if len(err) != 0 {
that.Error = err[0] that.Error = err[0]
} }
@ -82,7 +82,7 @@ func (that *Obj) ToObj() interface{} {
return that.Data return that.Data
} }
//获取向上取整Int64 // 获取向上取整Int64
func (that *Obj) ToCeilInt64(err ...*Error) int64 { func (that *Obj) ToCeilInt64(err ...*Error) int64 {
if len(err) != 0 { if len(err) != 0 {
that.Error = *err[0] that.Error = *err[0]
@ -92,7 +92,7 @@ func (that *Obj) ToCeilInt64(err ...*Error) int64 {
} }
//获取向上取整Int // 获取向上取整Int
func (that *Obj) ToCeilInt(err ...*Error) int { func (that *Obj) ToCeilInt(err ...*Error) int {
if len(err) != 0 { if len(err) != 0 {
that.Error = *err[0] that.Error = *err[0]

View File

@ -5,10 +5,11 @@ import (
"errors" "errors"
"math" "math"
"strconv" "strconv"
"strings"
"time" "time"
) )
//仅限于hotime.Slice // 仅限于hotime.Slice
func ObjToMap(obj interface{}, e ...*Error) Map { func ObjToMap(obj interface{}, e ...*Error) Map {
var err error var err error
var v Map var v Map
@ -59,7 +60,7 @@ func ObjToMapArray(obj interface{}, e ...*Error) []Map {
return res return res
} }
//仅限于hotime.Slice // 仅限于hotime.Slice
func ObjToSlice(obj interface{}, e ...*Error) Slice { func ObjToSlice(obj interface{}, e ...*Error) Slice {
var err error var err error
var v Slice var v Slice
@ -97,37 +98,52 @@ func ObjToSlice(obj interface{}, e ...*Error) Slice {
return v return v
} }
func ObjToTime(obj interface{}, e ...*Error) time.Time { func ObjToTime(obj interface{}, e ...*Error) *time.Time {
tInt := ObjToInt64(obj) tInt := ObjToInt64(obj)
//字符串类型只支持标准mysql datetime格式 //字符串类型只支持标准mysql datetime格式
if tInt == 0 { if tInt == 0 {
tStr := ObjToStr(obj) tStr := ObjToStr(obj)
timeNewStr := ""
timeNewStrs := strings.Split(tStr, "-")
for _, v := range timeNewStrs {
if v == "" {
continue
}
if len(v) == 1 {
v = "0" + v
}
if timeNewStr == "" {
timeNewStr = v
continue
}
timeNewStr = timeNewStr + "-" + v
}
tStr = timeNewStr
if len(tStr) > 18 { if len(tStr) > 18 {
t, e := time.Parse("2006-01-02 15:04:05", tStr) t, e := time.Parse("2006-01-02 15:04:05", tStr)
if e == nil { if e == nil {
return t return &t
} }
} else if len(tStr) > 15 { } else if len(tStr) > 15 {
t, e := time.Parse("2006-01-02 15:04", tStr) t, e := time.Parse("2006-01-02 15:04", tStr)
if e == nil { if e == nil {
return t return &t
} }
} else if len(tStr) > 12 { } else if len(tStr) > 12 {
t, e := time.Parse("2006-01-02 15", tStr) t, e := time.Parse("2006-01-02 15", tStr)
if e == nil { if e == nil {
return t return &t
} }
} else if len(tStr) > 9 { } else if len(tStr) > 9 {
t, e := time.Parse("2006-01-02", tStr) t, e := time.Parse("2006-01-02", tStr)
if e == nil { if e == nil {
return t return &t
} }
} else if len(tStr) > 6 { } else if len(tStr) > 6 {
t, e := time.Parse("2006-01", tStr) t, e := time.Parse("2006-01", tStr)
if e == nil { if e == nil {
return t return &t
} }
} }
@ -135,28 +151,32 @@ func ObjToTime(obj interface{}, e ...*Error) time.Time {
//纳秒级别 //纳秒级别
if len(ObjToStr(tInt)) > 16 { if len(ObjToStr(tInt)) > 16 {
t := time.Time{}.Add(time.Nanosecond * time.Duration(tInt)) //t := time.Time{}.Add(time.Nanosecond * time.Duration(tInt))
return t t := time.UnixMicro(tInt / 1000)
return &t
//微秒级别 //微秒级别
} else if len(ObjToStr(tInt)) > 13 { } else if len(ObjToStr(tInt)) > 13 {
t := time.Time{}.Add(time.Microsecond * time.Duration(tInt)) //t := time.Time{}.Add(time.Microsecond * time.Duration(tInt))
return t t := time.UnixMicro(tInt)
return &t
//毫秒级别 //毫秒级别
} else if len(ObjToStr(tInt)) > 10 { } else if len(ObjToStr(tInt)) > 10 {
t := time.Time{}.Add(time.Millisecond * time.Duration(tInt)) //t := time.Time{}.Add(time.Millisecond * time.Duration(tInt))
return t t := time.UnixMilli(tInt)
return &t
//秒级别 //秒级别
} else if len(ObjToStr(tInt)) > 9 { } else if len(ObjToStr(tInt)) > 9 {
t := time.Time{}.Add(time.Second * time.Duration(tInt)) //t := time.Time{}.Add(time.Second * time.Duration(tInt))
return t t := time.Unix(tInt, 0)
return &t
} else if len(ObjToStr(tInt)) > 3 { } else if len(ObjToStr(tInt)) > 3 {
t, e := time.Parse("2006", ObjToStr(tInt)) t, e := time.Parse("2006", ObjToStr(tInt))
if e == nil { if e == nil {
return t return &t
} }
} }
return time.Time{} return nil
} }
func ObjToFloat64(obj interface{}, e ...*Error) float64 { func ObjToFloat64(obj interface{}, e ...*Error) float64 {
@ -214,21 +234,21 @@ func ObjToFloat64(obj interface{}, e ...*Error) float64 {
return v return v
} }
//向上取整 // 向上取整
func ObjToCeilInt64(obj interface{}, e ...*Error) int64 { func ObjToCeilInt64(obj interface{}, e ...*Error) int64 {
f := ObjToCeilFloat64(obj, e...) f := ObjToCeilFloat64(obj, e...)
return ObjToInt64(math.Ceil(f)) return ObjToInt64(math.Ceil(f))
} }
//向上取整 // 向上取整
func ObjToCeilFloat64(obj interface{}, e ...*Error) float64 { func ObjToCeilFloat64(obj interface{}, e ...*Error) float64 {
f := ObjToFloat64(obj, e...) f := ObjToFloat64(obj, e...)
return math.Ceil(f) return math.Ceil(f)
} }
//向上取整 // 向上取整
func ObjToCeilInt(obj interface{}, e ...*Error) int { func ObjToCeilInt(obj interface{}, e ...*Error) int {
f := ObjToCeilFloat64(obj, e...) f := ObjToCeilFloat64(obj, e...)
return ObjToInt(f) return ObjToInt(f)
@ -340,7 +360,7 @@ func ObjToStr(obj interface{}) string {
return str return str
} }
//转换为Map // 转换为Map
func StrToMap(string string) Map { func StrToMap(string string) Map {
data := Map{} data := Map{}
data.JsonToMap(string) data.JsonToMap(string)
@ -348,7 +368,7 @@ func StrToMap(string string) Map {
return data return data
} }
//转换为Slice // 转换为Slice
func StrToSlice(string string) Slice { func StrToSlice(string string) Slice {
data := ObjToSlice(string) data := ObjToSlice(string)
@ -356,7 +376,7 @@ func StrToSlice(string string) Slice {
return data return data
} }
//字符串数组: a1,a2,a3转["a1","a2","a3"] // 字符串数组: a1,a2,a3转["a1","a2","a3"]
func StrArrayToJsonStr(a string) string { func StrArrayToJsonStr(a string) string {
if len(a) > 2 { if len(a) > 2 {
@ -374,7 +394,7 @@ func StrArrayToJsonStr(a string) string {
return a return a
} }
//字符串数组: a1,a2,a3转["a1","a2","a3"] // 字符串数组: a1,a2,a3转["a1","a2","a3"]
func JsonStrToStrArray(a string) string { func JsonStrToStrArray(a string) string {
//a = strings.Replace(a, `"`, "", -1) //a = strings.Replace(a, `"`, "", -1)
if len(a) != 0 { if len(a) != 0 {
@ -384,7 +404,7 @@ func JsonStrToStrArray(a string) string {
return "," + a + "," return "," + a + ","
} }
//字符串转int // 字符串转int
func StrToInt(s string) (int, error) { func StrToInt(s string) (int, error) {
i, err := strconv.Atoi(s) i, err := strconv.Atoi(s)
return i, err return i, err

View File

@ -15,7 +15,7 @@ func (that Slice) GetString(key int, err ...*Error) string {
return ObjToStr((that)[key]) return ObjToStr((that)[key])
} }
func (that Slice) GetTime(key int, err ...*Error) time.Time { func (that Slice) GetTime(key int, err ...*Error) *time.Time {
v := ObjToTime((that)[key], err...) v := ObjToTime((that)[key], err...)
return v return v

View File

@ -702,7 +702,7 @@ func (that *HoTimeDB) Select(table string, qu ...interface{}) []Map {
} }
} }
if reflect.ValueOf(qu[0]).Type().String() == "common.Slice" { if reflect.ValueOf(qu[0]).Type().String() == "common.Slice" || strings.Contains(reflect.ValueOf(qu[0]).Type().String(), "[]") {
qu0 := ObjToSlice(qu[0]) qu0 := ObjToSlice(qu[0])
for key, _ := range qu0 { for key, _ := range qu0 {
v := qu0.GetMap(key) v := qu0.GetMap(key)
@ -849,6 +849,31 @@ func (that *HoTimeDB) Count(table string, qu ...interface{}) int {
var condition = []string{"AND", "OR"} var condition = []string{"AND", "OR"}
var vcond = []string{"GROUP", "ORDER", "LIMIT"} var vcond = []string{"GROUP", "ORDER", "LIMIT"}
// Count 计数
func (that *HoTimeDB) Sum(table string, column string, qu ...interface{}) float64 {
var req = []interface{}{}
if len(qu) == 2 {
req = append(req, qu[0])
req = append(req, "SUM("+column+")")
req = append(req, qu[1])
} else {
req = append(req, "SUM("+column+")")
req = append(req, qu...)
}
//req=append(req,qu...)
data := that.Select(table, req...)
//fmt.Println(data)
if len(data) == 0 {
return 0
}
//res,_:=StrToInt(data[0]["COUNT(*)"].(string))
res := ObjToStr(data[0]["SUM("+column+")"])
count := ObjToFloat64(res)
return count
}
//where语句解析 //where语句解析
func (that *HoTimeDB) where(data Map) (string, []interface{}) { func (that *HoTimeDB) where(data Map) (string, []interface{}) {
@ -942,11 +967,12 @@ func (that *HoTimeDB) where(data Map) (string, []interface{}) {
where += k where += k
} }
if reflect.ValueOf(v).Type().String() == "common.Slice" { if reflect.ValueOf(v).Type().String() == "common.Slice" || strings.Contains(reflect.ValueOf(v).Type().String(), "[]") {
for i := 0; i < len(v.(Slice)); i++ { vs := ObjToSlice(v)
where += " " + ObjToStr(v.(Slice)[i]) + " " for i := 0; i < len(vs); i++ {
where += " " + vs.GetString(i) + " "
if len(v.(Slice)) != i+1 { if len(vs) != i+1 {
where += ", " where += ", "
} }
@ -1029,7 +1055,7 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
v = "%" + ObjToStr(v) + "%" v = "%" + ObjToStr(v) + "%"
res = append(res, v) res = append(res, v)
case "[!~]": //左边任意 case "[!~]": //左边任意
k = strings.Replace(k, "[~]", "", -1) k = strings.Replace(k, "[!~]", "", -1)
if !strings.Contains(k, ".") { if !strings.Contains(k, ".") {
k = "`" + k + "` " k = "`" + k + "` "
} }
@ -1037,7 +1063,7 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
v = "%" + ObjToStr(v) + "" v = "%" + ObjToStr(v) + ""
res = append(res, v) res = append(res, v)
case "[~!]": //右边任意 case "[~!]": //右边任意
k = strings.Replace(k, "[~]", "", -1) k = strings.Replace(k, "[~!]", "", -1)
if !strings.Contains(k, ".") { if !strings.Contains(k, ".") {
k = "`" + k + "` " k = "`" + k + "` "
} }
@ -1078,16 +1104,18 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
k = "`" + k + "` " k = "`" + k + "` "
} }
where += k + " NOT BETWEEN ? AND ? " where += k + " NOT BETWEEN ? AND ? "
res = append(res, v.(Slice)[0]) vs := ObjToSlice(v)
res = append(res, v.(Slice)[1]) res = append(res, vs[0])
res = append(res, vs[1])
case "[<>]": case "[<>]":
k = strings.Replace(k, "[<>]", "", -1) k = strings.Replace(k, "[<>]", "", -1)
if !strings.Contains(k, ".") { if !strings.Contains(k, ".") {
k = "`" + k + "` " k = "`" + k + "` "
} }
where += k + " BETWEEN ? AND ? " where += k + " BETWEEN ? AND ? "
res = append(res, v.(Slice)[0]) vs := ObjToSlice(v)
res = append(res, v.(Slice)[1]) res = append(res, vs[0])
res = append(res, vs[1])
default: default:
if !strings.Contains(k, ".") { if !strings.Contains(k, ".") {
k = "`" + k + "` " k = "`" + k + "` "
@ -1098,6 +1126,98 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
return where, res return where, res
} }
if len(vs) == 1 {
where += k + "=? "
res = append(res, vs[0])
return where, res
}
min := int64(0)
isMin := true
IsRange := true
num := int64(0)
isNum := true
where1 := ""
res1 := Slice{}
where2 := k + " IN ("
res2 := Slice{}
for kvs := 0; kvs <= len(vs); kvs++ {
vsv := int64(0)
if kvs < len(vs) {
vsv = vs.GetCeilInt64(kvs)
//确保是全部是int类型
if ObjToStr(vsv) != vs.GetString(kvs) {
IsRange = false
break
}
}
if isNum {
isNum = false
num = vsv
} else {
num++
}
if isMin {
isMin = false
min = vsv
}
//不等于则到了分路口
if num != vsv {
//between
if num-min > 1 {
if where1 != "" {
where1 += " OR " + k + " BETWEEN ? AND ? "
} else {
where1 += k + " BETWEEN ? AND ? "
}
res1 = append(res1, min)
res1 = append(res1, num-1)
} else {
//如果就前进一步就用OR
where2 += "?,"
res2 = append(res2, min)
}
min = vsv
num = vsv
}
}
if IsRange {
where3 := ""
if where1 != "" {
where3 += where1
res = append(res, res1...)
}
if len(res2) == 1 {
if where3 == "" {
where3 += k + " = ? "
} else {
where3 += " OR " + k + " = ? "
}
res = append(res, res2...)
} else if len(res2) > 1 {
where2 = where2[:len(where2)-1]
if where3 == "" {
where3 += where2 + ")"
} else {
where3 += " OR " + where2 + ")"
}
res = append(res, res2...)
}
if where3 != "" {
where += "(" + where3 + ")"
}
return where, res
}
where += k + " IN (" where += k + " IN ("
res = append(res, vs...) res = append(res, vs...)
@ -1131,6 +1251,100 @@ func (that *HoTimeDB) varCond(k string, v interface{}) (string, []interface{}) {
if len(vs) == 0 { if len(vs) == 0 {
return where, res return where, res
} }
if len(vs) == 1 {
where += k + "=? "
res = append(res, vs[0])
return where, res
}
//In转betwin和IN提升部分性能
min := int64(0)
isMin := true
IsRange := true
num := int64(0)
isNum := true
where1 := ""
res1 := Slice{}
where2 := k + " IN ("
res2 := Slice{}
for kvs := 0; kvs <= len(vs); kvs++ {
vsv := int64(0)
if kvs < len(vs) {
vsv = vs.GetCeilInt64(kvs)
//确保是全部是int类型
if ObjToStr(vsv) != vs.GetString(kvs) {
IsRange = false
break
}
}
if isNum {
isNum = false
num = vsv
} else {
num++
}
if isMin {
isMin = false
min = vsv
}
//不等于则到了分路口
if num != vsv {
//between
if num-min > 1 {
if where1 != "" {
where1 += " OR " + k + " BETWEEN ? AND ? "
} else {
where1 += k + " BETWEEN ? AND ? "
}
res1 = append(res1, min)
res1 = append(res1, num-1)
} else {
//如果就前进一步就用OR
where2 += "?,"
res2 = append(res2, min)
}
min = vsv
num = vsv
}
}
if IsRange {
where3 := ""
if where1 != "" {
where3 += where1
res = append(res, res1...)
}
if len(res2) == 1 {
if where3 == "" {
where3 += k + " = ? "
} else {
where3 += " OR " + k + " = ? "
}
res = append(res, res2...)
} else if len(res2) > 1 {
where2 = where2[:len(where2)-1]
if where3 == "" {
where3 += where2 + ")"
} else {
where3 += " OR " + where2 + ")"
}
res = append(res, res2...)
}
if where3 != "" {
where += "(" + where3 + ")"
}
return where, res
}
where += k + " IN (" where += k + " IN ("
res = append(res, vs...) res = append(res, vs...)

View File

@ -2,114 +2,63 @@
"flow": { "flow": {
"admin": { "admin": {
"sql": { "sql": {
"org_id": "org_id", "role_id": "role_id"
"parent_ids[~]": "%,id,%",
"role_id": "role_id",
"zone_id": "zone_id"
}, },
"stop": true, "stop": false,
"table": "admin" "table": "admin"
}, },
"channel": { "article": {
"sql": { "sql": {
"admin_id": "id", "admin_id": "id"
"org_id": "org_id",
"zone_id": "zone_id"
}, },
"stop": false, "stop": false,
"table": "channel" "table": "article"
}, },
"company": { "ctg": {
"sql": { "sql": {
"admin_id": "id", "admin_id": "id"
"org_id": "org_id",
"zone_id": "zone_id"
}, },
"stop": false, "stop": false,
"table": "company" "table": "ctg"
},
"ctg_article": {
"sql": {
"admin_id": "id"
},
"stop": false,
"table": "ctg_article"
},
"ctg_copy": {
"sql": {
"admin_id": "id"
},
"stop": false,
"table": "ctg_copy"
}, },
"logs": { "logs": {
"sql": { "sql": {
"admin_id": "id"
}, },
"stop": false, "stop": false,
"table": "logs" "table": "logs"
}, },
"org": { "org": {
"sql": { "sql": {
"admin_id": "id", "admin_id": "id"
"parent_ids[~]": "%,org_id,%",
"zone_id": "zone_id"
},
"stop": true,
"table": "org"
},
"proj": {
"sql": {
"admin_id": "id",
"org_id": "org_id",
"sc_admin_id": "sc_admin_id",
"xm_admin_id": "xm_admin_id",
"zone_id": "zone_id"
}, },
"stop": false, "stop": false,
"table": "proj" "table": "org"
}, },
"role": { "role": {
"sql": { "sql": {
"admin_id": "id",
"id": "role_id" "id": "role_id"
}, },
"stop": true, "stop": true,
"table": "role" "table": "role"
},
"sea": {
"sql": {
"admin_id": "id"
},
"stop": false,
"table": "sea"
},
"task": {
"sql": {
"admin_id": "id",
"zone_id": "zone_id"
},
"stop": false,
"table": "task"
},
"task_admin": {
"sql": {
"admin_id": "id",
"zone_id": "zone_id"
},
"stop": false,
"table": "task_admin"
},
"user": {
"sql": {
"admin_id": "id",
"zone_id": "zone_id"
},
"stop": false,
"table": "user"
},
"wechat": {
"sql": {
"admin_id": "id",
"org_id": "org_id"
},
"stop": false,
"table": "wechat"
},
"zone": {
"sql": {
"parent_ids[~]": "%,zone_id,%"
},
"stop": true,
"table": "zone"
} }
}, },
"id": "023d5002b1e2c64ed744a12ac442c00e", "id": "74a8a59407fa7d6c7fcdc85742dbae57",
"label": "HoTime管理平台", "label": "HoTime管理平台",
"labelConfig": { "labelConfig": {
"add": "添加", "add": "添加",
@ -120,6 +69,160 @@
"show": "开启" "show": "开启"
}, },
"menus": [ "menus": [
{
"auth": [
"show"
],
"icon": "Setting",
"label": "ebw_news",
"menus": [
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_news",
"table": "ebw_news"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_news_addition_res",
"table": "ebw_news_addition_res"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_annex",
"table": "ebw_annex"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_customer",
"table": "ebw_customer"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_items",
"table": "ebw_items"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_res",
"table": "ebw_res"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_vote",
"table": "ebw_vote"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_vote_option",
"table": "ebw_vote_option"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_user",
"table": "ebw_user"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_attachment",
"table": "ebw_attachment"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_jobs",
"table": "ebw_jobs"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "ebw_vote_user",
"table": "ebw_vote_user"
}
],
"name": "sys:ebw"
},
{ {
"auth": [ "auth": [
"show" "show"
@ -127,6 +230,14 @@
"icon": "Setting", "icon": "Setting",
"label": "系统管理", "label": "系统管理",
"menus": [ "menus": [
{
"auth": [
"show",
"download"
],
"label": "日志管理",
"table": "logs"
},
{ {
"auth": [ "auth": [
"show", "show",
@ -148,185 +259,9 @@
"info", "info",
"download" "download"
], ],
"label": "联络人管理", "label": "组织管理",
"table": "user"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目分类",
"table": "category"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "标签管理",
"table": "out_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "考勤管理",
"table": "time_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "车辆管理",
"table": "car"
},
{
"auth": [
"show",
"download"
],
"label": "日志管理",
"table": "logs"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "系统设置",
"table": "system"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "标签管理",
"table": "visit_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "城市管理",
"table": "city"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目管理",
"table": "proj"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "客户管理",
"table": "company"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "项目归口",
"table": "department"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "部门管理",
"table": "org" "table": "org"
}, },
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "用章管理",
"table": "seal_tag"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "微信信息",
"table": "wechat"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "联盟公司",
"table": "zone"
},
{ {
"auth": [ "auth": [
"show", "show",
@ -348,8 +283,8 @@
"info", "info",
"download" "download"
], ],
"label": "供应商管理", "label": "文章管理",
"table": "channel" "table": "article"
} }
], ],
"name": "sys" "name": "sys"
@ -359,7 +294,7 @@
"show" "show"
], ],
"icon": "Setting", "icon": "Setting",
"label": "任务执行", "label": "外部系统",
"menus": [ "menus": [
{ {
"auth": [ "auth": [
@ -370,8 +305,8 @@
"info", "info",
"download" "download"
], ],
"label": "任务执行", "label": "外部系统",
"table": "task_admin" "table": "swiper_sys"
}, },
{ {
"auth": [ "auth": [
@ -382,18 +317,66 @@
"info", "info",
"download" "download"
], ],
"label": "任务管理", "label": "顶部",
"table": "task" "table": "swiper_top"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "飘窗",
"table": "swiper_fly"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "底部",
"table": "swiper_bottom"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "中间",
"table": "swiper_center"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "关联专题",
"table": "swiper_point"
} }
], ],
"name": "sys:task" "name": "sys:swiper"
}, },
{ {
"auth": [ "auth": [
"show" "show"
], ],
"icon": "Setting", "icon": "Setting",
"label": "跟进管理", "label": "栏目管理",
"menus": [ "menus": [
{ {
"auth": [ "auth": [
@ -404,11 +387,81 @@
"info", "info",
"download" "download"
], ],
"label": "跟进管理", "label": "栏目管理",
"table": "sea" "table": "ctg"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "关联栏目",
"table": "ctg_article"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "栏目管理",
"table": "ctg_copy"
} }
], ],
"name": "sys:sea" "name": "sys:ctg"
},
{
"auth": [
"show"
],
"icon": "Setting",
"label": "纪委信箱",
"menus": [
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "纪委信箱",
"table": "mail_discipline"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "总经理信箱",
"table": "mail"
},
{
"auth": [
"show",
"add",
"delete",
"edit",
"info",
"download"
],
"label": "党委书记信箱",
"table": "mail_part"
}
],
"name": "sys:mail"
} }
], ],
"name": "admin", "name": "admin",

File diff suppressed because it is too large Load Diff

View File

@ -24,7 +24,7 @@
"db": { "db": {
"mysql": { "mysql": {
"host": "192.168.6.253", "host": "192.168.6.253",
"name": "rfcb", "name": "dgs-cms",
"password": "dasda8454456", "password": "dasda8454456",
"port": "3306", "port": "3306",
"user": "root" "user": "root"

View File

@ -396,7 +396,7 @@
"list": false, "list": false,
"must": false, "must": false,
"name": "auth", "name": "auth",
"strict": false, "strict": true,
"type": "auth" "type": "auth"
}, },
{ {