Documentation
¶
Index ¶
- Constants
- Variables
- func Init(writer io.Writer, traceid string, machineId func() (uint16, error))
- func Transaction(f func(*xorm.Session) (interface{}, error)) (i interface{}, err error)
- type Engine
- func (e Engine) AddEvent(name string, eventType int) (*Event, error)
- func (e Engine) AddGroup(admin uint64, name string) (*Group, error)
- func (e Engine) AddGroupUser(gid, uid uint64) error
- func (e Engine) AddKind(name string) (*Kind, error)
- func (e Engine) AddMessage(nid uint64, subject, content string) error
- func (e Engine) AddNode(pid uint64, name string, nodeType int, eids []uint64) (*Node, error)
- func (e Engine) AddNodeEvent(nid, eid uint64) error
- func (e Engine) AddProcess(kindId uint64, name string) (*Process, error)
- func (e Engine) AddTemplate(pid uint64, content []byte) (*Template, error)
- func (e Engine) AddUser(name string, email string) (*User, error)
- func (e Engine) ApplyNode(recordId uint64) error
- func (e Engine) ChangeEmail(id uint64, email string) error
- func (e Engine) ChangeNodeUser(recordId, uid uint64) error
- func (e Engine) DelKind(id uint64) error
- func (e Engine) DelKindSafe(id uint64) error
- func (e Engine) DelKindUnSafe(id uint64) error
- func (e Engine) DelNode(id uint64) error
- func (e Engine) DeleteProcess(id uint64) error
- func (e Engine) DisableMessage(nid uint64) error
- func (e Engine) DisableProcess(id uint64) error
- func (e Engine) EnableMessage(nid uint64) error
- func (e Engine) EnableProcess(id uint64) error
- func (e Engine) GetAllProcess() []Process
- func (e Engine) GetKind(id uint64, name string) (*Kind, error)
- func (e Engine) GetNodeMessage(nid uint64) (*Message, error)
- func (e Engine) GetProcess(id uint64, name string) (*Process, error)
- func (e Engine) GetTemplate(pid uint64) (*Template, error)
- func (e Engine) ListEvent() ([]Event, error)
- func (e Engine) ListGroup(id uint64, name string) ([]Group, error)
- func (e Engine) ListGroupUser(gid, uid uint64, username string) ([]GroupUser, error)
- func (e Engine) ListKind() ([]Kind, error)
- func (e Engine) ListKindProcess(kid uint64) ([]Process, error)
- func (e Engine) ListRecord(uid, nid uint64, actuallyNo string) ([]Record, error)
- func (e *Engine) RegisterEvent(events []Event)
- func (e *Engine) RegisterMailBox(mailBox MailBox)
- func (e Engine) RemoveEvent(id uint64) error
- func (e Engine) RemoveGroup(id uint64) error
- func (e Engine) RemoveGroupUser(gid, uid uint64) error
- func (e Engine) RemoveNodeEvent(nid, eid uint64) error
- func (e Engine) RenameKind(id uint64, name string) error
- func (e Engine) RenameNode(id uint64, name string) error
- func (e Engine) RenameProcess(id uint64, name string) error
- func (e Engine) RenameUser(id uint64, name string) error
- func (e Engine) TouchNode(uid, nid uint64, actuallyNo string) error
- type Event
- type EventFunc
- type Group
- type GroupUser
- type Kind
- type MailBox
- type Message
- type Node
- type NodeEvent
- type Process
- type Record
- type Template
- type User
Constants ¶
const ( PRE_EVENT = iota + 1 AFTER_EVENT APPLY_EVENT )
Event type表示一个动作类别 它包含三个类别,节点触发前,节点触发后,节点实际执行后
const ( BeginNode = iota + 1 NormalNode SplitNode BranchNode InterNode EndNode )
node type 是关于节点类型的描述 通常一个节点可以被表示为以下类型: 开始节点,普通节点,分流节点,分支节点,合流节点,结束节点
Variables ¶
var CAN_NOT_DELETE = errors.New("含有关联数据,无法删除")
var DELETE_FAIL = errors.New("删除失败")
var INSERT_FAIL = errors.New("插入失败")
var PARAM_NULL = errors.New("参数为空")
var SELECT_NULL = errors.New("查询失败")
var TRANSACTION_BEGIN_ERR = errors.New("事务开启失败")
var UPDATE_FAIL = errors.New("更新失败")
Functions ¶
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
工作流引擎 它并不存储任何信息,但是所有对流程的操作都通过它实现
func (Engine) AddMessage ¶
添加消息提醒内容
func (Engine) AddProcess ¶
添加流程,默认启用 kindId 为0时,表示不属于任何模块
func (Engine) AddTemplate ¶
新增模板
func (Engine) ChangeNodeUser ¶
更换节点执行人 开始节点无法更换执行人
func (Engine) DelKindSafe ¶
删除模块 若模块下含有流程,此方法将把所有流程对应模块置空
func (Engine) DelKindUnSafe ¶
删除模块 若模块下含有流程,此方法将把模块下流程全部删除
func (Engine) GetNodeMessage ¶
获取节点消息提醒内容
func (Engine) GetProcess ¶
通过id或者name查询指定流程
func (Engine) ListGroupUser ¶
查询分组中的成员 可以按uid精确查询,或使用成员名称模糊查询 查询条件为空时查询全部
func (Engine) ListKindProcess ¶
查询指定模块下流程
func (Engine) ListRecord ¶
查询节点执行记录 以uid,nid精确查询,以actuallyNo模糊查询
type Event ¶
type Event struct { Id uint64 `xorm:"pk" json:"id"` Name string `xorm:"varchar(36) not null unique index comment('名称')" json:"name"` EventType int `xorm:"TINYINT(1) not null comment('事件类别')" json:"eventType"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` Func EventFunc `xorm:"-"` }
Event 用于描述工作流中节点的相关动作
type Group ¶
type Group struct { Id uint64 `xorm:"pk" json:"id"` Name string `xorm:"varchar(36) not null unique index comment('组别名称')" json:"name"` Active bool `xorm:"not null default 1 comment('激活状态:0-未激活,1-激活')" json:"active"` Admin uint64 `xorm:"not null comment('管理员')"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` }
group是对用户的简单分组,它可以被描述为一个组织,也可以描述成一个团体 需要注意的是,它只是一个简单的分组,并不能够用来描述组与组之间的关系 同样的,一个用户也可以同时属于多个组别
type GroupUser ¶
type GroupUser struct { Id uint64 `xorm:"pk" json:"id"` Gid uint64 `xorm:"not null comment('分组ID')" json:"gid"` Uid uint64 `xorm:"not null comment('用户ID')" json:"uid"` Username string `xorm:"varchar(36) not null index comment('用户名称')" json:"username"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` }
type Kind ¶
type Kind struct { Id uint64 `xorm:"pk" json:"id"` Name string `xorm:"varchar(36) index not null unique comment('模块名称')" json:"name"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` }
kind 用于给流程区分模块
func (*Kind) BeforeInsert ¶
func (m *Kind) BeforeInsert()
type Message ¶
type Message struct { Id uint64 `xorm:"pk" json:"id"` Nid uint64 `xorm:"unique comment('节点ID')" json:"nid"` Subject string `xorm:"varchar(100) not null comment('主题')" json:"subject"` Content string `xorm:"varchar(500) comment('提醒内容')" json:"content"` Active bool `xorm:"TINYINT(1) default 1 comment('启用状态')" json:"active"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` }
message是节点被触发时的提醒设置 框架默认实现了邮件提醒的方式,当然使用者可以通过event扩展注册另外的提醒方式
type Node ¶
type Node struct { Id uint64 `xorm:"pk" json:"id"` Pid uint64 `xorm:"index comment('节点所属流程ID')" json:"pid"` Name string `xorm:"varchar(36) not null unique index comment('节点名称')" json:"name"` NodeType int `xorm:"TINYINT(1) not null comment('节点类型')" json:"nodeType"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` }
node用于描述一个工作流的节点信息 它包括一个工作流节点的基本信息,以及相应的动作 框架并不提供节点的信息查询,事实上,节点的信息应该被保存在模板中,使用者应该解析自定义的模板并从中获取节点条件和节点信息
type NodeEvent ¶
type NodeEvent struct { Id uint64 `xorm:"pk" json:"id"` Nid uint64 `xorm:"not null comment('节点ID')" json:"nid"` Eid uint64 `xorm:"not null comment('事件ID')" json:"eid"` EventType int `xorm:"TINYINT(1) not null comment('事件类别')" json:"eventType"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` }
节点启用动作
type Process ¶
type Process struct { Id uint64 `xorm:"pk" json:"id"` KindId uint64 `xorm:"index comment('流程所属模块')" json:"kindId"` Name string `xorm:"varchar(36) not null unique index comment('流程名称')" json:"name"` Active bool `xorm:"not null default 1 comment('激活状态:0-未激活,1-激活')" json:"active"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` DeletedAt time.Time `xorm:"deleted comment('删除时间')" json:"deletedAt"` }
流程信息应该被描述为单个的文档 默认情况下,流程的结构被定义为一个图,依赖于他的节点信息
func (*Process) BeforeInsert ¶
func (m *Process) BeforeInsert()
type Record ¶
type Record struct { Id uint64 `xorm:"pk" json:"id"` Nid uint64 `xorm:"not null comment('节点ID')" json:"nid"` Uid uint64 `xorm:"not null comment('节点处理用户ID')" json:"nid"` PreUid uint64 `xorm:"comment('节点原所属用户ID')" json:"preUid"` ActuallyNo string `xorm:"varchar(50) not null comment('流程实际执行编号')" json:"actuallyNo"` Status bool `xorm:"TINYINT(1) not null default 0 comment('执行状态:0-未执行,1已执行')"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` }
工作流实际执行节点记录
type Template ¶
type Template struct { Id uint64 `xorm:"pk" json:"id"` Pid uint64 `xorm:"index not null unique('version') comment('流程ID')" json:"pid"` Version int `xorm:"default 1 not null unique('version') comment('版本号')" json:"version"` Content []byte `xorm:"not null comment('模板内容')" json:"content"` Active bool `xorm:"not null default 1 comment('激活状态:0-未激活,1-激活')" json:"active"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` DeletedAt time.Time `xorm:"deleted comment('删除时间')" json:"deletedAt"` }
流程模板被用来表示工作流的内容 框架并不关心模板在实际使用时的数据类型和节点内容 它的拓扑结构必须是完整的图,包含节点的信息和节点走向以及判断条件 它还可以定义针对节点的一系列动作
func (*Template) BeforeInsert ¶
func (m *Template) BeforeInsert()
type User ¶
type User struct { Id uint64 `xorm:"pk" json:"id"` Name string `xorm:"varchar(36) not null index comment('用户名称')" json:"name"` Email string `xorm:"varchar(50) not null unique comment('邮箱')" json:"email"` CreatedAt time.Time `xorm:"created comment('创建时间')" json:"createdAt"` UpdatedAt time.Time `xorm:"updated comment('更新时间')" json:"updatedAt"` DeletedAt time.Time `xorm:"deleted comment('删除时间')" json:"deletedAt"` }
user是工作流中用于表示实际流程流转的具体用户 它并不用于存储一个用户的详细信息 使用时每个用户必须拥有一个唯一标识,在这里我们使用邮箱作为条件