health-go/service/sms/preValidate.go

25 lines
438 B
Go

package sms
import (
"fmt"
"health-go/config"
"health-go/model"
)
func PreValidate(userTel string) string {
var result model.User
// 计数查询是否存在对应的手机号
query := config.DB.Table("user").Where("tel = ?", userTel).First(&result)
if query.Error != nil {
return fmt.Sprint(query.Error)
}
if query.RowsAffected == 0 {
return "notExist"
}
if result.SMSTry > 10 {
return "reachLimit"
}
return "ok"
}