1
This commit is contained in:
46
controllers/app/sendVerifyCode.go
Normal file
46
controllers/app/sendVerifyCode.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-print/controllers"
|
||||
"git.rosy.net.cn/jx-print/model"
|
||||
"git.rosy.net.cn/jx-print/model/app_model"
|
||||
"git.rosy.net.cn/jx-print/services/print_server/app_server"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Verification struct{}
|
||||
|
||||
var VerificationController = new(Verification)
|
||||
|
||||
// SendVerifyCode 获取短信验证码
|
||||
// @Title 登录接口
|
||||
// @Description 登录接口(微信与公众号登录不能直接调用此接口)
|
||||
// @Param data body app_model.VerificationPhoneCode true "请求参数"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /sendVerifyCode [post]
|
||||
func (a *Verification) SendVerifyCode(c *gin.Context) {
|
||||
// 参数绑定
|
||||
var (
|
||||
err error
|
||||
params *app_model.VerificationPhoneCode
|
||||
service = app_server.SendVerifyCodeServer
|
||||
)
|
||||
|
||||
if err = c.ShouldBind(¶ms); err != nil {
|
||||
c.JSON(http.StatusOK, &model.CallBack{
|
||||
Code: model.ErrCodeNormal,
|
||||
Desc: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
controllers.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
bizId, err := service.SendCode(params.PhoneNumber)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return map[string]interface{}{"bizId": bizId}, "", nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user