订单写入数据库

This commit is contained in:
2026-02-09 20:43:55 +08:00
parent 2bdbe0f041
commit 357b505275
6 changed files with 165 additions and 48 deletions
+16
View File
@@ -5,6 +5,7 @@ import (
"crypto/rand"
"encoding/hex"
"regexp"
"strings"
"time"
)
@@ -23,6 +24,15 @@ func GetCurrentTimeString(format ...string) string {
return time.Now().Format(layout)
}
func StringToTimePtr(str string) (*time.Time, error) {
layout := "2006-01-02 15:04"
t, err := time.Parse(layout, str)
if err != nil {
return nil, err
}
return &t, nil
}
func RandStr32() string {
// 生成 32 字节 (256 位) 随机数据
b := make([]byte, 32)
@@ -90,3 +100,9 @@ func IsEmailValid(email string) bool {
regex := regexp.MustCompile(pattern)
return regex.MatchString(email)
}
// 判断字符串是否包含标点符号
func IsContainsSpecialChar(str string) bool {
specialChars := "!@#$%^&*()-+={}[]|\\:;\"'<>,.?/"
return strings.ContainsAny(str, specialChars)
}