表单数据持久化

This commit is contained in:
2024-09-13 20:33:36 +08:00
parent 250ffb4e20
commit a77308573e
4 changed files with 30 additions and 12 deletions
+25 -7
View File
@@ -9,19 +9,37 @@ import (
"time"
)
var uuidint = 0
var lock sync.Mutex
type UuidUtil struct {
lock sync.Mutex
uuidint int
}
func CreateUUID() string {
lock.Lock()
defer lock.Unlock()
var Uuid = &UuidUtil{}
func (u *UuidUtil) CreateUUID() string {
u.lock.Lock()
defer u.lock.Unlock()
// 生成基于字符串的 UUID
key := fmt.Sprintln(Get192Ip(), time.Now().Format("2006-01-02_15-04-05"), uuidint)
uuidint++
key := fmt.Sprintln(IP.Get192Ip(), time.Now().Format("2006-01-02_15-04-05"), u.uuidint)
u.uuidint++
u1 := uuid.NewSHA1(uuid.Nil, []byte(key))
return u1.String()
}
type IpUtil struct {
Ip string
}
var IP = &IpUtil{}
func (i *IpUtil) Get192Ip() string {
if i.Ip == "" {
i.Ip = Get192Ip()
return i.Ip
}
return i.Ip
}
func Get192Ip() string {
interfaces, err := net.Interfaces()
if err != nil {