feat: adjust id format
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package constant
|
||||
|
||||
const CleanLogsTaskId = "00000000-0000-0000-0000-000000000001"
|
||||
const CleanLogsTaskId = "T-IM1GBswSRY"
|
||||
const SiteSettingSectionName = "site_config"
|
||||
|
||||
//const SiteSettingTitleKeyName = "title"
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func TimeStampToYmdMHD(stamp int) string {
|
||||
timestamp := int64(stamp)
|
||||
timeObj := time.Unix(timestamp, 0)
|
||||
formattedTime := timeObj.Format("2006-01-02 15:04:05")
|
||||
return formattedTime
|
||||
}
|
||||
|
||||
func GetNowTimeStampToYmdMHD() string {
|
||||
now := time.Now().Unix()
|
||||
timeObj := time.Unix(now, 0)
|
||||
formattedTime := timeObj.Format("2006-01-02 15:04:05")
|
||||
return formattedTime
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GenerateRandomString(length int) string {
|
||||
source := rand.NewSource(time.Now().UnixNano())
|
||||
random := rand.New(source)
|
||||
|
||||
charSet := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
||||
var result string
|
||||
var charSetLen = len(charSet)
|
||||
|
||||
for i := 0; i < length; i++ {
|
||||
randomIndex := random.Intn(charSetLen)
|
||||
result += string(charSet[randomIndex])
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func GenerateUniqueID() string {
|
||||
randomString := GenerateRandomString(10)
|
||||
return randomString
|
||||
}
|
||||
Reference in New Issue
Block a user