model

package
v1.8.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

管理扩展领域对象(v1.1.0)——流程设计 / 设计历史 / 委托代理

DDD 聚合根行为——对标 Java 版 domain/ProcessInstance + domain/ProcessTask

Package model 域类型定义——对标 Java 版 domain + model 包

Index

Constants

View Source
const (
	TypeStart    = "snaker:start"
	TypeEnd      = "snaker:end"
	TypeTask     = "snaker:task"
	TypeDecision = "snaker:decision"
	TypeFork     = "snaker:fork"
	TypeJoin     = "snaker:join"
	TypeCustom   = "snaker:custom"
)
View Source
const BusinessNoKey = "BUSINESS_NO"

业务号变量 key(engine 包 KeyBusinessNo 同值)

Variables

This section is empty.

Functions

This section is empty.

Types

type CcInstanceRow added in v1.3.0

type CcInstanceRow struct {
	ID                int64
	ParentID          *int64
	DefineID          int64
	State             InstanceState
	ParentNodeName    string
	BusinessNo        string
	Operator          string
	ExpireTime        *time.Time
	Variables         map[string]interface{}
	CreateTime        time.Time
	CreateUser        string
	UpdateTime        time.Time
	UpdateUser        string
	DefineName        string
	DefineDisplayName string
	DefineVersion     int
}

CcInstanceRow 抄送实例行数据(ccList 分页,v1.3.0,对齐 Java InstanceRow 字段)

type CountersignType added in v1.4.0

type CountersignType int

CountersignType 会签类型(wf_countersign_type)

const (
	CountersignTypeParallel   CountersignType = 0
	CountersignTypeSequential CountersignType = 1
)

type DefineRow added in v1.5.0

type DefineRow struct {
	ID          int64     `json:"id"`
	Name        string    `json:"name"`
	DisplayName string    `json:"displayName"`
	Type        string    `json:"type"`
	State       int       `json:"state"`
	Version     int       `json:"version"`
	CreateTime  time.Time `json:"createTime"`
	CreateUser  string    `json:"createUser"`
	UpdateTime  time.Time `json:"updateTime"`
	UpdateUser  string    `json:"updateUser"`
}

DefineRow 流程定义行数据(pageDefines 分页)

type DefineState added in v1.4.0

type DefineState int

DefineState 流程定义状态(wf_process_define_state)

const (
	DefineStateDisable DefineState = 0
	DefineStateEnable  DefineState = 1
)

type FlowEdge

type FlowEdge struct {
	ID           string                 `json:"id"`
	SourceNodeID string                 `json:"sourceNodeId"`
	TargetNodeID string                 `json:"targetNodeId"`
	Properties   map[string]interface{} `json:"properties"`
	Text         *struct {
		Value string `json:"value"`
	} `json:"text,omitempty"`
}

type FlowModel

type FlowModel struct {
	Name        string     `json:"name"`
	DisplayName string     `json:"displayName"`
	Type        string     `json:"type"`
	Nodes       []FlowNode `json:"nodes"`
	Edges       []FlowEdge `json:"edges"`
}

type FlowNode

type FlowNode struct {
	ID         string                 `json:"id"`
	Type       string                 `json:"type"`
	X          float64                `json:"x"`
	Y          float64                `json:"y"`
	Properties map[string]interface{} `json:"properties"`
	Text       struct {
		Value string `json:"value"`
	} `json:"text"`
}

type InstanceRow added in v1.5.0

type InstanceRow struct {
	ID                int64                  `json:"id"`
	ParentID          *int64                 `json:"parentId"`
	DefineID          int64                  `json:"processDefineId"`
	State             InstanceState          `json:"state"`
	ParentNodeName    string                 `json:"parentNodeName"`
	BusinessNo        string                 `json:"businessNo"`
	Operator          string                 `json:"operator"`
	ExpireTime        *time.Time             `json:"expireTime"`
	Variables         map[string]interface{} `json:"variables"`
	CreateTime        time.Time              `json:"createTime"`
	CreateUser        string                 `json:"createUser"`
	UpdateTime        time.Time              `json:"updateTime"`
	UpdateUser        string                 `json:"updateUser"`
	DefineName        string                 `json:"defineName"`
	DefineDisplayName string                 `json:"defineDisplayName"`
	DefineVersion     int                    `json:"defineVersion"`
}

InstanceRow 流程实例行数据(pageInstances 分页)

type InstanceState

type InstanceState int
const (
	InstanceStateDoing     InstanceState = 10
	InstanceStateDone      InstanceState = 20
	InstanceStateWithdraw  InstanceState = 30
	InstanceStateInterrupt InstanceState = 40
	InstanceStateReject    InstanceState = 45
	InstanceStatePending   InstanceState = 50
	InstanceStateAbandon   InstanceState = 99
)

