技术性调整
This commit is contained in:
@@ -79,6 +79,7 @@ var ColumnNameType = []ColumnShow{
|
||||
{"longitude", false, true, true, false, "", false},
|
||||
|
||||
{"index", false, false, false, false, "index", false},
|
||||
{"parent_ids", false, false, false, false, "index", false},
|
||||
{"password", false, true, false, false, "password", false},
|
||||
{"pwd", false, true, false, false, "password", false},
|
||||
|
||||
|
||||
+69
-8
@@ -855,7 +855,18 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
if ruleData[v.GetString("link")] != nil {
|
||||
|
||||
if v.GetString("name") == "parent_id" {
|
||||
data[table+".index[~]"] = "," + ruleData.GetString(v.GetString("link")) + ","
|
||||
|
||||
parent_idsStr := ""
|
||||
parent_ids := that.TableColumns[v.GetString("link")]["parent_ids"]
|
||||
if parent_ids != nil {
|
||||
parent_idsStr = "parent_ids[~]"
|
||||
}
|
||||
index := that.TableColumns[v.GetString("link")]["index"]
|
||||
if index != nil {
|
||||
parent_idsStr = "index[~]"
|
||||
}
|
||||
|
||||
data[table+"."+parent_idsStr] = "," + ruleData.GetString(v.GetString("link")) + ","
|
||||
|
||||
} else {
|
||||
idMap := db.Select(v.GetString("link"), "id", Map{"index[~]": "," + ruleData.GetString(v.GetString("link")) + ","})
|
||||
@@ -900,13 +911,37 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
|
||||
search := that.TableConfig.GetMap(table).GetSlice("search")
|
||||
for k, _ := range search {
|
||||
|
||||
reqValue := req.FormValue(search.GetMap(k).GetString("name"))
|
||||
if reqValue == "" {
|
||||
continue
|
||||
}
|
||||
searchItem := search.GetMap(k)
|
||||
searchItemName := searchItem.GetString("name")
|
||||
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
|
||||
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
//columns := that.TableConfig.GetMap(table).GetSlice("columns")
|
||||
if searchItem.GetString("type") == "search" {
|
||||
@@ -944,7 +979,7 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
}
|
||||
|
||||
if searchItem.GetString("name") == "sort" {
|
||||
sortMap["ORDER"] = table + "." + reqValue
|
||||
sortMap["ORDER"] = table + "." + reqValue[0]
|
||||
}
|
||||
|
||||
continue
|
||||
@@ -960,10 +995,36 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
|
||||
}
|
||||
continue
|
||||
}
|
||||
//如果是树节点则需要判断是否符合权限
|
||||
if searchItem.GetString("type") == "tree" {
|
||||
|
||||
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"))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data[table+"."+searchItemName] = reqValue
|
||||
|
||||
}
|
||||
|
||||
if sortMap["ORDER"] == nil {
|
||||
sortMap["ORDER"] = table + ".id DESC"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user