Browse Source

过滤非中文表头

Jianghan 1 year ago
parent
commit
1de4f12984
1 changed files with 6 additions and 2 deletions
  1. 6 2
      service/exprot.go

+ 6 - 2
service/exprot.go

@@ -8,6 +8,7 @@ import (
 	"math/rand"
 	"os"
 	"path/filepath"
+	"regexp"
 	"strings"
 	"time"
 
@@ -255,8 +256,8 @@ func compressFiles(filePattern []string, path, timeStr string) {
 
 // 数据导出(通用)
 func (e *ExportByDbReq) ExportDataByDb() []byte {
-
 	key := hName(e.Query)
+	log.Println("", key)
 	timeStr := time.Now().Format("20060102150405")
 	rand.Seed(time.Now().UnixNano())
 	randomInt := rand.Intn(10000) // 生成0到9999之间的随机整数
@@ -300,7 +301,10 @@ func hName(sql string) []interface{} {
 		if strings.Contains(s1, "as") {
 			a1 := strings.Split(s1, "as")
 			l1 := len(a1)
-			key = append(key, a1[l1-1])
+			chiReg := regexp.MustCompile("[^\u4e00-\u9fa5]")
+			if !chiReg.MatchString(a1[l1-1]) {
+				key = append(key, a1[l1-1])
+			}
 		}
 	}
 	return key