liuxiaolong
2022-03-04 f64dd9f191dff341b4eb430d7bacc44a3db9a279
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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()
}