Files
novel/internal/service/bizctx.go
2024-01-12 18:08:51 +08:00

43 lines
1.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"context"
"novel/internal/model"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/net/ghttp"
)
type (
IBizCtx interface {
// Init 初始化上下文对象指针到上下文对象中,以便后续的请求流程中可以修改。
Init(r *ghttp.Request, customCtx *model.Context)
// Get 获得上下文变量如果没有设置那么返回nil
Get(ctx context.Context) *model.Context
// SetUser 将上下文信息设置到上下文请求中,注意是完整覆盖
SetUser(ctx context.Context, ctxUser *model.ContextUser)
// SetData 将上下文信息设置到上下文请求中,注意是完整覆盖
SetData(ctx context.Context, data g.Map)
}
)
var (
localBizCtx IBizCtx
)
func BizCtx() IBizCtx {
if localBizCtx == nil {
panic("implement not found for interface IBizCtx, forgot register?")
}
return localBizCtx
}
func RegisterBizCtx(i IBizCtx) {
localBizCtx = i
}