package controllers
|
|
import (
|
"car-service/extend/code"
|
"car-service/service"
|
"github.com/astaxie/beego"
|
"net/http"
|
)
|
|
type CodeController struct {
|
beego.Controller
|
}
|
|
// @router /new [get]
|
func (c *CodeController) New() {
|
phoneNum := c.GetString("phoneNum")
|
resp := code.Code{}
|
if phoneNum == "" {
|
resp.Success= false
|
resp.Status= http.StatusBadRequest
|
resp.Data= nil
|
} else {
|
err := service.NewVerifyCode(phoneNum)
|
if err == nil {
|
resp.Success= true
|
resp.Status= http.StatusOK
|
resp.Data= "发送成功"
|
} else {
|
resp.Success= false
|
resp.Status= http.StatusBadRequest
|
resp.Message= err.Error()
|
}
|
}
|
c.Data["json"] = resp
|
c.ServeJSON()
|
}
|