|
|
@@ -116,28 +116,33 @@ func buildSQL(datas []interface{}, parentCode string, level int) string {
|
|
|
for i, v := range datas {
|
|
|
data := v.(map[string]interface{})
|
|
|
var (
|
|
|
- remark string
|
|
|
+ remark string
|
|
|
+ rulekey string
|
|
|
)
|
|
|
|
|
|
- if data["remark"] != nil {
|
|
|
- remark = data["remark"].(string)
|
|
|
- }
|
|
|
-
|
|
|
- sql += "INSERT INTO FUNCMENULIST (RESOURCECODE, RESOURCENAME, RESOURCELEVEL, MENUTYPE, PARENTCODE, URL, SORT, ICONAME, REMARK)\n"
|
|
|
- if parentCode == "" {
|
|
|
- sql += fmt.Sprintf("VALUES('%s', '%s', %d, 3, NULL, '', %d, '', '%s');\n", data["code"].(string), data["title"].(string), level, i+1, remark)
|
|
|
- } else {
|
|
|
- sql += fmt.Sprintf("VALUES('%s', '%s', %d, 3, '%s', '', %d, '', '%s');\n", data["code"].(string), data["title"].(string), level, parentCode, i+1, remark)
|
|
|
- }
|
|
|
-
|
|
|
- // 递归
|
|
|
- sub := data["children"].([]interface{})
|
|
|
- if len(sub) > 0 {
|
|
|
- sql += buildSQL(data["children"].([]interface{}), data["code"].(string), level+1)
|
|
|
- }
|
|
|
-
|
|
|
- if level == 1 {
|
|
|
- sql += "\n"
|
|
|
+ if data["rulekey"] != nil {
|
|
|
+ rulekey = data["rulekey"].(string)
|
|
|
+
|
|
|
+ if data["remark"] != nil {
|
|
|
+ remark = data["remark"].(string)
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += "INSERT INTO FUNCMENULIST (RESOURCECODE, RESOURCENAME, RESOURCELEVEL, MENUTYPE, PARENTCODE, URL, SORT, ICONAME, REMARK)\n"
|
|
|
+ if parentCode == "" {
|
|
|
+ sql += fmt.Sprintf("VALUES('%s', '%s', %d, 3, NULL, '', %d, '', '%s');\n", rulekey, data["title"].(string), level, i+1, remark)
|
|
|
+ } else {
|
|
|
+ sql += fmt.Sprintf("VALUES('%s', '%s', %d, 3, '%s', '', %d, '', '%s');\n", rulekey, data["title"].(string), level, parentCode, i+1, remark)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 递归
|
|
|
+ sub := data["children"].([]interface{})
|
|
|
+ if len(sub) > 0 {
|
|
|
+ sql += buildSQL(data["children"].([]interface{}), data["code"].(string), level+1)
|
|
|
+ }
|
|
|
+
|
|
|
+ if level == 1 {
|
|
|
+ sql += "\n"
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -151,38 +156,44 @@ func buildPCWEBSQL(datas []interface{}, parentCode string, level int) string {
|
|
|
for i, v := range datas {
|
|
|
data := v.(map[string]interface{})
|
|
|
var (
|
|
|
- remark string
|
|
|
+ remark string
|
|
|
+ rulekey string
|
|
|
)
|
|
|
|
|
|
- if data["remark"] != nil {
|
|
|
- remark = data["remark"].(string)
|
|
|
- }
|
|
|
-
|
|
|
- title := ""
|
|
|
- if data["title"] != nil {
|
|
|
- title = data["title"].(string)
|
|
|
- } else {
|
|
|
- title = data["label"].(string)
|
|
|
- }
|
|
|
-
|
|
|
- sql += "INSERT INTO FUNCMENULIST (RESOURCECODE, RESOURCENAME, RESOURCELEVEL, MENUTYPE, PARENTCODE, URL, SORT, ICONAME, REMARK)\n"
|
|
|
- if parentCode == "" {
|
|
|
- sql += fmt.Sprintf("VALUES('%s', '%s', %d, 5, NULL, '', %d, '', '%s');\n", data["code"].(string), title, level, i+1, remark)
|
|
|
- } else {
|
|
|
- sql += fmt.Sprintf("VALUES('%s', '%s', %d, 5, '%s', '', %d, '', '%s');\n", data["code"].(string), title, level, parentCode, i+1, remark)
|
|
|
+ if data["rulekey"] != nil {
|
|
|
+ rulekey = data["rulekey"].(string)
|
|
|
+
|
|
|
+ if data["remark"] != nil {
|
|
|
+ remark = data["remark"].(string)
|
|
|
+ }
|
|
|
+
|
|
|
+ title := ""
|
|
|
+ if data["title"] != nil {
|
|
|
+ title = data["title"].(string)
|
|
|
+ } else {
|
|
|
+ title = data["label"].(string)
|
|
|
+ }
|
|
|
+
|
|
|
+ sql += "INSERT INTO FUNCMENULIST (RESOURCECODE, RESOURCENAME, RESOURCELEVEL, MENUTYPE, PARENTCODE, URL, SORT, ICONAME, REMARK)\n"
|
|
|
+ if parentCode == "" {
|
|
|
+ sql += fmt.Sprintf("VALUES('%s', '%s', %d, 5, NULL, '', %d, '', '%s');\n", rulekey, title, level, i+1, remark)
|
|
|
+ } else {
|
|
|
+ sql += fmt.Sprintf("VALUES('%s', '%s', %d, 5, '%s', '', %d, '', '%s');\n", rulekey, title, level, parentCode, i+1, remark)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 递归
|
|
|
+ if data["auth"] != nil {
|
|
|
+ sql += buildPCWEBSQL(data["auth"].([]interface{}), data["code"].(string), level+1)
|
|
|
+ }
|
|
|
+ if data["children"] != nil {
|
|
|
+ sql += buildPCWEBSQL(data["children"].([]interface{}), data["code"].(string), level+1)
|
|
|
+ }
|
|
|
+
|
|
|
+ if level == 1 {
|
|
|
+ sql += "\n"
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- // 递归
|
|
|
- if data["auth"] != nil {
|
|
|
- sql += buildPCWEBSQL(data["auth"].([]interface{}), data["code"].(string), level+1)
|
|
|
- }
|
|
|
- if data["children"] != nil {
|
|
|
- sql += buildPCWEBSQL(data["children"].([]interface{}), data["code"].(string), level+1)
|
|
|
- }
|
|
|
-
|
|
|
- if level == 1 {
|
|
|
- sql += "\n"
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
return sql
|