refactor: adjust project structure
This commit is contained in:
24
service/sms/preValidate.go
Normal file
24
service/sms/preValidate.go
Normal file
@ -0,0 +1,24 @@
|
||||
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"
|
||||
}
|
Reference in New Issue
Block a user