zhou.xiaoning 3 anni fa
parent
commit
ea3dcd9b14

+ 1 - 3
.gitignore

@@ -20,9 +20,7 @@ _cgo_export.*
 
 _testmain.go
 
-*.exe
 *.test
 *.prof
 
-permission_generator/out
-permission_generator/buildsql
+permission_generator/out

BIN
permission_generator/buildsql


BIN
permission_generator/buildsql.exe


+ 19 - 11
permission_generator/main.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"os"
+	"strconv"
 	"time"
 )
 
@@ -28,7 +29,7 @@ func main() {
 		clientType string // 终端类型: 1-PCWEB 2-手机
 	)
 
-	fmt.Println("请输入终端类型: (1-PCWEB 2-手机)")
+	fmt.Println("请输入终端类型: (3-手机 4-PC大宗 5-PC风管)")
 	fmt.Scanln(&clientType)
 
 	fmt.Println("请输入菜单JSON文件地址:")
@@ -55,16 +56,23 @@ func main() {
 	}
 
 	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"
-	} else {
+	} else if clientType == "3" {
 		s += "-- 说明:MENUTYPE = 3 为手机专用的终端权限\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 {
 		s += buildSQL(datas, "", 1)
 	}
@@ -134,7 +142,7 @@ func buildSQL(datas []interface{}, parentCode string, level int) string {
 }
 
 // 构建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
 
 	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"
 			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 {
-				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 {
-				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 {
-				sql += buildPCWEBSQL(data["children"].([]interface{}), data["rulekey"].(string), level+1)
+				sql += buildPCWEBSQL(data["children"].([]interface{}), data["rulekey"].(string), level+1, clientType)
 			}
 
 			if level == 1 {