2024-10-28 14:41:27 +08:00
|
|
|
package sms
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"health-go/config"
|
2024-11-14 01:15:55 +08:00
|
|
|
"health-go/model"
|
2024-10-28 14:41:27 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func PreValidate(userTel string) string {
|
|
|
|
|
2024-11-14 01:15:55 +08:00
|
|
|
var result model.User
|
2024-10-28 14:41:27 +08:00
|
|
|
// 计数查询是否存在对应的手机号
|
|
|
|
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"
|
|
|
|
}
|