补齐证书任务创建人归属

传递已认证操作者上下文,关联证书任务审计,并同步四份整改清单进度。
This commit is contained in:
xuans committed 2026-09-30 02:40:41 +08:00
1 parent 4cf9fb6076
commit 5fecd05d46
8 files changed
+100 -5

No files matched your search

+16 -1
View File
@@ -1,6 +1,9 @@
package repository
import "context"
import (
"context"
"strings"
)
type TaskCancellationHooks struct {
Register func(string, context.CancelFunc)
@@ -8,6 +11,7 @@ type TaskCancellationHooks struct {
}
type taskCancellationHooksContextKey struct{}
type taskOperatorContextKey struct{}
func WithTaskCancellationHooks(ctx context.Context, hooks TaskCancellationHooks) context.Context {
return context.WithValue(ctx, taskCancellationHooksContextKey{}, hooks)
@@ -20,3 +24,14 @@ func TaskCancellationHooksFromContext(ctx context.Context) (TaskCancellationHook
}
return hooks, true
}
// WithTaskOperator 将当前已认证操作者绑定到任务工作流上下文。
func WithTaskOperator(ctx context.Context, operatorID string) context.Context {
return context.WithValue(ctx, taskOperatorContextKey{}, strings.TrimSpace(operatorID))
}
// TaskOperatorFromContext 读取任务工作流的创建人;后台调度任务没有操作者时返回空字符串。
func TaskOperatorFromContext(ctx context.Context) string {
operatorID, _ := ctx.Value(taskOperatorContextKey{}).(string)
return strings.TrimSpace(operatorID)
}