package api
|
|
|
|
import (
|
|
model "LAPP_GAAS_GFrame_BACKEND/models/api"
|
|
"LAPP_GAAS_GFrame_BACKEND/web/middleware/jwts"
|
|
"LAPP_GAAS_GFrame_BACKEND/web/models"
|
|
"LAPP_GAAS_GFrame_BACKEND/web/supports"
|
|
"github.com/kataras/iris/v12"
|
|
"github.com/kataras/iris/v12/core/router"
|
|
)
|
|
|
|
/******************************************************************************
|
|
*
|
|
* @Function Name : RegisterTouchOffAndon
|
|
*-----------------------------------------------------------------------------
|
|
*
|
|
* @Description : andon触发调用mes
|
|
*
|
|
* @Function Parameters : 路由分组
|
|
*
|
|
* @Function Parameters : 路径
|
|
*
|
|
* @Function Parameters : 实际处理请求的方法
|
|
*
|
|
* @Author : zhangxin
|
|
*
|
|
* @Date : 2021-05-17
|
|
*
|
|
******************************************************************************/
|
|
func RegisterTouchOffAndon(party router.Party, path string, method func(*models.Usertab) (model.Andon, error)) {
|
|
|
|
party.Post(path, func(ctx iris.Context) {
|
|
|
|
user, ok := jwts.ParseToken(ctx)
|
|
if !ok {
|
|
supports.Error(ctx, iris.StatusBadRequest, supports.ParseParamsFailur, nil)
|
|
return
|
|
}
|
|
|
|
result, err := method(user)
|
|
if err != nil {
|
|
supports.Error(ctx, iris.StatusBadRequest, err.Error(), nil)
|
|
return
|
|
}
|
|
supports.Ok(ctx, supports.OptionSuccess, result)
|
|
})
|
|
}
|
|
|