202 Star 1.9K Fork 613

张奇峰 / GinSkeleton

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
destroy_before.go 592 Bytes
一键复制 编辑 Web IDE 原始数据 按行查看 历史
张奇峰 提交于 2020-08-17 11:31 . 项目编码规划化进行中...
package users
import (
"github.com/gin-gonic/gin"
"goskeleton/app/global/consts"
"goskeleton/app/global/variable"
)
// 模拟Aop 实现对某个控制器函数的前置和后置回调
type DestroyBefore struct{}
// 前置函数必须具有返回值,这样才能控制流程是否继续向下执行
func (d *DestroyBefore) Before(context *gin.Context) bool {
userId := context.GetFloat64(consts.ValidatorPrefix + "id")
variable.ZapLog.Sugar().Infof("模拟 Users 删除操作, Before 回调,用户ID:%.f\n", userId)
if userId > 10 {
return true
} else {
return false
}
}
Go
1
https://gitee.com/daitougege/GinSkeleton.git
git@gitee.com:daitougege/GinSkeleton.git
daitougege
GinSkeleton
GinSkeleton
master

搜索帮助

14c37bed 8189591 565d56ea 8189591