package utils import ( "fmt" "math/rand" "time" ) var GetUuid = getUuid{} type getUuid struct { } func (*getUuid) GetTalentId() string { now := time.Now() nowStr := time.Time.String(now) str1 := nowStr[11:13] + nowStr[14:16] str2 := fmt.Sprintf("%04v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000)) tid := "2" + str1 + str2 return tid } func (*getUuid) GetTaskId(ProjectId string, EnterpriseId string, TalentId string) string { str1 := ProjectId[len(ProjectId)-2:] + EnterpriseId[len(EnterpriseId)-1:] + TalentId[len(TalentId)-2:] str2 := fmt.Sprintf("%05v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(100000)) tid := str1 + str2 return tid } func (*getUuid) GetTeamId(ProjectId string, SelectionId string, TalentId string) string { str0 := ProjectId + SelectionId str1 := str0[len(str0)-3:] + TalentId[len(TalentId)-2:] str2 := fmt.Sprintf("%05v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(100000)) tid := str1 + str2 return tid } func (*getUuid) GetRandomString(l int) string { str := "0123456789" bytes := []byte(str) var result []byte r := rand.New(rand.NewSource(time.Now().UnixNano())) for i := 0; i < l; i++ { result = append(result, bytes[r.Intn(len(bytes))]) } return string(result) }