tuiguangm
This commit is contained in:
@@ -227,7 +227,7 @@ func CreateUser(user *model.User, creatorName string) (err error) {
|
|||||||
user.Status = model.UserStatusNormal
|
user.Status = model.UserStatusNormal
|
||||||
// user.DividePercentage = 1
|
// user.DividePercentage = 1
|
||||||
//推广码
|
//推广码
|
||||||
user.PopCode = jxutils.GenValidateCode(6)
|
user.PopCode = jxutils.GenRandomString(6)
|
||||||
return dao.CreateEntity(nil, user)
|
return dao.CreateEntity(nil, user)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -894,16 +894,13 @@ func polarTriangleArea(tan1, lng1, tan2, lng2 float64) (s float64) {
|
|||||||
return 2 * math.Atan2(t*math.Sin(deltaLng), 1+t*math.Cos(deltaLng))
|
return 2 * math.Atan2(t*math.Sin(deltaLng), 1+t*math.Cos(deltaLng))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenValidateCode(width int) string {
|
func GenRandomString(l int) string {
|
||||||
numeric := [36]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
|
str := "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
|
bytes := []byte(str)
|
||||||
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'}
|
result := []byte{}
|
||||||
r := len(numeric)
|
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
rand.Seed(time.Now().UnixNano())
|
for i := 0; i < l; i++ {
|
||||||
|
result = append(result, bytes[r.Intn(len(bytes))])
|
||||||
var sb strings.Builder
|
|
||||||
for i := 0; i < width; i++ {
|
|
||||||
fmt.Fprintf(&sb, "%d", numeric[rand.Intn(r)])
|
|
||||||
}
|
}
|
||||||
return sb.String()
|
return string(result)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user