技术性调整

This commit is contained in:
hoteas 2022-07-26 17:37:17 +08:00
parent 33cd7ebd6b
commit 952c3a1243
5 changed files with 58 additions and 384 deletions

15
code.go
View File

@ -124,9 +124,20 @@ var TptProject = Proj{
return
}
if that.MakeCodeRouter[hotimeName].TableColumns[tableName]["auth"] != nil {
for _, v := range that.MakeCodeRouter[hotimeName].TableColumns[fileConfig.GetString("table")] {
if v.GetString("link") != "" {
if v.GetString("link") == tableName && that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["parent_id"] != nil {
if inData["parent_id"] == 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")
}
}
if that.MakeCodeRouter[hotimeName].TableColumns[tableName]["auth"] != nil {
linkHasAuth := that.MakeCodeRouter[hotimeName].TableColumns[v.GetString("link")]["auth"]
if linkHasAuth != nil {
@ -151,7 +162,7 @@ var TptProject = Proj{
}
//索引管理,便于检索以及权限
if inData.Get("parent_id") != nil && inData.GetString("parent_ids") != "" {
index := that.Db.Get(tableName, "`index`", Map{"id": inData.Get("parent_id")})
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") != "" {

View File

@ -63,9 +63,10 @@ var ColumnNameType = []ColumnShow{
//通用
{"idcard", false, true, true, false, "", false},
{"id", true, false, true, false, "", true},
{"sn", true, false, true, false, "", false},
{"parent_ids", false, false, false, false, "index", true},
{"parent_id", true, true, true, false, "", true},
{"amount", true, true, true, false, "money", true},
{"content", false, false, false, false, "textArea", false},
{"info", false, true, true, false, "textArea", false},
//"sn"{true,true,true,""},
{"status", true, true, true, false, "select", false},
@ -79,7 +80,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},
@ -89,7 +90,7 @@ var ColumnNameType = []ColumnShow{
{"note", false, true, true, false, "", false},
{"description", false, true, true, false, "", false},
{"abstract", false, true, true, false, "", false},
{"content", false, true, true, false, "", false},
{"content", false, true, true, false, "textArea", false},
{"address", true, true, true, false, "", false},
{"full_name", false, true, true, false, "", false},
{"create_time", false, false, true, false, "time", true},

View File

@ -633,11 +633,21 @@ func (that *MakeCode) Info(table string, userData Map, db *db.HoTimeDB) (string,
}
if ruleData[v.GetString("link")] != nil {
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[~]"
}
if v.GetString("name") == "parent_id" {
data["index[~]"] = "," + ruleData.GetString(v.GetString("link")) + ","
data[parent_idsStr] = "," + ruleData.GetString(v.GetString("link")) + ","
} else {
idMap := db.Select(v.GetString("link"), "id", Map{"index[~]": "," + ruleData.GetString(v.GetString("link")) + ","})
idMap := db.Select(v.GetString("link"), "id", Map{parent_idsStr: "," + ruleData.GetString(v.GetString("link")) + ","})
ids := Slice{ruleData.GetCeilInt(v.GetString("link"))}
for _, v := range idMap {
ids = append(ids, v.GetCeilInt("id"))
@ -701,7 +711,16 @@ func (that *MakeCode) Add(table string, user Map, req *http.Request) Map {
}
}
//sn则自动生成
if v.GetString("name") == "sn" {
reqValue := req.FormValue(v.GetString("name"))
if reqValue == "" {
data[v.GetString("name")] = Md5(ObjToStr(time.Now().UnixNano()))
} else {
data[v.GetString("name")] = reqValue
}
}
if v.GetString("name") == "create_time" {
if v.GetString("type") == "unixTime" {
data[v.GetString("name")] = time.Now().Unix()
@ -749,9 +768,15 @@ func (that *MakeCode) Edit(table string, req *http.Request) Map {
data[v.GetString("name")] = reqValue
}
}
if v.GetString("name") == "modify_time" {
if v.GetString("type") == "unixTime" {
data[v.GetString("name")] = time.Now().Unix()
}
if v.GetString("type") == "time" {
data[v.GetString("name")] = time.Now().Format("2006-01-02 15-04-05")
}
}
}
if len(data) == 0 {
@ -853,9 +878,6 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
}
}
if ruleData[v.GetString("link")] != nil {
if v.GetString("name") == "parent_id" {
parent_idsStr := ""
parent_ids := that.TableColumns[v.GetString("link")]["parent_ids"]
if parent_ids != nil {
@ -866,10 +888,12 @@ func (that *MakeCode) Search(table string, userData Map, req *http.Request, db *
parent_idsStr = "index[~]"
}
if v.GetString("name") == "parent_id" {
data[table+"."+parent_idsStr] = "," + ruleData.GetString(v.GetString("link")) + ","
} else {
idMap := db.Select(v.GetString("link"), "id", Map{"index[~]": "," + ruleData.GetString(v.GetString("link")) + ","})
idMap := db.Select(v.GetString("link"), "id", Map{parent_idsStr: "," + ruleData.GetString(v.GetString("link")) + ","})
ids := Slice{ruleData.GetCeilInt(v.GetString("link"))}
for _, v := range idMap {
ids = append(ids, v.GetCeilInt("id"))

View File

@ -68,7 +68,7 @@ func (that *Context) View() {
}
//创建日志
if that.Log != nil {
that.Log["time"] = time.Now().Unix()
that.Log["time"] = time.Now().Format("2006-01-02 15:04")
if that.Session("admin_id").Data != nil {
that.Log["admin_id"] = that.Session("admin_id").ToCeilInt()
}

View File

@ -1,362 +0,0 @@
[
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "idcard",
"strict": false,
"type": ""
},
{
"edit": false,
"info": true,
"list": true,
"must": false,
"name": "id",
"strict": true,
"type": ""
},
{
"edit": true,
"info": true,
"list": true,
"must": false,
"name": "parent_id",
"strict": true,
"type": ""
},
{
"edit": true,
"info": true,
"list": true,
"must": false,
"name": "amount",
"strict": true,
"type": "money"
},
{
"edit": false,
"info": false,
"list": false,
"must": false,
"name": "content",
"strict": false,
"type": "textArea"
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "info",
"strict": false,
"type": "textArea"
},
{
"edit": true,
"info": true,
"list": true,
"must": false,
"name": "status",
"strict": false,
"type": "select"
},
{
"edit": true,
"info": true,
"list": true,
"must": false,
"name": "state",
"strict": false,
"type": "select"
},
{
"edit": true,
"info": true,
"list": true,
"must": false,
"name": "sex",
"strict": false,
"type": "select"
},
{
"edit": false,
"info": false,
"list": false,
"must": false,
"name": "delete",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "lat",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "lng",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "latitude",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "longitude",
"strict": false,
"type": ""
},
{
"edit": false,
"info": false,
"list": false,
"must": false,
"name": "index",
"strict": false,
"type": "index"
},
{
"edit": true,
"info": false,
"list": false,
"must": false,
"name": "password",
"strict": false,
"type": "password"
},
{
"edit": true,
"info": false,
"list": false,
"must": false,
"name": "pwd",
"strict": false,
"type": "password"
},
{
"edit": false,
"info": false,
"list": false,
"must": false,
"name": "version",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "seq",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "sort",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "note",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "description",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "abstract",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "content",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": true,
"must": false,
"name": "address",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "full_name",
"strict": false,
"type": ""
},
{
"edit": false,
"info": true,
"list": false,
"must": false,
"name": "create_time",
"strict": true,
"type": "time"
},
{
"edit": false,
"info": true,
"list": true,
"must": false,
"name": "modify_time",
"strict": true,
"type": "time"
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "image",
"strict": false,
"type": "image"
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "img",
"strict": false,
"type": "image"
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "icon",
"strict": false,
"type": "image"
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "avatar",
"strict": false,
"type": "image"
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "file",
"strict": false,
"type": "file"
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "age",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": false,
"must": false,
"name": "email",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": true,
"must": false,
"name": "time",
"strict": false,
"type": "time"
},
{
"edit": false,
"info": true,
"list": false,
"must": false,
"name": "level",
"strict": false,
"type": ""
},
{
"edit": true,
"info": true,
"list": true,
"must": false,
"name": "rule",
"strict": false,
"type": "form"
},
{
"edit": false,
"info": true,
"list": true,
"must": false,
"name": "table",
"strict": false,
"type": "table"
},
{
"edit": false,
"info": true,
"list": true,
"must": false,
"name": "table_id",
"strict": false,
"type": "table_id"
}
]