Browse Source

修改创建企业用户id

yuliang1112 2 years ago
parent
commit
ec7530f21c
1 changed files with 6 additions and 3 deletions
  1. 6 3
      service/enterprise.go

+ 6 - 3
service/enterprise.go

@@ -2,7 +2,9 @@ package service
 
 import (
 	"context"
+	"fmt"
 	"math/rand"
+	"strconv"
 	"time"
 	"youngee_b_api/db"
 	"youngee_b_api/model/gorm_model"
@@ -35,15 +37,16 @@ func (*enterprise) CreateEnterpriseUser(ctx context.Context, newEnterprise http_
 		return nil, err
 	} else {
 		rand.Seed(time.Now().UnixNano())
-		th := conv.MustString(time.Now().Hour())
-		tm := conv.MustString(time.Now().Minute())
+		th := strconv.Itoa(time.Now().Hour())
+		tm := strconv.Itoa(time.Now().Minute())
 		if len(tm) < 2 {
 			tm = "0" + tm
 		}
 		if len(th) < 2 {
 			th = "0" + th
 		}
-		ShowEnterpriseID := "1" + th + tm + conv.MustString(rand.Intn(10000-1000)+1000)
+		//ShowEnterpriseID := "1" + th + tm + conv.MustString(rand.Intn(10000-1000)+1000
+		ShowEnterpriseID := "1" + th + tm + fmt.Sprintf("%04v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000))
 		enterprise := &gorm_model.Enterprise{
 			EnterpriseID:     ShowEnterpriseID,
 			Industry:         newEnterprise.Industry,