升级流程引擎配置文件版本

This commit is contained in:
hoteas 2022-10-19 21:29:38 +08:00
parent 9a7426180d
commit cdba8af129
3 changed files with 157 additions and 20 deletions

103
code.go
View File

@ -247,20 +247,28 @@ var TptProject = Proj{
}
conf := ObjToMap(string(btes))
stop := conf.GetSlice("stop")
for k, _ := range stop {
v := stop.GetString(k)
//不能改对应行数据
if tableName == v && data.GetCeilInt64(v+"_id") == ObjToCeilInt64(that.RouterString[2]) {
that.Display(4, "你没有权限修改当前数据")
return
//相同则
if tableName == fileConfig.GetString("table") {
flows := conf.GetMap("flow")
for k, _ := range flows {
v := flows.GetMap(k)
if v.GetBool("stop") {
//不能改自身对应的数据
if inData[k+"_id"] != nil {
//fmt.Println(inData[k+"_id"])
delete(inData, k+"_id")
//fmt.Println(inData[k+"_id"])
}
}
}
//不能改自身对应的数据
if tableName == fileConfig.GetString("table") && inData[v+"_id"] != nil {
delete(inData, v+"_id")
} else {
flow := conf.GetMap("flow").GetMap(tableName)
if flow != nil && flow.GetBool("stop") {
if data.GetCeilInt64(tableName+"_id") == ObjToCeilInt64(that.RouterString[2]) {
that.Display(4, "你没有权限修改当前数据")
return
}
}
}
if inData["auth"] != nil {
@ -392,7 +400,33 @@ var TptProject = Proj{
tableName := that.RouterString[1]
that.Log = Map{"table": tableName, "type": 3, "table_id": that.RouterString[2]}
hotimeName := that.RouterString[0]
fileConfig := that.MakeCodeRouter[hotimeName].FileConfig
//树状结构不允许修改自身的属性,修改别人的可以
btes, err := ioutil.ReadFile(fileConfig.GetString("config"))
if err != nil {
that.Display(4, "找不到权限配置文件")
return
}
conf := ObjToMap(string(btes))
data := that.Db.Get(fileConfig.GetString("table"), "*", Map{"id": that.Session(fileConfig.GetString("table") + "_id").ToCeilInt()})
//相同则
if tableName == fileConfig.GetString("table") {
if data.GetCeilInt64("id") == ObjToCeilInt64(that.RouterString[2]) {
that.Display(4, "你不能删除自己")
return
}
} else {
flow := conf.GetMap("flow").GetMap(tableName)
if flow != nil && flow.GetBool("stop") {
if data.GetCeilInt64(tableName+"_id") == ObjToCeilInt64(that.RouterString[2]) {
that.Display(4, "你没有权限修改当前数据")
return
}
}
}
re := int64(0)
//有索引则删除对应的参数
if that.MakeCodeRouter[hotimeName].TableColumns[tableName]["parent_id"] != nil {
@ -412,8 +446,51 @@ var TptProject = Proj{
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{}
columnStr, leftJoin, where := that.MakeCodeRouter[hotimeName].Search(tableName, data, that.Req, that.Db)
//树状结构不允许修改自身的属性,修改别人的可以
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[tableName+"."+k] = strings.Replace(sql.GetString(k), "id", data.GetString("id"), -1)
continue
}
if k == "parent_ids[~]" && data[tableName+"_id"] != nil {
where[tableName+"."+k] = strings.Replace(sql.GetString(k), tableName+"_id", data.GetString(tableName+"_id"), -1)
continue
}
if data[sql.GetString(k)] != nil {
where[tableName+"."+k] = data[sql.GetString(k)]
}
}
}
//}
columnStr, leftJoin, where := that.MakeCodeRouter[hotimeName].Search(tableName, data, where, that.Req, that.Db)
page := ObjToInt(that.Req.FormValue("page"))
pageSize := ObjToInt(that.Req.FormValue("pageSize"))

View File

@ -508,7 +508,12 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
}
}
flow := Map{}
//"user": {"table": "user", "stop": true,
// "SQL": {
// "role_id": "role_id",
// "admin_id": "admin_id",
// "parent_ids": "%,user_id,%"}}
//搜索增加树节点
for fk, fv := range that.TableColumns {
for k, v := range fv {
@ -521,12 +526,61 @@ func (that *MakeCode) Db2JSON(db *db.HoTimeDB, config Map) {
that.SearchColumns[fk][k] = sv
}
if fk == that.FileConfig.GetString("table") && v["link"] != nil && that.TableColumns[v.GetString("link")]["parent_id"] != nil {
that.Config["stop"] = append(that.Config.GetSlice("stop"), v.GetString("link"))
//if fk == that.FileConfig.GetString("table") && v["link"] != nil && that.TableColumns[v.GetString("link")]["parent_id"] != nil {
// that.Config["stop"] = append(that.Config.GetSlice("stop"), v.GetString("link"))
// //that.
//}
for _, av := range that.TableColumns[that.FileConfig.GetString("table")] {
//同字段
if av["link"] != nil && av.GetString("link") == v.GetString("link") {
if flow[fk] == nil {
flow[fk] = Map{"table": fk, "stop": false, "sql": Map{}}
}
sql := flow.GetMap(fk).GetMap("sql")
if k == "parent_id" {
sql["parent_ids[~]"] = "%," + av.GetString("name") + ",%"
} else {
sql[k] = k
}
flow.GetMap(fk)["sql"] = sql
}
//同表
if av["link"] != nil && av.GetString("link") == fk {
if flow[fk] == nil {
flow[fk] = Map{"table": fk, "stop": false, "sql": Map{}}
}
ta := flow.GetMap(fk)
ta["stop"] = true
flow[fk] = ta
}
}
if k == that.FileConfig.GetString("table")+"_id" {
if flow[fk] == nil {
flow[fk] = Map{"table": fk, "stop": false, "sql": Map{}}
}
sql := flow.GetMap(fk).GetMap("sql")
sql[k] = "id"
flow.GetMap(fk)["sql"] = sql
}
//当前用户
if k == "parent_id" && that.FileConfig.GetString("table") == fk {
if flow[fk] == nil {
flow[fk] = Map{"table": fk, "stop": false, "sql": Map{}}
}
sql := flow.GetMap(fk).GetMap("sql")
sql["parent_ids[~]"] = "%,id,%"
flow.GetMap(fk)["sql"] = sql
}
}
}
//fmt.Println(flow)
that.Config["flow"] = flow
//fmt.Println(id, "---", that.Config.GetString("id"))
//that.Config["id"] = id
@ -786,10 +840,13 @@ func (that *MakeCode) Delete(table string, req *http.Request) Map {
return data
}
func (that *MakeCode) Search(table string, userData 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, Map) {
reStr := ""
leftJoin := Map{}
data := Map{}
//data := Map{}
if data == nil {
data = Map{}
}
keyword := Map{}
daterange := Map{}
sortMap := Map{}
@ -1155,6 +1212,9 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
}
where := Map{}
//if where==nil{
// where=Map{}
//}
if len(keyword) == 1 {
for k, v := range keyword {

View File

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