workflow

package module
v0.0.0-...-561d2ec Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 7 Imported by: 0

README

Slowflow

根据 github.com/antlinker/flow 修改

工作流设计器

获取项目

go get github.com/redshiftkeying/slowflow-server

直接使用

1.初始化工作流引擎(仅引擎)
package main
import (
    sw "github.com/redshiftkeying/slowflow-server"
    "github.com/redshiftkeying/slowflow-server/engine"
    _ "github.com/go-sql-driver/mysql"
)
func main() {
   	//use default configs
	sw.SetServerOptions("")
	// Instance
	e := sw.InitEngine()
}

配置文件样例:

# config.yml
dsn: root:123456@tcp(127.0.0.1:3306)/sflow?charset=utf8
2. 加载工作流文件
	err := e.LoadFile("leave.bpmn")
	if err != nil {
		// 处理错误
	}
3. 发起流程
  input := map[string]interface{}{
	"day": 1,
  }

	result, err := e.StartFlow("流程编号", "开始节点编号", "流程发起人ID", input)
	if err != nil {
		// 处理错误
	}
4. 查询待办流程列表
	todos, err := e.QueryTodoFlows("流程编号", "流程待办人ID")
	if err != nil {
		// 处理错误
	}
5. 处理流程
  input := map[string]interface{}{
	"action": "pass",
  }

  result, err = e.HandleFlow("待办流程节点实例ID", "流程处理人ID", input)
	if err != nil {
		// 处理错误
	}
6. 停止流程
	err := e.StopFlow("待办流程节点实例ID", func(flowInstance *schema.FlowInstance) bool {
		return flowInstance.Launcher == "XXX"
	})
	if err != nil {
		// 处理错误
	}
7. 查询流程历史数据
result,err := e.QueryFlowHistory("待办流程实例ID")
if err != nil {
	// 处理错误
}
8. 查询已办理的流程实例 ID 列表
ids,err := e.QueryDoneFlowIDs("流程编号","流程处理人ID")
if err != nil {
	// 处理错误
}
9. 查询节点实例的候选人 ID 列表
ids,err := e.QueryNodeCandidates("待办流程节点实例ID")
if err != nil {
	// 处理错误
}
10. 停止流程实例
	err := e.StopFlowInstance("待办流程节点实例ID", func(flowInstance *schema.FlowInstance) bool {
		return flowInstance.Launcher == "XXX"
	})
	if err != nil {
		// 处理错误
	}

使用接口

1. 初始化工作流引擎
默认配置
package main
import (
    sw "github.com/redshiftkeying/slowflow-server"
    _ "github.com/go-sql-driver/mysql"
)
func main() {
   	//use default configs
	sw.SetServerOptions("")
	// Instance
	s := sw.Init()
	// add Middleware
	s.AddServerMiddleware(filter)
	// start server
    s.StartServer()
}
func filter(c *gin.Context) {
	fmt.Printf("请求参数:%s \n", c.FullPath())
	c.Next()
}
使用配置文件
package main
import (
    sw "github.com/redshiftkeying/slowflow-server/"
    _ "github.com/go-sql-driver/mysql"
)
func main() {
   	//use default configs
	sw.SetServerOptions("./config.yml")
	// Instance
	s := sw.Init()
	// add Middleware
	s.AddServerMiddleware(filter)
	// start server
    s.StartServer()
}

配置文件样例:

# config.yml
dsn: root:123456@tcp(127.0.0.1:3306)/sflow?charset=utf8
mode: debug
staticroot: ./build
staticPath: /
port: 6062

TODO 列表

  • 移除 ionic
  • 使用 GIN 代替 gear 框架
  • 微服务改造
  • 移除 qlang 的部分
  • 增加对 DMN 的支持
  • 接入 ORM 支持多种数据库
  • 支持子流程
  • 重构并完善客户端
  • 新增 APP 客户端
  • 增加丰富的例子
  • 完善 BPMN2.0 的支持和实现
  • 打包 Docker

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitEngine

func InitEngine() *engine.Engine

InitEngine 仅初始化引擎,提供代码调用

func SetServerOptions

func SetServerOptions(configsPath string)

SetServerOptions 读取配置文件

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server 流程管理服务

func Init

func Init() *Server

Init 初始化服务,提供接口调用

func (*Server) AddServerMiddleware

func (a *Server) AddServerMiddleware(middlewares ...gin.HandlerFunc)

AddServerMiddleware 中间件

func (*Server) StartServer

func (a *Server) StartServer()

StartServer 启动管理服务

Jump to

Keyboard shortcuts

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