type PerformType added in v1.4.0

type PerformType int

PerformType 任务参与方式(wf_process_task_perform_type)

const (
	PerformTypeNormal      PerformType = 0
	PerformTypeCountersign PerformType = 1
)

type ProcessDefine

type ProcessDefine struct {
	ID          int64
	Name        string
	DisplayName string
	Type        string
	State       int
	Content     []byte
	Version     int
	CreateTime  time.Time
	CreateUser  string
	UpdateTime  time.Time
	UpdateUser  string
}

type ProcessDesign added in v1.1.0

type ProcessDesign struct {
	ID          int64     `json:"id"`
	Name        string    `json:"name"`
	DisplayName string    `json:"displayName"`
	Type        string    `json:"type"`
	Icon        string    `json:"icon"`
	IsDeployed  int       `json:"isDeployed"`
	Remark      string    `json:"remark"`
	CreateTime  time.Time `json:"createTime"`
	CreateUser  string    `json:"createUser"`
	UpdateTime  time.Time `json:"updateTime"`
	UpdateUser  string    `json:"updateUser"`
}

ProcessDesign 流程设计(wf_process_design)——设计器保存的设计稿元信息

type ProcessDesignHis added in v1.1.0

type ProcessDesignHis struct {
	ID              int64     `json:"id"`
	ProcessDesignID int64     `json:"processDesignId"`
	Content         []byte    `json:"content"`
	CreateTime      time.Time `json:"createTime"`
	CreateUser      string    `json:"createUser"`
}

ProcessDesignHis 流程设计历史(wf_process_design_his)——每次保存的 content 快照

type ProcessInstance

type ProcessInstance struct {
	ID             int64
	ParentID       *int64
	DefineID       int64
	State          InstanceState
	ParentNodeName string
	BusinessNo     string
	Operator       string
	ExpireTime     *time.Time
	Variables      map[string]interface{}
	Tasks          []*ProcessTask
	CreateTime     time.Time
	CreateUser     string
	UpdateTime     time.Time
	UpdateUser     string
}

func NewProcessInstance

func NewProcessInstance(id, defineID int64, operator string, vars map[string]interface{}, now time.Time) *ProcessInstance

NewProcessInstance 工厂方法——创建流程实例

func (*ProcessInstance) AbandonAllDoing

func (p *ProcessInstance) AbandonAllDoing(now time.Time) []*ProcessTask

AbandonAllDoing 废弃所有进行中任务,返回被废弃的任务列表(供调用方持久化)

func (*ProcessInstance) AbandonTask

func (p *ProcessInstance) AbandonTask(task *ProcessTask, now time.Time)

AbandonTask 废弃单个任务

func (*ProcessInstance) AddVariable

func (p *ProcessInstance) AddVariable(vars map[string]interface{})

AddVariable 追加变量

func (*ProcessInstance) CompleteTask

func (p *ProcessInstance) CompleteTask(task *ProcessTask, operator string, vars map[string]interface{}, now time.Time)

CompleteTask 完成任务(子实体状态转换 + 实例变量合并)

func (*ProcessInstance) CreateTask

func (p *ProcessInstance) CreateTask(id int64, taskName, displayName, actor, operator, formKey string, now time.Time, performType ...int) *ProcessTask

CreateTask 创建任务(子实体工厂)——performType:0 普通 / 1 会签(issues/52 E24 落库对齐 Java)

func (*ProcessInstance) Finish

func (p *ProcessInstance) Finish(now time.Time)

Finish 流程完成

func (*ProcessInstance) GetDoingTasks

func (p *ProcessInstance) GetDoingTasks() []*ProcessTask

GetDoingTasks 获取进行中任务

func (*ProcessInstance) GetDoneTasks

func (p *ProcessInstance) GetDoneTasks() []*ProcessTask

GetDoneTasks 获取已完成任务

func (*ProcessInstance) IsAllTasksFinished

func (p *ProcessInstance) IsAllTasksFinished() bool

IsAllTasksFinished 所有任务是否都已完成(用于 join 合并判断)

func (*ProcessInstance) Reject

func (p *ProcessInstance) Reject(now time.Time)

Reject 驳回流程

func (*ProcessInstance) Withdraw added in v1.8.11

func (p *ProcessInstance) Withdraw(now time.Time)

Withdraw 撤回流程(issues/53 E25:withdraw 用 Withdraw(30),与 reject 区分)

type ProcessSurrogate added in v1.1.0

