refactor: 引入tailwind css & 后端部分非公共包位置调整

This commit is contained in:
meilin.huang
2025-04-18 22:07:37 +08:00
parent 585cbbed23
commit abd2b4bac0
168 changed files with 763 additions and 793 deletions

View File

@@ -1,34 +0,0 @@
package consts
import "time"
const (
AdminId = 1
MachineConnExpireTime = 60 * time.Minute
DbConnExpireTime = 120 * time.Minute
RedisConnExpireTime = 30 * time.Minute
MongoConnExpireTime = 30 * time.Minute
/**** 开发测试使用 ****/
// MachineConnExpireTime = 4 * time.Minute
// DbConnExpireTime = 2 * time.Minute
// RedisConnExpireTime = 2 * time.Minute
// MongoConnExpireTime = 2 * time.Minute
ResourceTypeMachine int8 = 1
ResourceTypeDbInstance int8 = 2
ResourceTypeRedis int8 = 3
ResourceTypeMongo int8 = 4
// imsg起始编号
ImsgNumSys = 10000
ImsgNumAuth = 20000
ImsgNumTag = 30000
ImsgNumFlow = 40000
ImsgNumMachine = 50000
ImsgNumDb = 60000
ImsgNumRedis = 70000
ImsgNumMongo = 80000
ImsgNumMsg = 90000
)

View File

@@ -1,56 +0,0 @@
package utils
import (
"mayfly-go/pkg/config"
"regexp"
)
// 检查用户密码安全等级
func CheckAccountPasswordLever(ps string) bool {
if len(ps) < 8 {
return false
}
// 包含大写字母
charRegex := regexp.MustCompile(`[a-zA-Z]`)
// 包含数字
digitRegex := regexp.MustCompile(`[0-9]`)
// 包含特殊符号
specialCharRegex := regexp.MustCompile(`[!@#$%^&*(),.?":{}|<>]`)
return charRegex.MatchString(ps) &&
digitRegex.MatchString(ps) &&
specialCharRegex.MatchString(ps)
}
// 使用config.yml的aes.key进行密码加密
func PwdAesEncrypt(password string) (string, error) {
if password == "" {
return "", nil
}
aes := config.Conf.Aes
if aes.Key == "" {
return password, nil
}
encryptPwd, err := aes.EncryptBase64([]byte(password))
if err != nil {
return "", err
}
return encryptPwd, nil
}
// 使用config.yml的aes.key进行密码解密
func PwdAesDecrypt(encryptPwd string) (string, error) {
if encryptPwd == "" {
return "", nil
}
aes := config.Conf.Aes
if aes.Key == "" {
return encryptPwd, nil
}
decryptPwd, err := aes.DecryptBase64(encryptPwd)
if err != nil {
return "", err
}
// 解密后的密码
return string(decryptPwd), nil
}

View File

@@ -1,118 +0,0 @@
package utils
import (
"bufio"
"bytes"
"io"
"strings"
"unicode/utf8"
)
// StmtCallback stmt回调函数
type StmtCallback func(stmt string) error
// SplitStmts 语句切割(用于以;结尾为一条语句,并且去除// -- /**/等注释)主要由阿里通义灵码提供
func SplitStmts(r io.Reader, callback StmtCallback) error {
reader := bufio.NewReaderSize(r, 512*1024)
buffer := new(bytes.Buffer) // 使用 bytes.Buffer 来处理数据
var currentStatement bytes.Buffer
var inString bool
var inMultiLineComment bool
var inSingleLineComment bool
var stringDelimiter rune
var escapeNextChar bool // 用于处理转义符
for {
// 读取数据到缓冲区
data, err := reader.ReadBytes('\n') // 按行读取
if err == io.EOF && len(data) == 0 {
break
}
if err != nil && err != io.EOF {
return err
}
buffer.Write(data)
// 处理缓冲区中的数据
for buffer.Len() > 0 {
r, size := utf8.DecodeRune(buffer.Bytes())
if r == utf8.RuneError && size == 1 {
// 如果解码出错,说明数据不完整,继续读取更多数据
break
}
switch {
case inMultiLineComment:
if r == '*' && buffer.Len() >= 2 && buffer.Bytes()[1] == '/' {
inMultiLineComment = false
buffer.Next(2) // 跳过 '*/'
} else {
buffer.Next(size)
}
case inSingleLineComment:
if r == '\n' {
inSingleLineComment = false
}
buffer.Next(size)
case inString:
if escapeNextChar {
// 当前字符是转义后的字符,直接写入。如后一个为" 避免进入r==stringDelimiter判断被当做字符串结束符中断
currentStatement.WriteRune(r)
escapeNextChar = false
} else if r == '\\' {
// 当前字符是转义符,设置标志位并写入
escapeNextChar = true
currentStatement.WriteRune(r)
} else if r == stringDelimiter {
// 当前字符是字符串结束符,结束字符串处理
inString = false
currentStatement.WriteRune(r)
} else {
// 其他字符,直接写入
currentStatement.WriteRune(r)
}
buffer.Next(size)
case r == '/' && buffer.Len() >= 2 && buffer.Bytes()[1] == '*':
inMultiLineComment = true
buffer.Next(2) // 跳过 '/*'
case r == '-' && buffer.Len() >= 2 && buffer.Bytes()[1] == '-':
inSingleLineComment = true
buffer.Next(2) // 跳过 '--'
case r == '\'' || r == '"':
inString = true
stringDelimiter = r
currentStatement.WriteRune(r)
buffer.Next(size)
case r == ';' && !inString && !inMultiLineComment && !inSingleLineComment:
sql := strings.TrimSpace(currentStatement.String())
if sql != "" {
if err := callback(sql); err != nil {
return err
}
}
currentStatement.Reset()
buffer.Next(size)
default:
currentStatement.WriteRune(r)
buffer.Next(size)
}
}
// 如果读取到 EOF 并且缓冲区为空,退出循环
if err == io.EOF && buffer.Len() == 0 {
break
}
}
// 处理最后剩余的缓冲区
if currentStatement.Len() > 0 {
sql := strings.TrimSpace(currentStatement.String())
if sql != "" {
if err := callback(sql); err != nil {
return err
}
}
}
return nil
}