This commit is contained in:
suyl
2021-07-07 18:23:47 +08:00
parent ecbded38dc
commit ee1f00ab29
2 changed files with 34 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
package controllers
import (
"fmt"
"git.rosy.net.cn/jx-print/globals"
"git.rosy.net.cn/jx-print/model"
"git.rosy.net.cn/jx-print/services"
@@ -35,3 +36,35 @@ func GetApps(c *gin.Context) {
}
return
}
type AddAppParam struct {
Code string `json:"code" form:"code"` //手机验证码
Mobile string `json:"mobile" form:"mobile"` //手机号
}
//新建app POST
func AddApp(c *gin.Context) {
var (
b, ok bool
token string
user *model.User
)
globals.SugarLogger.Debugf("Begin API :%s params: %v ip: %s", c.Request.URL, c.Params, c.ClientIP())
if token, b = checkToken(c); !b {
return
}
if user, ok = utils.GetKet(token).(*model.User); !ok {
c.JSON(http.StatusOK, &CallBack{
Code: model.ErrCodeToken,
Desc: "token 过期或无效!",
})
return
}
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
fmt.Println(user)
return retVal, "", err
}) {
return
}
return
}

View File

@@ -16,6 +16,7 @@ func Init(r *gin.Engine) {
//app
app := v2.Group("/app")
app.GET("/getApps", controllers.GetApps)
app.GET("/addApp", controllers.AddApp)
//v1是不需要token的
v1 := r.Group("v1")