type ProcessSurrogate struct {
	ID          int64      `json:"id"`
	ProcessName string     `json:"processName"`
	Operator    string     `json:"operator"`
	Surrogate   string     `json:"surrogate"`
	StartTime   *time.Time `json:"startTime"`
	EndTime     *time.Time `json:"endTime"`
	Enabled     int        `json:"enabled"`
	CreateTime  time.Time  `json:"createTime"`
	CreateUser  string     `json:"createUser"`
	UpdateTime  time.Time  `json:"updateTime"`
	UpdateUser  string     `json:"updateUser"`
}

ProcessSurrogate 流程委托代理(wf_process_surrogate)——授权人把待办委托给代理人

type ProcessTask

type ProcessTask struct {
	ID                int64
	ProcessInstanceID int64
	TaskName          string
	DisplayName       string
	TaskType          int
	PerformType       int
	TaskState         TaskState
	ActorID           string
	ActorIDs          []string
	FinishTime        *time.Time
	ExpireTime        *time.Time
	FormKey           string
	ParentTaskID      *int64
	Variables         map[string]interface{}
	CreateTime        time.Time
	CreateUser        string
	UpdateTime        time.Time
	UpdateUser        string
}

func (*ProcessTask) Abandon

func (t *ProcessTask) Abandon(now time.Time)

Abandon 废弃任务

func (*ProcessTask) Finish

func (t *ProcessTask) Finish(operator string, vars map[string]interface{}, now time.Time)

Finish 完成任务

func (*ProcessTask) IsAllowed

func (t *ProcessTask) IsAllowed(operator string) bool

IsAllowed 操作人是否有权限处理该任务

func (*ProcessTask) IsDoing

func (t *ProcessTask) IsDoing() bool

IsDoing 是否进行中

func (*ProcessTask) IsFinished

func (t *ProcessTask) IsFinished() bool

IsFinished 是否已完成

type SubmitType added in v1.4.0

type SubmitType int

SubmitType 流程提交类型(wf_process_submit_type)

const (
	SubmitTypeApply               SubmitType = 0
	SubmitTypeAgree               SubmitType = 1
	SubmitTypeReject              SubmitType = 2
	SubmitTypeRollback            SubmitType = 3
	SubmitTypeJump                SubmitType = 4
	SubmitTypeReApply             SubmitType = 5
	SubmitTypeRollbackToOperator  SubmitType = 6
	SubmitTypeCountersignDisagree SubmitType = 20
)

type TaskRow added in v1.5.0

type TaskRow struct {
	ID                       int64                  `json:"id"`
	ProcessInstanceID        int64                  `json:"processInstanceId"`
	TaskName                 string                 `json:"taskName"`
	DisplayName              string                 `json:"displayName"`
	TaskType                 int                    `json:"taskType"`
	PerformType              int                    `json:"performType"`
	TaskState                TaskState              `json:"taskState"`
	Operator                 string                 `json:"operator"`
	FinishTime               *time.Time             `json:"finishTime"`
	ExpireTime               *time.Time             `json:"expireTime"`
	FormKey                  string                 `json:"formKey"`
	TaskParentID             *int64                 `json:"taskParentId"`
	Variables                map[string]interface{} `json:"variables"`
	CreateTime               time.Time              `json:"createTime"`
	CreateUser               string                 `json:"createUser"`
	UpdateTime               time.Time              `json:"updateTime"`
	UpdateUser               string                 `json:"updateUser"`
	ProcessDefineName        string                 `json:"processDefineName"`
	ProcessDefineDisplayName string                 `json:"processDefineDisplayName"`
	DefineVersion            int                    `json:"defineVersion"`
	InstanceVariable         string                 `json:"instanceVariable"`
	InstanceCreateTime       time.Time              `json:"instanceCreateTime"`
}

TaskRow 任务行数据(pageTodoTasks / pageDoneTasks 分页)

type TaskState

type TaskState int
const (
	TaskStateDoing     TaskState = 10
	TaskStateDone      TaskState = 20
	TaskStateWithdraw  TaskState = 30
	TaskStateInterrupt TaskState = 40
	TaskStatePending   TaskState = 50
	TaskStateAbandoned TaskState = 99
)

type TaskType added in v1.4.0

type TaskType int

TaskType 任务类型(wf_process_task_type)

const (
	TaskTypeMajor     TaskType = 0
	TaskTypeSecondary TaskType = 1
	TaskTypeRecord    TaskType = 2
)

type UserInfo

type UserInfo struct {
	UserID   string
	RealName string
	DeptID   string
	DeptName string
	PostID   string
	PostName string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL