修改打印模板
This commit is contained in:
@@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.rosy.net.cn/jx-print/controllers/controller"
|
||||
"git.rosy.net.cn/jx-print/globals"
|
||||
"git.rosy.net.cn/jx-print/model"
|
||||
"git.rosy.net.cn/jx-print/putils"
|
||||
@@ -28,22 +29,22 @@ func RegisterUser(c *gin.Context) {
|
||||
user = &UserParam{}
|
||||
)
|
||||
if err = c.ShouldBind(&user); err != nil {
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
c.JSON(http.StatusOK, &model.CallBack{
|
||||
Code: model.ErrCodeNormal,
|
||||
Desc: err.Error(),
|
||||
})
|
||||
globals.SugarLogger.Debugf("API :%s error:%v:", c.Request.URL, err)
|
||||
return
|
||||
}
|
||||
if !captchaVerify(c, user.Code) {
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
if !controller.CaptchaVerify(c, user.Code) {
|
||||
c.JSON(http.StatusOK, &model.CallBack{
|
||||
Code: model.ErrCodeNormal,
|
||||
Desc: "验证码错误!",
|
||||
})
|
||||
globals.SugarLogger.Debugf("End API :%s error:%v:", c.Request.URL, err)
|
||||
return
|
||||
}
|
||||
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
if !controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
err = print_server.RegisterUser(c, user.Name, user.Password)
|
||||
return retVal, "", err
|
||||
}) {
|
||||
@@ -59,22 +60,22 @@ func Login(c *gin.Context) {
|
||||
user = &UserParam{}
|
||||
)
|
||||
if err = c.ShouldBind(&user); err != nil {
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
c.JSON(http.StatusOK, &model.CallBack{
|
||||
Code: model.ErrCodeNormal,
|
||||
Desc: err.Error(),
|
||||
})
|
||||
globals.SugarLogger.Debugf("End API :%s error:%v:", c.Request.URL, err)
|
||||
return
|
||||
}
|
||||
if !captchaVerify(c, user.Code) {
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
if !controller.CaptchaVerify(c, user.Code) {
|
||||
c.JSON(http.StatusOK, &model.CallBack{
|
||||
Code: model.ErrCodeNormal,
|
||||
Desc: "验证码错误!",
|
||||
})
|
||||
globals.SugarLogger.Debugf("End API :%s error:%v:", c.Request.URL, err)
|
||||
return
|
||||
}
|
||||
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
if !controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = print_server.Login(c, user.Name, user.Password)
|
||||
return retVal, "", err
|
||||
}) {
|
||||
@@ -88,11 +89,11 @@ func GetTokenInfo(c *gin.Context) {
|
||||
var (
|
||||
tokenInfo *model.TokenInfo
|
||||
)
|
||||
if tokenInfo = checkToken(c); tokenInfo == nil {
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
data, _ := json.Marshal(tokenInfo)
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
c.JSON(http.StatusOK, &model.CallBack{
|
||||
Code: model.ErrCodeSuccess,
|
||||
Data: string(data),
|
||||
})
|
||||
@@ -104,10 +105,10 @@ func Logout(c *gin.Context) {
|
||||
var (
|
||||
tokenInfo *model.TokenInfo
|
||||
)
|
||||
if tokenInfo = checkToken(c); tokenInfo == nil {
|
||||
if tokenInfo = controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
if !controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
err = print_server.Logout(c, tokenInfo.Token)
|
||||
return retVal, "", err
|
||||
}) {
|
||||
@@ -125,17 +126,17 @@ func UpdateUser(c *gin.Context) {
|
||||
}{}
|
||||
)
|
||||
if err = c.ShouldBind(&user); err != nil {
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
c.JSON(http.StatusOK, &model.CallBack{
|
||||
Code: model.ErrCodeNormal,
|
||||
Desc: err.Error(),
|
||||
})
|
||||
globals.SugarLogger.Debugf("End API :%s error:%v:", c.Request.URL, err)
|
||||
return
|
||||
}
|
||||
if tokenInfo := checkToken(c); tokenInfo == nil {
|
||||
if tokenInfo := controller.CheckToken(c); tokenInfo == nil {
|
||||
return
|
||||
}
|
||||
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
if !controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
err = print_server.UpdateUser(c, user.Payload)
|
||||
return retVal, "", err
|
||||
}) {
|
||||
@@ -146,7 +147,7 @@ func UpdateUser(c *gin.Context) {
|
||||
|
||||
//获取菜单,文档 GET
|
||||
func GetMenus(c *gin.Context) {
|
||||
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
if !controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = print_server.GetMenus(c)
|
||||
return retVal, "", err
|
||||
}) {
|
||||
@@ -164,14 +165,14 @@ func GetMenuDetail(c *gin.Context) {
|
||||
}{}
|
||||
)
|
||||
if err = c.ShouldBind(&user); err != nil {
|
||||
c.JSON(http.StatusOK, &CallBack{
|
||||
c.JSON(http.StatusOK, &model.CallBack{
|
||||
Code: model.ErrCodeNormal,
|
||||
Desc: err.Error(),
|
||||
})
|
||||
globals.SugarLogger.Debugf("End API :%s error:%v:", c.Request.URL, err)
|
||||
return
|
||||
}
|
||||
if !callFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
if !controller.CallFunc(c, func() (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = print_server.GetMenuDetail(c, user.ID)
|
||||
return retVal, "", err
|
||||
}) {
|
||||
|
||||
Reference in New Issue
Block a user