|
@@ -1,9 +1,6 @@
|
|
|
package auth
|
|
package auth
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
- "fmt"
|
|
|
|
|
- "net/http"
|
|
|
|
|
-
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
|
v1 "github.com/runningwater/gohub/app/http/controllers/api/v1"
|
|
v1 "github.com/runningwater/gohub/app/http/controllers/api/v1"
|
|
|
"github.com/runningwater/gohub/app/models/user"
|
|
"github.com/runningwater/gohub/app/models/user"
|
|
@@ -19,23 +16,7 @@ func (controller *SignupController) IsPhoneExist(c *gin.Context) {
|
|
|
|
|
|
|
|
// 初始化请求对象
|
|
// 初始化请求对象
|
|
|
req := requests.SignupPhoneExistRequest{}
|
|
req := requests.SignupPhoneExistRequest{}
|
|
|
-
|
|
|
|
|
- // 解析 JSON 请求
|
|
|
|
|
- if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
|
- c.AbortWithStatusJSON(http.StatusUnprocessableEntity, gin.H{
|
|
|
|
|
- "error": "请求参数错误"+ err.Error(),
|
|
|
|
|
- })
|
|
|
|
|
- // 打印错误信息
|
|
|
|
|
- fmt.Println(err.Error())
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 表单验证
|
|
|
|
|
- errs := requests.ValidateSignupPhoneExist(&req, c)
|
|
|
|
|
- if len(errs) > 0 {
|
|
|
|
|
- c.AbortWithStatusJSON(http.StatusUnprocessableEntity, gin.H{
|
|
|
|
|
- "errors": errs,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if ok := requests.Validate(c, &req, requests.ValidateSignupPhoneExist); !ok {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -50,23 +31,7 @@ func (controller *SignupController) IsEmailExist(c *gin.Context) {
|
|
|
|
|
|
|
|
// 初始化请求对象
|
|
// 初始化请求对象
|
|
|
req := requests.SignupEmailExistRequest{}
|
|
req := requests.SignupEmailExistRequest{}
|
|
|
-
|
|
|
|
|
- // 解析 JSON 请求
|
|
|
|
|
- if err := c.ShouldBindJSON(&req); err != nil {
|
|
|
|
|
- c.AbortWithStatusJSON(http.StatusUnprocessableEntity, gin.H{
|
|
|
|
|
- "error": "请求参数错误"+ err.Error(),
|
|
|
|
|
- })
|
|
|
|
|
- // 打印错误信息
|
|
|
|
|
- fmt.Println(err.Error())
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 表单验证
|
|
|
|
|
- errs := requests.ValidateSignupEmailExist(&req, c)
|
|
|
|
|
- if len(errs) > 0 {
|
|
|
|
|
- c.AbortWithStatusJSON(http.StatusUnprocessableEntity, gin.H{
|
|
|
|
|
- "errors": errs,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ if ok := requests.Validate(c, &req, requests.ValidateSignupEmailExist);!ok {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|