|
@@ -5,6 +5,7 @@ import (
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
|
"os"
|
|
"os"
|
|
|
|
|
+ "strconv"
|
|
|
"time"
|
|
"time"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -28,7 +29,7 @@ func main() {
|
|
|
clientType string // 终端类型: 1-PCWEB 2-手机
|
|
clientType string // 终端类型: 1-PCWEB 2-手机
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
- fmt.Println("请输入终端类型: (1-PCWEB 2-手机)")
|
|
|
|
|
|
|
+ fmt.Println("请输入终端类型: (3-手机 4-PC大宗 5-PC风管)")
|
|
|
fmt.Scanln(&clientType)
|
|
fmt.Scanln(&clientType)
|
|
|
|
|
|
|
|
fmt.Println("请输入菜单JSON文件地址:")
|
|
fmt.Println("请输入菜单JSON文件地址:")
|
|
@@ -55,16 +56,23 @@ func main() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
s := "-- 权限控制\n"
|
|
s := "-- 权限控制\n"
|
|
|
- if clientType == "1" {
|
|
|
|
|
- s += "-- 说明:MENUTYPE = 5 为PC WEB专用的终端权限\n"
|
|
|
|
|
|
|
+ if clientType == "4" {
|
|
|
|
|
+ s += "-- 说明:MENUTYPE = 4 为PC大宗专用的终端权限\n"
|
|
|
|
|
+ s += "DELETE FROM FUNCMENULIST WHERE MENUTYPE=4;\n\n"
|
|
|
|
|
+ } else if clientType == "5" {
|
|
|
|
|
+ s += "-- 说明:MENUTYPE = 5 为PC风管专用的终端权限\n"
|
|
|
s += "DELETE FROM FUNCMENULIST WHERE MENUTYPE=5;\n\n"
|
|
s += "DELETE FROM FUNCMENULIST WHERE MENUTYPE=5;\n\n"
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else if clientType == "3" {
|
|
|
s += "-- 说明:MENUTYPE = 3 为手机专用的终端权限\n"
|
|
s += "-- 说明:MENUTYPE = 3 为手机专用的终端权限\n"
|
|
|
s += "DELETE FROM FUNCMENULIST WHERE MENUTYPE=3;\n\n"
|
|
s += "DELETE FROM FUNCMENULIST WHERE MENUTYPE=3;\n\n"
|
|
|
|
|
+ } else {
|
|
|
|
|
+ fmt.Printf("错误的终端类型。")
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if clientType == "1" {
|
|
|
|
|
- s += buildPCWEBSQL(datas, "", 1)
|
|
|
|
|
|
|
+ t, _ := strconv.Atoi(clientType)
|
|
|
|
|
+ if clientType == "4" || clientType == "5" {
|
|
|
|
|
+ s += buildPCWEBSQL(datas, "", 1, t)
|
|
|
} else {
|
|
} else {
|
|
|
s += buildSQL(datas, "", 1)
|
|
s += buildSQL(datas, "", 1)
|
|
|
}
|
|
}
|
|
@@ -134,7 +142,7 @@ func buildSQL(datas []interface{}, parentCode string, level int) string {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 构建PC WEB SQL
|
|
// 构建PC WEB SQL
|
|
|
-func buildPCWEBSQL(datas []interface{}, parentCode string, level int) string {
|
|
|
|
|
|
|
+func buildPCWEBSQL(datas []interface{}, parentCode string, level int, clientType int) string {
|
|
|
var sql string
|
|
var sql string
|
|
|
|
|
|
|
|
for i, v := range datas {
|
|
for i, v := range datas {
|
|
@@ -160,17 +168,17 @@ func buildPCWEBSQL(datas []interface{}, parentCode string, level int) string {
|
|
|
|
|
|
|
|
sql += "INSERT INTO FUNCMENULIST (RESOURCECODE, RESOURCENAME, RESOURCELEVEL, MENUTYPE, PARENTCODE, URL, SORT, ICONAME, REMARK)\n"
|
|
sql += "INSERT INTO FUNCMENULIST (RESOURCECODE, RESOURCENAME, RESOURCELEVEL, MENUTYPE, PARENTCODE, URL, SORT, ICONAME, REMARK)\n"
|
|
|
if parentCode == "" {
|
|
if parentCode == "" {
|
|
|
- sql += fmt.Sprintf("VALUES('%s', '%s', %d, 5, NULL, '', %d, '', '%s');\n", rulekey, title, level, i+1, remark)
|
|
|
|
|
|
|
+ sql += fmt.Sprintf("VALUES('%s', '%s', %d, %d, NULL, '', %d, '', '%s');\n", rulekey, title, level, clientType, i+1, remark)
|
|
|
} else {
|
|
} else {
|
|
|
- sql += fmt.Sprintf("VALUES('%s', '%s', %d, 5, '%s', '', %d, '', '%s');\n", rulekey, title, level, parentCode, i+1, remark)
|
|
|
|
|
|
|
+ sql += fmt.Sprintf("VALUES('%s', '%s', %d, %d, '%s', '', %d, '', '%s');\n", rulekey, title, level, clientType, parentCode, i+1, remark)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 递归
|
|
// 递归
|
|
|
if data["auth"] != nil {
|
|
if data["auth"] != nil {
|
|
|
- sql += buildPCWEBSQL(data["auth"].([]interface{}), data["rulekey"].(string), level+1)
|
|
|
|
|
|
|
+ sql += buildPCWEBSQL(data["auth"].([]interface{}), data["rulekey"].(string), level+1, clientType)
|
|
|
}
|
|
}
|
|
|
if data["children"] != nil {
|
|
if data["children"] != nil {
|
|
|
- sql += buildPCWEBSQL(data["children"].([]interface{}), data["rulekey"].(string), level+1)
|
|
|
|
|
|
|
+ sql += buildPCWEBSQL(data["children"].([]interface{}), data["rulekey"].(string), level+1, clientType)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if level == 1 {
|
|
if level == 1 {
|