Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d314891126 | |||
| c0ae31f499 | |||
| 25edb6b5b7 | |||
| ead64dc776 |
@@ -218,6 +218,9 @@ var TptProject = Proj{
|
||||
}
|
||||
inData["parent_ids"] = parent_ids + ObjToStr(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
|
||||
@@ -365,22 +368,28 @@ var TptProject = Proj{
|
||||
|
||||
}
|
||||
|
||||
if inData.Get("parent_id") != nil {
|
||||
if _, ok := inData["parent_id"]; ok {
|
||||
//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"), parent_ids, -1)
|
||||
that.Db.Update(tableName, Map{"parent_ids": v["parent_ids"]}, Map{"id": v.GetCeilInt("id")})
|
||||
|
||||
if inData.GetCeilInt64("parent_id") == 0 {
|
||||
that.Db.Update(tableName, Map{"parent_ids": "," + that.RouterString[2] + ","}, Map{"id": that.RouterString[2]})
|
||||
} else {
|
||||
|
||||
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"), parent_ids, -1)
|
||||
that.Db.Update(tableName, Map{"parent_ids": v["parent_ids"]}, Map{"id": v.GetCeilInt("id")})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+74
-49
@@ -743,17 +743,23 @@ func (that *MakeCode) Add(table string, user Map, req *http.Request) Map {
|
||||
|
||||
}
|
||||
|
||||
reqValue := req.FormValue(v.GetString("name"))
|
||||
if (reqValue == "" || reqValue == "null") && strings.Contains(v.GetString("name"), "id") {
|
||||
data[v.GetString("name")] = nil
|
||||
} else {
|
||||
if v.GetString("type") == "password" {
|
||||
data[v.GetString("name")] = Md5(reqValue)
|
||||
} else {
|
||||
data[v.GetString("name")] = reqValue
|
||||
}
|
||||
|
||||
if req.Form[v.GetString("name")] == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
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则自动生成
|
||||
if v.GetString("name") == "sn" {
|
||||
@@ -802,13 +808,21 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map {
|
||||
}
|
||||
|
||||
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 == "null" {
|
||||
data[v.GetString("name")] = nil
|
||||
continue
|
||||
}
|
||||
if v.GetString("type") == "number" && reqValue == "" {
|
||||
data[v.GetString("name")] = nil
|
||||
continue
|
||||
}
|
||||
|
||||
if v.GetString("type") == "password" {
|
||||
data[v.GetString("name")] = Md5(reqValue)
|
||||
} else {
|
||||
@@ -907,14 +921,14 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
// 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") + ","
|
||||
reStr += "`" + v.GetString("name") + "`,"
|
||||
//}
|
||||
|
||||
//if v["name"] == "parent_id" && v.GetString("link") != "" {
|
||||
@@ -972,7 +986,7 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
if strings.Contains(v.GetString("type"), "text") {
|
||||
reqValue := req.FormValue(v.GetString("name"))
|
||||
if reqValue != "" {
|
||||
data[table+"."+v.GetString("name")+"[~]"] = reqValue
|
||||
data[v.GetString("name")+"[~]"] = reqValue
|
||||
}
|
||||
|
||||
}
|
||||
@@ -980,9 +994,9 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
if v.GetString("type") == "unixtime" {
|
||||
|
||||
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 {
|
||||
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||
daterange[v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||
}
|
||||
|
||||
//fmt.Println(req.Form["daterange"])
|
||||
@@ -995,12 +1009,12 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
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
|
||||
daterange[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}
|
||||
daterange[v.GetString("name")+"[<>]"] = Slice{t1, t2}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1040,8 +1054,8 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
for _, v := range r {
|
||||
reqValue = append(reqValue, v.GetString("id"))
|
||||
}
|
||||
if data[table+"."+searchItemName] != nil {
|
||||
data[table+"."+searchItemName] = reqValue
|
||||
if data[searchItemName] != nil {
|
||||
data[searchItemName] = reqValue
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1065,10 +1079,10 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
if v.GetString("type") == "unixtime" {
|
||||
//fmt.Println(req.Form["daterange"])
|
||||
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 {
|
||||
|
||||
daterange[table+"."+v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||
daterange[v.GetString("name")+"[<>]"] = ObjToSlice(req.Form["daterange"])
|
||||
}
|
||||
}
|
||||
if v.GetString("type") == "time" {
|
||||
@@ -1077,12 +1091,12 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
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
|
||||
daterange[v.GetString("name")+"[>]"] = t
|
||||
|
||||
} else if len(req.Form["daterange"]) == 2 {
|
||||
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")
|
||||
daterange[table+"."+v.GetString("name")+"[<>]"] = Slice{t1, t2}
|
||||
daterange[v.GetString("name")+"[<>]"] = Slice{t1, t2}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1092,7 +1106,7 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
|
||||
if keywordTableStr != "" {
|
||||
if keywordTableStr == v.GetString("name") {
|
||||
data[table+"."+keywordTableStr+"[~]"] = keywordStr
|
||||
data[keywordTableStr+"[~]"] = keywordStr
|
||||
}
|
||||
|
||||
if keywordTableStr == v.GetString("value") {
|
||||
@@ -1109,11 +1123,11 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
}
|
||||
|
||||
if strings.Contains(v.GetString("type"), "text") {
|
||||
keyword[table+"."+v.GetString("name")+"[~]"] = keywordStr
|
||||
keyword[v.GetString("name")+"[~]"] = keywordStr
|
||||
|
||||
}
|
||||
if v.GetString("name") == "id" {
|
||||
keyword[table+"."+v.GetString("name")] = keywordStr
|
||||
keyword[v.GetString("name")] = keywordStr
|
||||
}
|
||||
if v.GetString("link") != "" &&
|
||||
v.GetString("name") != "parent_id" {
|
||||
@@ -1132,7 +1146,7 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
}
|
||||
|
||||
if len(reqValue) != 0 && searchItem.GetString("name") == "sort" && reqValue[0] != "" {
|
||||
sortMap["ORDER"] = table + "." + reqValue[0]
|
||||
sortMap["ORDER"] = reqValue[0]
|
||||
}
|
||||
|
||||
continue
|
||||
@@ -1143,7 +1157,7 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
parentID := ObjToInt(req.FormValue("parent_id"))
|
||||
if parentID == 0 {
|
||||
parentID = userData.GetCeilInt(table + "_id")
|
||||
data["OR"] = Map{table + ".id": parentID, table + ".parent_id": nil}
|
||||
data["OR"] = Map{"id": parentID, "parent_id": nil}
|
||||
} else {
|
||||
//是否展示全部子级
|
||||
where := Map{}
|
||||
@@ -1151,21 +1165,21 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
|
||||
for _, v := range reqValue {
|
||||
if len(where) == 0 {
|
||||
where[table+"."+parent_idsStr] = "," + v + ","
|
||||
where[parent_idsStr] = "," + v + ","
|
||||
continue
|
||||
}
|
||||
where = Map{"OR": where, table + "." + parent_idsStr: "," + v + ","}
|
||||
where = Map{"OR": where, parent_idsStr: "," + v + ","}
|
||||
}
|
||||
|
||||
} else {
|
||||
where[table+".parent_id"] = reqValue
|
||||
where["parent_id"] = reqValue
|
||||
}
|
||||
//是否展示自己
|
||||
if req.FormValue("showself") == "1" {
|
||||
if len(where) == 0 {
|
||||
data["OR"] = Map{table + ".id": reqValue}
|
||||
data["OR"] = Map{"id": reqValue}
|
||||
} else {
|
||||
data["OR"] = Map{"OR": where, table + ".id": reqValue}
|
||||
data["OR"] = Map{"OR": where, "id": reqValue}
|
||||
}
|
||||
} else {
|
||||
if len(where) != 0 {
|
||||
@@ -1181,26 +1195,37 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
|
||||
if parent_idsStr != "" {
|
||||
|
||||
where := Map{}
|
||||
//where := Map{}
|
||||
//是否全部展示
|
||||
if req.FormValue("showall") != "1" {
|
||||
where[table+"."+searchItem.GetString("name")] = reqValue
|
||||
if len(reqValue) != 0 {
|
||||
data[searchItem.GetString("name")] = reqValue
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
ls := []int64{}
|
||||
for _, v := range reqValue {
|
||||
if len(where) == 0 {
|
||||
where[searchItem.GetString("link")+"."+parent_idsStr] = "," + v + ","
|
||||
continue
|
||||
|
||||
ls1 := db.Select(searchItem.GetString("link"), "id", Map{"OR": Map{parent_idsStr: "," + v + ",", "id": v}})
|
||||
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 {
|
||||
|
||||
where = Map{"AND": Map{searchItem.GetString("link") + "." + parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ",", "OR": where}}
|
||||
}
|
||||
data["OR"] = where
|
||||
//if userData[searchItem.GetString("name")] != nil {
|
||||
//
|
||||
// where = Map{"AND": Map{searchItem.GetString("link") + "." + parent_idsStr: "," + ObjToStr(userData.GetCeilInt64(searchItem.GetString("name"))) + ",", "OR": where}}
|
||||
//}
|
||||
//if len(where)!=0{
|
||||
// data["OR"] = where
|
||||
//}
|
||||
|
||||
continue
|
||||
//r := db.Select(searchItem.GetString("link"), "id", where)
|
||||
@@ -1212,13 +1237,13 @@ func (that *MakeCode) Search(table string, userData Map, data Map, req *http.Req
|
||||
}
|
||||
|
||||
if len(reqValue) != 0 && reqValue[0] != "" {
|
||||
data[table+"."+searchItemName] = reqValue
|
||||
data[searchItemName] = reqValue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if sortMap["ORDER"] == nil {
|
||||
sortMap["ORDER"] = table + ".id DESC"
|
||||
sortMap["ORDER"] = "id DESC"
|
||||
}
|
||||
|
||||
where := Map{}
|
||||
|
||||
+349
-346
File diff suppressed because it is too large
Load Diff
@@ -396,7 +396,7 @@
|
||||
"list": false,
|
||||
"must": false,
|
||||
"name": "auth",
|
||||
"strict": false,
|
||||
"strict": true,
|
||||
"type": "auth"
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user