lhs před 4 roky
rodič
revize
c2edf26400
3 změnil soubory, kde provedl 19 přidání a 7 odebrání
  1. 6 4
      global/init.go
  2. 2 1
      repository/http/loallout_server.go
  3. 11 2
      service/auth.go

+ 6 - 4
global/init.go

@@ -17,9 +17,11 @@ var (
 			Host string
 		}
 
-		DBName   string
-		LogLevel string
-		Host     string
-		Debug    bool
+		DBName       string
+		LogLevel     string
+		Host         string
+		Debug        bool
+		LoalloutUrl  string
+		HeartrateUrl string
 	}
 )

+ 2 - 1
repository/http/loallout_server.go

@@ -8,13 +8,14 @@ import (
 	"net/url"
 	"strings"
 	"video_course/errors"
+	"video_course/global"
 )
 
 type LoalloutServer struct {
 }
 
 func (l LoalloutServer) CheckPhone(phone string) (userMd5 string) {
-	api := strings.Join([]string{"http://192.168.0.3:19095", "v1/Auth/CheckPhone"}, "/")
+	api := strings.Join([]string{global.Project.LoalloutUrl, "v1/Auth/CheckPhone"}, "/")
 
 	resp, err := http.PostForm(api, url.Values{
 		"phone": {phone},

+ 11 - 2
service/auth.go

@@ -85,13 +85,22 @@ func (a Auth) GenVFCode(codeTypeInt int, phone string, ip string,
 	//if !store.Verify(picId, picCode, true) {
 	//	return errors.ErrPicVerifyCode
 	//}
+	//手机号验证
+	userMd5 := h.LoalloutServer{}.CheckPhone(phone)
+	if userMd5 == "" {
+		return errors.ErrUserNotExists
+	}
 	//生成短信验证码
+	//rand.Seed(time.Now().Unix())
+	//smsInt := rand.Int31n(10000)
+	//smsCode :=  strconv.Itoa(smsInt)
 	smsCode := "12345678"
-	//发送短信
-	fmt.Println(smsCode)
+
 	//存储短信验证码
 	redisdb := rdb.GetRedis()
 	redisdb.Set(global.ProjectName+":"+global.AppName+":"+"smsCode:"+phone, []byte(smsCode), 3*time.Minute)
+	//发送短信
+	fmt.Println(smsCode)
 
 	return
 	//dao := a.getUserDao()