Documentation
¶
Index ¶
- Constants
- Variables
- func CollectUniqueCCUserIDs(configs []approval.FlowNodeCC, formData approval.FormData, ...) ([]string, error)
- func ComputeTaskDeadline(timeoutHours int) *timex.DateTime
- func InsertAutoCCRecords(ctx context.Context, db orm.DB, instanceID, nodeID string, userIDs []string, ...) ([]string, error)
- func InsertCCRecords(ctx context.Context, db orm.DB, instanceID string, nodeID *string, ...) ([]string, error)
- func InsertManualCCRecords(ctx context.Context, db orm.DB, instanceID, nodeID string, userIDs []string, ...) ([]string, error)
- func NormalizeUniqueIDs(ids []string) []string
- func ResolveCCUserIDs(cfg approval.FlowNodeCC, formData approval.FormData) ([]string, error)
- func ResolveUserName(ctx context.Context, resolver approval.UserInfoResolver, userID string) string
- func ResolveUserNameMap(ctx context.Context, resolver approval.UserInfoResolver, ids []string) (map[string]string, error)
- func ResolveUserNameMapSilent(ctx context.Context, resolver approval.UserInfoResolver, ids []string) map[string]string
- type CCConfigSelector
- type CCUserResolver
- type CreateFlowInitiatorCmd
- type FlowGraph
- type InstanceDetail
- type OrderedUnique
Constants ¶
const ( ErrCodeFlowNotFound = 40001 ErrCodeFlowNotActive = 40002 ErrCodeNoPublishedVersion = 40003 ErrCodeVersionNotDraft = 40004 ErrCodeInvalidFlowDesign = 40005 ErrCodeFlowCodeExists = 40006 ErrCodeVersionNotFound = 40007 ErrCodeInstanceNotFound = 40101 ErrCodeInstanceCompleted = 40102 ErrCodeNotAllowedInitiate = 40103 ErrCodeWithdrawNotAllowed = 40104 ErrCodeResubmitNotAllowed = 40105 ErrCodeTaskNotFound = 40201 ErrCodeTaskNotPending = 40202 ErrCodeNotAssignee = 40203 ErrCodeInvalidTaskTransition = 40204 ErrCodeRollbackNotAllowed = 40205 ErrCodeAddAssigneeNotAllowed = 40206 ErrCodeTransferNotAllowed = 40207 ErrCodeOpinionRequired = 40208 ErrCodeManualCcNotAllowed = 40209 ErrCodeRemoveAssigneeNotAllowed = 40210 ErrCodeInvalidAddAssigneeType = 40211 ErrCodeNotApplicant = 40212 ErrCodeInvalidRollbackTarget = 40213 ErrCodeLastAssigneeRemoval = 40214 ErrCodeInvalidTransferTarget = 40215 ErrCodeNoAssignee = 40301 ErrCodeAssigneeResolveFailed = 40302 ErrCodeFormValidationFailed = 40401 ErrCodeFieldNotEditable = 40402 ErrCodeDelegationNotFound = 40501 ErrCodeDelegationConflict = 40502 ErrCodeUrgeCooldown = 40601 ErrCodeAccessDenied = 40701 ErrCodeInstanceNotRunning = 40702 )
Error codes for the approval module (40xxx range).
Variables ¶
var ( ErrFlowNotFound = result.Err("流程不存在", result.WithCode(ErrCodeFlowNotFound)) ErrFlowNotActive = result.Err("流程未激活", result.WithCode(ErrCodeFlowNotActive)) ErrNoPublishedVersion = result.Err("无已发布版本", result.WithCode(ErrCodeNoPublishedVersion)) ErrVersionNotDraft = result.Err("版本非草稿状态", result.WithCode(ErrCodeVersionNotDraft)) ErrInvalidFlowDesign = result.Err("流程设计无效", result.WithCode(ErrCodeInvalidFlowDesign)) ErrFlowCodeExists = result.Err("流程编码已存在", result.WithCode(ErrCodeFlowCodeExists)) ErrVersionNotFound = result.Err("流程版本不存在", result.WithCode(ErrCodeVersionNotFound)) ErrInstanceNotFound = result.Err("审批实例不存在", result.WithCode(ErrCodeInstanceNotFound)) ErrInstanceCompleted = result.Err("审批实例已结束", result.WithCode(ErrCodeInstanceCompleted)) ErrNotAllowedInitiate = result.Err("无权发起此流程", result.WithCode(ErrCodeNotAllowedInitiate)) ErrWithdrawNotAllowed = result.Err("当前状态不允许撤回", result.WithCode(ErrCodeWithdrawNotAllowed)) ErrResubmitNotAllowed = result.Err("当前状态不允许重新提交", result.WithCode(ErrCodeResubmitNotAllowed)) ErrTaskNotFound = result.Err("任务不存在", result.WithCode(ErrCodeTaskNotFound)) ErrTaskNotPending = result.Err("任务非待处理状态", result.WithCode(ErrCodeTaskNotPending)) ErrNotAssignee = result.Err("非任务审批人", result.WithCode(ErrCodeNotAssignee)) ErrInvalidTaskTransition = result.Err("非法的任务状态转换", result.WithCode(ErrCodeInvalidTaskTransition)) ErrRollbackNotAllowed = result.Err("当前节点不允许回退", result.WithCode(ErrCodeRollbackNotAllowed)) ErrAddAssigneeNotAllowed = result.Err("当前节点不允许加签", result.WithCode(ErrCodeAddAssigneeNotAllowed)) ErrTransferNotAllowed = result.Err("当前节点不允许转交", result.WithCode(ErrCodeTransferNotAllowed)) ErrOpinionRequired = result.Err("审批意见必填", result.WithCode(ErrCodeOpinionRequired)) ErrManualCcNotAllowed = result.Err("当前节点不允许手动抄送", result.WithCode(ErrCodeManualCcNotAllowed)) ErrRemoveAssigneeNotAllowed = result.Err("当前节点不允许减签", result.WithCode(ErrCodeRemoveAssigneeNotAllowed)) ErrInvalidAddAssigneeType = result.Err("非法的加签类型", result.WithCode(ErrCodeInvalidAddAssigneeType)) ErrNotApplicant = result.Err("非审批发起人,无权操作", result.WithCode(ErrCodeNotApplicant)) ErrInvalidRollbackTarget = result.Err("非法的回退目标节点", result.WithCode(ErrCodeInvalidRollbackTarget)) ErrLastAssigneeRemoval = result.Err("无法移除最后一个有效审批人", result.WithCode(ErrCodeLastAssigneeRemoval)) ErrInvalidTransferTarget = result.Err("非法的转交目标审批人", result.WithCode(ErrCodeInvalidTransferTarget)) ErrNoAssignee = result.Err("无可用审批人", result.WithCode(ErrCodeNoAssignee)) ErrAssigneeResolveFailed = result.Err("解析审批人失败", result.WithCode(ErrCodeAssigneeResolveFailed)) ErrFormValidationFailed = result.Err("表单验证失败", result.WithCode(ErrCodeFormValidationFailed)) ErrFieldNotEditable = result.Err("字段不可编辑", result.WithCode(ErrCodeFieldNotEditable)) ErrDelegationNotFound = result.Err("委托记录不存在", result.WithCode(ErrCodeDelegationNotFound)) ErrDelegationConflict = result.Err("委托时间段冲突", result.WithCode(ErrCodeDelegationConflict)) ErrUrgeCooldown = result.Err("催办冷却中,请稍后再试", result.WithCode(ErrCodeUrgeCooldown)) ErrAccessDenied = result.Err("无权访问此审批实例", result.WithCode(ErrCodeAccessDenied)) ErrInstanceNotRunning = result.Err("实例非运行状态,无法操作", result.WithCode(ErrCodeInstanceNotRunning)) )
Error definitions.
Functions ¶
func CollectUniqueCCUserIDs ¶
func CollectUniqueCCUserIDs( configs []approval.FlowNodeCC, formData approval.FormData, resolver CCUserResolver, selector CCConfigSelector, ) ([]string, error)
CollectUniqueCCUserIDs resolves and deduplicates CC user IDs while preserving first-seen order.
func ComputeTaskDeadline ¶
ComputeTaskDeadline calculates a task deadline from timeout hours. Returns nil when timeout is disabled.
func InsertAutoCCRecords ¶
func InsertAutoCCRecords(ctx context.Context, db orm.DB, instanceID, nodeID string, userIDs []string, userNames map[string]string) ([]string, error)
InsertAutoCCRecords inserts non-manual CC records and returns newly inserted IDs.
func InsertCCRecords ¶
func InsertCCRecords( ctx context.Context, db orm.DB, instanceID string, nodeID *string, userIDs []string, userNames map[string]string, isManual bool, ) ([]string, error)
InsertCCRecords inserts CC records for the given users and returns only the newly inserted user IDs (existing records are ignored).
Callers must hold an instance-level FOR UPDATE lock to prevent concurrent inserts from racing on the existence check.
func InsertManualCCRecords ¶
func InsertManualCCRecords(ctx context.Context, db orm.DB, instanceID, nodeID string, userIDs []string, userNames map[string]string) ([]string, error)
InsertManualCCRecords inserts manual CC records and returns newly inserted IDs.
func NormalizeUniqueIDs ¶
NormalizeUniqueIDs trims, deduplicates, and filters empty IDs while preserving first-seen order.
func ResolveCCUserIDs ¶
ResolveCCUserIDs resolves CC recipients from static IDs or form-field values. CCRole and CCDept kinds require external user resolution and are not supported here.
func ResolveUserName ¶
ResolveUserName resolves a single user ID to a display name. Returns empty string on failure (best-effort for display-only fields).
func ResolveUserNameMap ¶
func ResolveUserNameMap(ctx context.Context, resolver approval.UserInfoResolver, ids []string) (map[string]string, error)
ResolveUserNameMap batch-resolves user IDs to a map of ID→Name. Returns an error if the resolver fails.
func ResolveUserNameMapSilent ¶
func ResolveUserNameMapSilent(ctx context.Context, resolver approval.UserInfoResolver, ids []string) map[string]string
ResolveUserNameMapSilent batch-resolves user IDs to a map of ID→Name. Silently returns an empty map on resolver failure (best-effort for display-only fields).
Types ¶
type CCConfigSelector ¶
type CCConfigSelector func(cfg approval.FlowNodeCC) bool
CCConfigSelector decides whether a FlowNodeCC config should be included.
type CCUserResolver ¶
CCUserResolver resolves CC user IDs from a single FlowNodeCC configuration.
type CreateFlowInitiatorCmd ¶
type CreateFlowInitiatorCmd struct {
Kind approval.InitiatorKind
IDs []string
}
CreateFlowInitiatorCmd contains the parameters for creating a flow initiator.
type FlowGraph ¶
type FlowGraph struct {
Flow *approval.Flow `json:"flow"`
Version *approval.FlowVersion `json:"version"`
Nodes []approval.FlowNode `json:"nodes"`
Edges []approval.FlowEdge `json:"edges"`
}
FlowGraph contains the complete flow graph for a version.
type InstanceDetail ¶
type InstanceDetail struct {
Instance approval.Instance `json:"instance"`
Tasks []approval.Task `json:"tasks"`
ActionLogs []approval.ActionLog `json:"actionLogs"`
FlowNodes []approval.FlowNode `json:"flowNodes"`
}
InstanceDetail contains the full details of an instance.
type OrderedUnique ¶
type OrderedUnique[T comparable] struct { // contains filtered or unexported fields }
OrderedUnique stores unique values while preserving first-seen order.
func NewOrderedUnique ¶
func NewOrderedUnique[T comparable](capacity int) *OrderedUnique[T]
NewOrderedUnique creates an ordered-unique container with optional capacity.
func (*OrderedUnique[T]) Add ¶
func (o *OrderedUnique[T]) Add(value T) bool
Add inserts value only if it does not already exist, preserving insertion order.
func (*OrderedUnique[T]) AddAll ¶
func (o *OrderedUnique[T]) AddAll(values ...T) int
AddAll inserts multiple values and returns how many were newly added.
func (*OrderedUnique[T]) Contains ¶
func (o *OrderedUnique[T]) Contains(value T) bool
Contains reports whether value already exists in the set.
func (*OrderedUnique[T]) Len ¶
func (o *OrderedUnique[T]) Len() int
Len returns the number of unique values.
func (*OrderedUnique[T]) ToSlice ¶
func (o *OrderedUnique[T]) ToSlice() []T
ToSlice returns a copy of ordered unique values.