清理工作流功能
This commit is contained in:
@@ -1,258 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gin-vue-admin/global"
|
||||
"gin-vue-admin/model"
|
||||
"gin-vue-admin/model/request"
|
||||
"gin-vue-admin/model/response"
|
||||
"gin-vue-admin/service"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 创建WorkflowProcess
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.WorkflowProcess true "创建WorkflowProcess"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /workflowProcess/createWorkflowProcess [post]
|
||||
func CreateWorkflowProcess(c *gin.Context) {
|
||||
var workflowProcess model.WorkflowProcess
|
||||
_ = c.ShouldBindJSON(&workflowProcess)
|
||||
err := service.CreateWorkflowProcess(workflowProcess)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("创建失败,%v", err), c)
|
||||
} else {
|
||||
response.OkWithMessage("创建成功", c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 删除WorkflowProcess
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.WorkflowProcess true "删除WorkflowProcess"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||
// @Router /workflowProcess/deleteWorkflowProcess [delete]
|
||||
func DeleteWorkflowProcess(c *gin.Context) {
|
||||
var workflowProcess model.WorkflowProcess
|
||||
_ = c.ShouldBindJSON(&workflowProcess)
|
||||
err := service.DeleteWorkflowProcess(workflowProcess)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
|
||||
} else {
|
||||
response.OkWithMessage("删除成功", c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 批量删除WorkflowProcess
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body request.IdsReq true "批量删除WorkflowProcess"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
|
||||
// @Router /workflowProcess/deleteWorkflowProcessByIds [delete]
|
||||
func DeleteWorkflowProcessByIds(c *gin.Context) {
|
||||
var IDS request.IdsReq
|
||||
_ = c.ShouldBindJSON(&IDS)
|
||||
err := service.DeleteWorkflowProcessByIds(IDS)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("删除失败,%v", err), c)
|
||||
} else {
|
||||
response.OkWithMessage("删除成功", c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 更新WorkflowProcess
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.WorkflowProcess true "更新WorkflowProcess"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
|
||||
// @Router /workflowProcess/updateWorkflowProcess [put]
|
||||
func UpdateWorkflowProcess(c *gin.Context) {
|
||||
var workflowProcess model.WorkflowProcess
|
||||
_ = c.ShouldBindJSON(&workflowProcess)
|
||||
err := service.UpdateWorkflowProcess(&workflowProcess)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("更新失败,%v", err), c)
|
||||
} else {
|
||||
response.OkWithMessage("更新成功", c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 用id查询WorkflowProcess
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.WorkflowProcess true "用id查询WorkflowProcess"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
// @Router /workflowProcess/findWorkflowProcess [get]
|
||||
func FindWorkflowProcess(c *gin.Context) {
|
||||
var workflowProcess model.WorkflowProcess
|
||||
_ = c.ShouldBindQuery(&workflowProcess)
|
||||
err, reworkflowProcess := service.GetWorkflowProcess(workflowProcess.ID)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
|
||||
} else {
|
||||
response.OkWithData(gin.H{"reworkflowProcess": reworkflowProcess}, c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 用id查询工作流步骤
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.WorkflowProcess true "用id查询WorkflowProcess"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
|
||||
// @Router /workflowProcess/findWorkflowStep [get]
|
||||
func FindWorkflowStep(c *gin.Context) {
|
||||
var workflowProcess model.WorkflowProcess
|
||||
_ = c.ShouldBindQuery(&workflowProcess)
|
||||
err, workflow := service.FindWorkflowStep(workflowProcess.ID)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("查询失败,%v", err), c)
|
||||
} else {
|
||||
response.OkWithData(gin.H{"workflow": workflow}, c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 分页获取WorkflowProcess列表
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body request.WorkflowProcessSearch true "分页获取WorkflowProcess列表"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /workflowProcess/getWorkflowProcessList [get]
|
||||
func GetWorkflowProcessList(c *gin.Context) {
|
||||
var pageInfo request.WorkflowProcessSearch
|
||||
_ = c.ShouldBindQuery(&pageInfo)
|
||||
err, list, total := service.GetWorkflowProcessInfoList(pageInfo)
|
||||
if err != nil {
|
||||
response.FailWithMessage(fmt.Sprintf("获取数据失败,%v", err), c)
|
||||
} else {
|
||||
response.OkWithData(response.PageResult{
|
||||
List: list,
|
||||
Total: total,
|
||||
Page: pageInfo.Page,
|
||||
PageSize: pageInfo.PageSize,
|
||||
}, c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 开启工作流
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /workflowProcess/startWorkflow [post]
|
||||
func StartWorkflow(c *gin.Context) {
|
||||
business := c.Query("businessType")
|
||||
wfInfo := model.WorkflowBusinessStruct[business]()
|
||||
c.ShouldBindJSON(wfInfo)
|
||||
err := service.StartWorkflow(wfInfo)
|
||||
if err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("启动成功", c)
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 提交工作流
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /workflowProcess/completeWorkflowMove [post]
|
||||
func CompleteWorkflowMove(c *gin.Context) {
|
||||
business := c.Query("businessType")
|
||||
wfInfo := model.WorkflowBusinessStruct[business]()
|
||||
c.ShouldBindJSON(wfInfo)
|
||||
err := service.CompleteWorkflowMove(wfInfo)
|
||||
if err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("启动成功", c)
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 我发起的工作流
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /workflowProcess/getMyStated [get]
|
||||
func GetMyStated(c *gin.Context) {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
errStr := "从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件"
|
||||
global.GVA_LOG.Error(errStr)
|
||||
response.FailWithMessage(errStr, c)
|
||||
} else {
|
||||
waitUse := claims.(*request.CustomClaims)
|
||||
err, wfms := service.GetMyStated(waitUse.ID)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
global.GVA_LOG.Error(errStr)
|
||||
response.FailWithMessage(errStr, c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(gin.H{"wfms": wfms}, c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 我的待办
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /workflowProcess/getMyNeed [get]
|
||||
func GetMyNeed(c *gin.Context) {
|
||||
if claims, exists := c.Get("claims"); !exists {
|
||||
errStr := "从Gin的Context中获取从jwt解析出来的用户ID失败, 请检查路由是否使用jwt中间件"
|
||||
global.GVA_LOG.Error(errStr)
|
||||
response.FailWithMessage(errStr, c)
|
||||
} else {
|
||||
waitUse := claims.(*request.CustomClaims)
|
||||
err, wfms := service.GetMyNeed(waitUse.ID, waitUse.AuthorityId)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
global.GVA_LOG.Error(errStr)
|
||||
response.FailWithMessage(errStr, c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(gin.H{"wfms": wfms}, c)
|
||||
}
|
||||
}
|
||||
|
||||
// @Tags WorkflowProcess
|
||||
// @Summary 根据id获取当前节点详情和历史
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body request.GetById true "根据id获取当前节点详情和过往"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /workflowProcess/getWorkflowMoveByID [get]
|
||||
func GetWorkflowMoveByID(c *gin.Context) {
|
||||
var req request.GetById
|
||||
_ = c.ShouldBindQuery(&req)
|
||||
err, move, moves, business := service.GetWorkflowMoveByID(req.Id)
|
||||
if err != nil {
|
||||
errStr := err.Error()
|
||||
global.GVA_LOG.Error(errStr)
|
||||
response.FailWithMessage(errStr, c)
|
||||
return
|
||||
}
|
||||
response.OkWithData(gin.H{"move": move, "moves": moves, "business": business}, c)
|
||||
}
|
||||
+31
-109
@@ -1,116 +1,38 @@
|
||||
# Gin-Vue-Admin Global Configuration
|
||||
|
||||
# jwt configuration
|
||||
aliyun-oss:
|
||||
access-key-id: yourAccessKeyId
|
||||
access-key-secret: yourAccessKeySecret
|
||||
bucket-name: yourBucketName
|
||||
bucket-url: yourBucketUrl
|
||||
casbin:
|
||||
model-path: ./resource/rbac_model.conf
|
||||
email:
|
||||
host: smtp.163.com
|
||||
is-ssl: true
|
||||
nickname: test
|
||||
excel:
|
||||
dir: ./resource/excel/
|
||||
jwt:
|
||||
signing-key: 'qmPlus'
|
||||
expires-time: 604800
|
||||
buffer-time: 86400
|
||||
|
||||
# zap logger configuration
|
||||
zap:
|
||||
level: 'info'
|
||||
format: 'console'
|
||||
prefix: '[GIN-VUE-ADMIN]'
|
||||
director: 'log'
|
||||
link-name: 'latest_log'
|
||||
show-line: true
|
||||
encode-level: 'LowercaseColorLevelEncoder'
|
||||
stacktrace-key: 'stacktrace'
|
||||
log-in-console: true
|
||||
|
||||
# redis configuration
|
||||
signing-key: qmPlus
|
||||
mysql:
|
||||
config: charset=utf8mb4&parseTime=True&loc=Local
|
||||
db-name: gva
|
||||
max-idle-conns: 10
|
||||
password: Aa@6447985
|
||||
path: 127.0.0.1:3306
|
||||
username: root
|
||||
qiniu:
|
||||
bucket: qm-plus-img
|
||||
secret-key: pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY
|
||||
redis:
|
||||
db: 0
|
||||
addr: '127.0.0.1:6379'
|
||||
password: ''
|
||||
|
||||
# email configuration
|
||||
email:
|
||||
to: 'xxx@qq.com'
|
||||
port: 465
|
||||
from: 'xxx@163.com'
|
||||
host: 'smtp.163.com'
|
||||
is-ssl: true
|
||||
secret: 'xxx'
|
||||
nickname: 'test'
|
||||
|
||||
# casbin configuration
|
||||
casbin:
|
||||
model-path: './resource/rbac_model.conf'
|
||||
|
||||
# system configuration
|
||||
system:
|
||||
env: 'public' # Change to "develop" to skip authentication for development mode
|
||||
addr: 8888
|
||||
db-type: 'mysql'
|
||||
oss-type: 'local' # 控制oss选择走本期还是 七牛等其他仓 自行增加其他oss仓可以在 server/utils/upload/upload.go 中 NewOss函数配置
|
||||
env: public
|
||||
use-multipoint: false
|
||||
|
||||
# captcha configuration
|
||||
captcha:
|
||||
key-long: 6
|
||||
img-width: 240
|
||||
img-height: 80
|
||||
|
||||
# mysql connect configuration
|
||||
mysql:
|
||||
path: ''
|
||||
config: ''
|
||||
db-name: ''
|
||||
username: ''
|
||||
password: ''
|
||||
max-idle-conns: 10
|
||||
max-open-conns: 100
|
||||
log-mode: false
|
||||
log-zap: ""
|
||||
|
||||
autoCode:
|
||||
root: ''
|
||||
server: '/server'
|
||||
server-api: '/api/v1'
|
||||
server-model: '/model'
|
||||
server-request: '/model/request/'
|
||||
server-router: '/router'
|
||||
server-service: '/service'
|
||||
|
||||
web: '/web/src'
|
||||
web-api: '/api'
|
||||
web-form: '/view'
|
||||
web-table: '/view'
|
||||
web-flow: '/view'
|
||||
|
||||
# local configuration
|
||||
local:
|
||||
path: 'uploads/file'
|
||||
|
||||
# qiniu configuration (请自行七牛申请对应的 公钥 私钥 bucket �?域名地址)
|
||||
qiniu:
|
||||
zone: 'ZoneHuadong'
|
||||
bucket: 'qm-plus-img'
|
||||
img-path: 'http://qmplusimg.henrongyi.top'
|
||||
use-https: false
|
||||
access-key: '25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ'
|
||||
secret-key: 'pgdbqEsf7ooZh7W3xokP833h3dZ_VecFXPDeG5JY'
|
||||
use-cdn-domains: false
|
||||
|
||||
|
||||
# aliyun oss configuration
|
||||
aliyun-oss:
|
||||
endpoint: 'yourEndpoint'
|
||||
access-key-id: 'yourAccessKeyId'
|
||||
access-key-secret: 'yourAccessKeySecret'
|
||||
bucket-name: 'yourBucketName'
|
||||
bucket-url: 'yourBucketUrl'
|
||||
|
||||
# tencent cos configuration
|
||||
tencent-cos:
|
||||
bucket: 'xxxxx-10005608'
|
||||
region: 'ap-shanghai'
|
||||
secret-id: 'xxxxxxxx'
|
||||
secret-key: 'xxxxxxxx'
|
||||
base-url: 'https://gin.vue.admin'
|
||||
path-prefix: 'gin-vue-admin'
|
||||
|
||||
# excel configuration
|
||||
excel:
|
||||
dir: './resource/excel/'
|
||||
secret-key: xxxxxxxx
|
||||
zap:
|
||||
director: log
|
||||
encode-level: LowercaseColorLevelEncoder
|
||||
format: console
|
||||
link-name: latest_log
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package constant
|
||||
|
||||
//定义clazz常量
|
||||
|
||||
const (
|
||||
USER_TASK string = "userTask" // 审批节点
|
||||
//SCRIPT_TASK string = "scriptTask" //脚本节点
|
||||
//RECEIVE_TASK string = "receiveTask"
|
||||
//MAIL_TASK string = "mailTask" //邮件节点
|
||||
//TIMER_START string = "timerStart" // 定时节点
|
||||
//MESSAGE_START string = "messageStart" // 消息节点
|
||||
EXCLUSIVE_GATEWAY string = "exclusiveGateway" // 排他网关
|
||||
INCLUSIVE_GATEWAY string = "inclusiveGateway" // 包容网关
|
||||
PARELLEL_GATEWAY string = "parallelGateway" // 并行网关
|
||||
FLOW string = "flow" // 连线
|
||||
START string = "start" // 开始节点
|
||||
END string = "end" // 结束节点
|
||||
//PROCESS string = "process" // 基础节点
|
||||
)
|
||||
@@ -17,7 +17,6 @@ func RunWindowsServer() {
|
||||
// 初始化redis服务
|
||||
initialize.Redis()
|
||||
}
|
||||
initialize.InitWkMode()
|
||||
Router := initialize.Routers()
|
||||
Router.Static("/form-generator", "./resource/page")
|
||||
|
||||
|
||||
@@ -48,13 +48,6 @@ func MysqlTables(db *gorm.DB) {
|
||||
model.ExaSimpleUploader{},
|
||||
model.ExaCustomer{},
|
||||
model.SysOperationRecord{},
|
||||
model.WorkflowProcess{},
|
||||
model.WorkflowNode{},
|
||||
model.WorkflowEdge{},
|
||||
model.WorkflowStartPoint{},
|
||||
model.WorkflowEndPoint{},
|
||||
model.WorkflowMove{},
|
||||
model.ExaWfLeave{},
|
||||
)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("register table failed", zap.Any("err", err))
|
||||
|
||||
@@ -28,7 +28,7 @@ func Routers() *gin.Engine {
|
||||
PublicGroup := Router.Group("")
|
||||
{
|
||||
router.InitBaseRouter(PublicGroup) // 注册基础功能路由 不做鉴权
|
||||
router.InitInitRouter(PublicGroup) // 自动初始化相关
|
||||
router.InitInitRouter(PublicGroup) // 自动初始化相关
|
||||
}
|
||||
PrivateGroup := Router.Group("")
|
||||
PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
|
||||
@@ -48,7 +48,6 @@ func Routers() *gin.Engine {
|
||||
router.InitSysOperationRecordRouter(PrivateGroup) // 操作记录
|
||||
router.InitSysDictionaryDetailRouter(PrivateGroup) // 字典详情管理
|
||||
router.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
|
||||
router.InitWorkflowProcessRouter(PrivateGroup) // 工作流相关接口
|
||||
router.InitExcelRouter(PrivateGroup) // 表格导入导出
|
||||
}
|
||||
global.GVA_LOG.Info("router register success")
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package initialize
|
||||
|
||||
import "gin-vue-admin/model"
|
||||
|
||||
func initWorkflowModel() {
|
||||
model.WorkflowBusinessStruct = make(map[string]func() model.GVA_Workflow)
|
||||
model.WorkflowBusinessStruct["leave"] = func() model.GVA_Workflow {
|
||||
return new(model.ExaWfLeaveWorkflow)
|
||||
}
|
||||
}
|
||||
|
||||
func initWorkflowTable() {
|
||||
model.WorkflowBusinessTable = make(map[string]func() interface{})
|
||||
model.WorkflowBusinessTable["leave"] = func() interface{} {
|
||||
return new(model.ExaWfLeave)
|
||||
}
|
||||
}
|
||||
|
||||
func InitWkMode() {
|
||||
initWorkflowModel()
|
||||
initWorkflowTable()
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// 自动生成模板ExaWfLeave
|
||||
package model
|
||||
|
||||
import (
|
||||
"gin-vue-admin/global"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 如果含有time.Time 请自行import time包
|
||||
type ExaWfLeave struct {
|
||||
global.GVA_MODEL
|
||||
Cause string `json:"cause" form:"cause" gorm:"column:cause;comment:"`
|
||||
StartTime time.Time `json:"startTime" form:"startTime" gorm:"column:start_time;comment:"`
|
||||
EndTime time.Time `json:"endTime" form:"endTime" gorm:"column:end_time;comment:"`
|
||||
}
|
||||
|
||||
type ExaWfLeaveWorkflow struct {
|
||||
// 工作流操作结构体
|
||||
WorkflowBase `json:"wf"`
|
||||
ExaWfLeave `json:"business"`
|
||||
}
|
||||
|
||||
func (ExaWfLeave) TableName() string {
|
||||
return "exa_wf_leaves"
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package request
|
||||
|
||||
import "gin-vue-admin/model"
|
||||
|
||||
type WorkflowProcessSearch struct {
|
||||
model.WorkflowProcess
|
||||
PageInfo
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gin-vue-admin/global"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
var WorkflowBusinessStruct map[string]func() GVA_Workflow
|
||||
var WorkflowBusinessTable map[string]func() interface{}
|
||||
|
||||
type GVA_Workflow interface {
|
||||
CreateWorkflowMove() *WorkflowMove
|
||||
GetBusinessType() string
|
||||
GetBusinessID() uint
|
||||
GetWorkflowBase() WorkflowBase
|
||||
}
|
||||
|
||||
type WorkflowBase struct {
|
||||
WorkflowMoveID uint `json:"workflowMoveID" gorm:"-"`
|
||||
BusinessID uint `json:"businessID" gorm:"<-:false;column:id"` // 业务对应ID(businessID)的返回
|
||||
BusinessType string `json:"businessType" gorm:"-"`
|
||||
PromoterID uint `json:"promoterID" gorm:"-"`
|
||||
OperatorID uint `json:"operatorID" gorm:"-"`
|
||||
WorkflowProcessID string `json:"workflowProcessID" gorm:"-"`
|
||||
WorkflowNodeID string `json:"workflowNodeID" gorm:"-"`
|
||||
Param string `json:"param" gorm:"-"`
|
||||
Action string `json:"action" gorm:"-"`
|
||||
}
|
||||
|
||||
func (w WorkflowBase) CreateWorkflowMove() (businessModel *WorkflowMove) {
|
||||
return &WorkflowMove{
|
||||
GVA_MODEL: global.GVA_MODEL{ID: w.WorkflowMoveID},
|
||||
BusinessType: w.BusinessType,
|
||||
PromoterID: w.PromoterID,
|
||||
OperatorID: w.OperatorID,
|
||||
Param: w.Param,
|
||||
WorkflowProcessID: w.WorkflowProcessID,
|
||||
WorkflowNodeID: w.WorkflowNodeID,
|
||||
BusinessID: w.BusinessID,
|
||||
Action: w.Action,
|
||||
IsActive: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (w WorkflowBase) GetBusinessType() (businessType string) {
|
||||
return w.BusinessType
|
||||
}
|
||||
|
||||
func (w WorkflowBase) GetBusinessID() (businessID uint) {
|
||||
return w.BusinessID
|
||||
}
|
||||
|
||||
func (w WorkflowBase) GetWorkflowBase() (workflowBase WorkflowBase) {
|
||||
return w
|
||||
}
|
||||
|
||||
type WorkflowMove struct {
|
||||
global.GVA_MODEL
|
||||
WorkflowProcessID string `json:"workflowProcessID" gorm:"comment:工作流模板ID"`
|
||||
WorkflowProcess WorkflowProcess `gorm:"<-:false" json:"workflowProcess" gorm:"comment:工作流模板具体信息"`
|
||||
WorkflowNodeID string `json:"workflowNodeID" gorm:"comment:工作流节点ID"`
|
||||
WorkflowNode WorkflowNode `gorm:"<-:false" json:"workflowNode" gorm:"comment:工作流节点具体信息"`
|
||||
BusinessType string `json:"businessType" gorm:"comment:业务标记"`
|
||||
BusinessID uint `json:"businessID" gorm:"comment:业务ID"`
|
||||
PromoterID uint `json:"promoterID" gorm:"comment:当前流转发起人"`
|
||||
Promoter SysUser `gorm:"<-:false" json:"promoter" gorm:"comment:当前流转发起人信息"`
|
||||
OperatorID uint `json:"operatorID" gorm:"comment:当前流转操作人"`
|
||||
Operator SysUser `gorm:"<-:false" json:"operator" gorm:"comment:当前流转操作人信息"`
|
||||
Action string `json:"action" gorm:"comment:工作流驱动事件"`
|
||||
Param string `json:"param" gorm:"comment:工作流驱动参数"`
|
||||
IsActive bool `json:"isActive" gorm:"comment:是否是活跃节点 "`
|
||||
}
|
||||
|
||||
type WorkflowProcess struct {
|
||||
ID string `json:"id" form:"id" gorm:"comment:流程标识;primaryKey;unique;not null"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
Name string `json:"name" gorm:"comment:流程名称"`
|
||||
Category string `json:"category" gorm:"comment:分类"`
|
||||
Clazz string `json:"clazz" gorm:"comment:类型"`
|
||||
Label string `json:"label" gorm:"comment:流程标题"`
|
||||
HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"`
|
||||
Description string `json:"description" gorm:"comment:详细介绍"`
|
||||
View string `json:"view" gorm:"comment:前端视图文件"`
|
||||
Nodes []WorkflowNode `json:"nodes"` // 流程节点数据
|
||||
Edges []WorkflowEdge `json:"edges"` // 流程链接数据
|
||||
}
|
||||
|
||||
type WorkflowNode struct {
|
||||
ID string `json:"id" form:"id" gorm:"comment:节点id;primaryKey;unique;not null"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
WorkflowProcessID string `json:"workflowProcessID" gorm:"comment:流程标识"`
|
||||
Clazz string `json:"clazz" gorm:"comment:节点类型"`
|
||||
Label string `json:"label" gorm:"comment:节点名称"`
|
||||
Type string `json:"type" gorm:"comment:图标类型"`
|
||||
Shape string `json:"shape" gorm:"comment:形状"`
|
||||
Description string `json:"description" gorm:"comment:详细介绍"`
|
||||
View string `json:"view" gorm:"comment:前端视图文件"`
|
||||
X float64 `json:"y" gorm:"comment:x位置"`
|
||||
Y float64 `json:"x" gorm:"comment:y位置"`
|
||||
WaitState string `json:"waitState" gorm:"comment:等待属性"`
|
||||
StateValue string `json:"stateValue" gorm:"comment:等待值"`
|
||||
To string `json:"to" gorm:"comment:收件人"`
|
||||
Subject string `json:"subject" gorm:"comment:标题"`
|
||||
Content string `json:"content" gorm:"comment:内容"`
|
||||
Cycle string `json:"cycle" gorm:"comment:循环时间"`
|
||||
Duration string `json:"duration" gorm:"comment:持续时间"`
|
||||
HideIcon bool `json:"hideIcon" gorm:"comment:是否隐藏图标"`
|
||||
DueDate *time.Time `json:"dueDate" gorm:"comment:到期时间"`
|
||||
AssignType string `json:"assignType" gorm:"comment:审批类型"`
|
||||
AssignValue string `json:"assignValue" gorm:"comment:审批类型值"`
|
||||
Success bool `json:"success" gorm:"comment:是否成功"`
|
||||
}
|
||||
|
||||
type WorkflowEdge struct {
|
||||
ID string `json:"id" form:"id" gorm:"comment:唯一标识;primaryKey;unique;not null"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
|
||||
WorkflowProcessID string `json:"-" gorm:"comment:流程标识"`
|
||||
Clazz string `json:"clazz" gorm:"comment:类型(线)"`
|
||||
Source string `json:"source" gorm:"comment:起点节点"`
|
||||
Target string `json:"target" gorm:"comment:目标节点"`
|
||||
SourceAnchor int `json:"sourceAnchor" gorm:"comment:起点"`
|
||||
TargetAnchor int `json:"targetAnchor" gorm:"comment:目标点"`
|
||||
Description string `json:"description" gorm:"comment:详细介绍"`
|
||||
Shape string `json:"shape" gorm:"comment:形状"`
|
||||
StartPoint WorkflowStartPoint `json:"startPoint"` // 起点信息
|
||||
EndPoint WorkflowEndPoint `json:"endPoint"` // 终点信息
|
||||
Label string `json:"label" gorm:"comment:标题"`
|
||||
HideIcon bool `json:"hideIcon" gorm:"comment:隐藏图标"`
|
||||
ConditionExpression string `json:"conditionExpression" gorm:"comment:条件标识"`
|
||||
Seq string `json:"seq" gorm:"comment:序号"`
|
||||
Reverse bool `json:"reverse" gorm:"comment:是否反向"`
|
||||
}
|
||||
|
||||
type WorkflowStartPoint struct {
|
||||
WorkflowEdgeID string
|
||||
global.GVA_MODEL
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Index int `json:"index"`
|
||||
}
|
||||
|
||||
type WorkflowEndPoint struct {
|
||||
WorkflowEdgeID string
|
||||
global.GVA_MODEL
|
||||
X float64 `json:"x"`
|
||||
Y float64 `json:"y"`
|
||||
Index int `json:"index"`
|
||||
}
|
||||
@@ -20,26 +20,3 @@ func ({{.StructName}}) TableName() string {
|
||||
return "{{.TableName}}"
|
||||
}
|
||||
{{ end }}
|
||||
|
||||
// 如果使用工作流功能 需要打开下方注释 并到initialize的workflow中进行注册 且必须指定TableName
|
||||
// type {{.StructName}}Workflow struct {
|
||||
// // 工作流操作结构体
|
||||
// WorkflowBase `json:"wf"`
|
||||
// {{.StructName}} `json:"business"`
|
||||
// }
|
||||
|
||||
// func ({{.StructName}}) TableName() string {
|
||||
// return "{{.TableName}}"
|
||||
// }
|
||||
|
||||
// 工作流注册代码
|
||||
|
||||
// initWorkflowModel内部注册
|
||||
// model.WorkflowBusinessStruct["{{.Abbreviation}}"] = func() model.GVA_Workflow {
|
||||
// return new(model.{{.StructName}}Workflow)
|
||||
// }
|
||||
|
||||
// initWorkflowTable内部注册
|
||||
// model.WorkflowBusinessTable["{{.Abbreviation}}"] = func() interface{} {
|
||||
// return new(model.{{.StructName}})
|
||||
// }
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-form :model="formData" label-position="right" label-width="80px">
|
||||
{{- range .Fields}}
|
||||
<el-form-item label="{{.FieldDesc}}:">
|
||||
{{- if eq .FieldType "bool" }}
|
||||
<el-switch active-color="#13ce66" inactive-color="#ff4949" active-text="是" inactive-text="否" v-model="formData.{{.FieldJson}}" clearable ></el-switch>
|
||||
{{ end -}}
|
||||
{{- if eq .FieldType "string" }}
|
||||
<el-input v-model="formData.{{.FieldJson}}" clearable placeholder="请输入" ></el-input>
|
||||
{{ end -}}
|
||||
{{- if eq .FieldType "int" }}
|
||||
{{- if .DictType}}
|
||||
<el-select v-model="formData.{{ .FieldJson }}" placeholder="请选择" clearable>
|
||||
<el-option v-for="(item,key) in {{ .DictType }}Options" :key="key" :label="item.label" :value="item.value"></el-option>
|
||||
</el-select>
|
||||
{{ else -}}
|
||||
<el-input v-model.number="formData.{{ .FieldJson }}" clearable placeholder="请输入"></el-input>
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
{{- if eq .FieldType "time.Time" }}
|
||||
<el-date-picker type="date" placeholder="选择日期" v-model="formData.{{ .FieldJson }}" clearable></el-date-picker>
|
||||
{{ end -}}
|
||||
{{- if eq .FieldType "float64" }}
|
||||
<el-input-number v-model="formData.{{ .FieldJson }}" :precision="2" clearable></el-input-number>
|
||||
{{ end -}}
|
||||
</el-form-item>
|
||||
{{ end -}}
|
||||
|
||||
<el-form-item>
|
||||
<el-button v-if="this.wf.clazz == 'start'" @click="start" type="primary">启动</el-button>
|
||||
<!-- complete传入流转参数 决定下一步会流转到什么位置 此处可以设置多个按钮来做不同的流转 -->
|
||||
<el-button v-if="canShow" @click="complete('yes')" type="primary">提交</el-button>
|
||||
<el-button v-if="showSelfNode" @click="complete('')" type="primary">确认</el-button>
|
||||
<el-button @click="back" type="primary">返回</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
startWorkflow,
|
||||
completeWorkflowMove
|
||||
} from "@/api/workflowProcess";
|
||||
import infoList from "@/mixins/infoList";
|
||||
import { mapGetters } from "vuex";
|
||||
export default {
|
||||
name: "{{.StructName}}",
|
||||
mixins: [infoList],
|
||||
props:{
|
||||
business:{
|
||||
type:Object,
|
||||
default:function(){return null}
|
||||
},
|
||||
wf:{
|
||||
type:Object,
|
||||
default:function(){return{}}
|
||||
},
|
||||
move:{
|
||||
type:Object,
|
||||
default:function(){return{}}
|
||||
},
|
||||
workflowMoveID:{
|
||||
type:[Number,String],
|
||||
default:0
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
{{- range .Fields}}
|
||||
{{- if .DictType }}
|
||||
{{ .DictType }}Options:[],
|
||||
{{ end -}}
|
||||
{{end -}}
|
||||
|
||||
formData: {
|
||||
{{range .Fields}}
|
||||
{{- if eq .FieldType "bool" -}}
|
||||
{{.FieldJson}}:false,
|
||||
{{ end -}}
|
||||
{{- if eq .FieldType "string" -}}
|
||||
{{.FieldJson}}:"",
|
||||
{{ end -}}
|
||||
{{- if eq .FieldType "int" -}}
|
||||
{{.FieldJson}}:0,
|
||||
{{ end -}}
|
||||
{{- if eq .FieldType "time.Time" -}}
|
||||
{{.FieldJson}}:new Date(),
|
||||
{{ end -}}
|
||||
{{- if eq .FieldType "float64" -}}
|
||||
{{.FieldJson}}:0,
|
||||
{{ end -}}
|
||||
{{ end }}
|
||||
}
|
||||
};
|
||||
},
|
||||
computed:{
|
||||
showSelfNode(){
|
||||
if(this.wf.assignType == "self" && this.move.promoterID == this.userInfo.ID){
|
||||
return true
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
},
|
||||
canShow(){
|
||||
if(this.wf.assignType == "user"){
|
||||
if(this.wf.assignValue.indexOf(","+this.userInfo.ID+",")>-1 && this.wf.clazz == 'userTask'){
|
||||
return true
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
}else if(this.wf.assign_type == "authority"){
|
||||
if(this.wf.assignValue.indexOf(","+this.userInfo.authorityId+",")>-1 && this.wf.clazz == 'userTask'){
|
||||
return true
|
||||
}else{
|
||||
return false
|
||||
}
|
||||
}
|
||||
return false
|
||||
},
|
||||
...mapGetters("user", ["userInfo"])
|
||||
},
|
||||
methods: {
|
||||
async start() {
|
||||
const res = await startWorkflow({
|
||||
business:this.formData,
|
||||
wf:{
|
||||
workflowMoveID:this.workflowMoveID,
|
||||
businessId:0,
|
||||
businessType:"{{.Abbreviation}}",
|
||||
workflowProcessID:this.wf.workflowProcessID,
|
||||
workflowNodeID:this.wf.id,
|
||||
promoterID:this.userInfo.ID,
|
||||
operatorID:this.userInfo.ID,
|
||||
action:"create",
|
||||
param:""
|
||||
}
|
||||
});
|
||||
if (res.code == 0) {
|
||||
this.$message({
|
||||
type:"success",
|
||||
message:"启动成功"
|
||||
})
|
||||
this.back()
|
||||
}
|
||||
},
|
||||
async complete(param){
|
||||
const res = await completeWorkflowMove({
|
||||
business:this.formData,
|
||||
wf:{
|
||||
workflowMoveID:this.workflowMoveID,
|
||||
businessID:this.formData.ID,
|
||||
businessType:"{{.Abbreviation}}",
|
||||
workflowProcessID:this.wf.workflowProcessID,
|
||||
workflowNodeID:this.wf.id,
|
||||
promoterID:this.userInfo.ID,
|
||||
operatorID:this.userInfo.ID,
|
||||
action:"complete",
|
||||
param:param
|
||||
}
|
||||
})
|
||||
if(res.code == 0){
|
||||
this.$message({
|
||||
type:"success",
|
||||
message:"提交成功"
|
||||
})
|
||||
this.back()
|
||||
}
|
||||
},
|
||||
back(){
|
||||
this.$router.go(-1)
|
||||
}
|
||||
},
|
||||
async created() {
|
||||
if(this.business){
|
||||
this.formData = this.business
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
</style>
|
||||
@@ -1,25 +0,0 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"gin-vue-admin/api/v1"
|
||||
"gin-vue-admin/middleware"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func InitWorkflowProcessRouter(Router *gin.RouterGroup) {
|
||||
WorkflowProcessRouter := Router.Group("workflowProcess").Use(middleware.OperationRecord())
|
||||
{
|
||||
WorkflowProcessRouter.POST("createWorkflowProcess", v1.CreateWorkflowProcess) // 新建WorkflowProcess
|
||||
WorkflowProcessRouter.DELETE("deleteWorkflowProcess", v1.DeleteWorkflowProcess) // 删除WorkflowProcess
|
||||
WorkflowProcessRouter.DELETE("deleteWorkflowProcessByIds", v1.DeleteWorkflowProcessByIds) // 批量删除WorkflowProcess
|
||||
WorkflowProcessRouter.PUT("updateWorkflowProcess", v1.UpdateWorkflowProcess) // 更新WorkflowProcess
|
||||
WorkflowProcessRouter.GET("findWorkflowProcess", v1.FindWorkflowProcess) // 根据ID获取WorkflowProcess
|
||||
WorkflowProcessRouter.GET("findWorkflowStep", v1.FindWorkflowStep) // 根据ID获取工作流步骤
|
||||
WorkflowProcessRouter.GET("getWorkflowProcessList", v1.GetWorkflowProcessList) // 获取WorkflowProcess列表
|
||||
WorkflowProcessRouter.POST("startWorkflow", v1.StartWorkflow) // 开启工作流
|
||||
WorkflowProcessRouter.POST("completeWorkflowMove", v1.CompleteWorkflowMove) // 提交工作流
|
||||
WorkflowProcessRouter.GET("getMyStated", v1.GetMyStated) // 获取我发起的工作流
|
||||
WorkflowProcessRouter.GET("getMyNeed", v1.GetMyNeed) // 获取我的待办
|
||||
WorkflowProcessRouter.GET("getWorkflowMoveByID", v1.GetWorkflowMoveByID) // 获取我的待办
|
||||
}
|
||||
}
|
||||
@@ -237,9 +237,6 @@ func addAutoMoveFile(data *tplData) {
|
||||
if strings.Contains(fileSlice[n-1], "js") {
|
||||
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
|
||||
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WApi, base)
|
||||
} else if strings.Contains(fileSlice[n-2], "workflowForm") {
|
||||
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
|
||||
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WFlow, filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), strings.TrimSuffix(base, filepath.Ext(base))+"WorkflowForm.vue")
|
||||
} else if strings.Contains(fileSlice[n-2], "form") {
|
||||
data.autoMoveFilePath = filepath.Join(global.GVA_CONFIG.AutoCode.Root,
|
||||
global.GVA_CONFIG.AutoCode.Web, global.GVA_CONFIG.AutoCode.WForm, filepath.Base(filepath.Dir(filepath.Dir(data.autoCodePath))), strings.TrimSuffix(base, filepath.Ext(base))+"Form.vue")
|
||||
|
||||
@@ -61,6 +61,15 @@ func initDB(InitDBFunctions ...model.InitDBFunc) (err error) {
|
||||
//@return: err error, treeMap map[string][]model.SysMenu
|
||||
|
||||
func InitDB(conf request.InitDB) error {
|
||||
|
||||
baseSetting := map[string]interface{}{
|
||||
"mysql.path": "",
|
||||
"mysql.db-name": "",
|
||||
"mysql.username": "",
|
||||
"mysql.password": "",
|
||||
"mysql.config": "charset=utf8mb4&parseTime=True&loc=Local",
|
||||
}
|
||||
|
||||
if conf.Host == "" {
|
||||
conf.Host = "127.0.0.1"
|
||||
}
|
||||
@@ -125,13 +134,6 @@ func InitDB(conf request.InitDB) error {
|
||||
model.ExaSimpleUploader{},
|
||||
model.ExaCustomer{},
|
||||
model.SysOperationRecord{},
|
||||
model.WorkflowProcess{},
|
||||
model.WorkflowNode{},
|
||||
model.WorkflowEdge{},
|
||||
model.WorkflowStartPoint{},
|
||||
model.WorkflowEndPoint{},
|
||||
model.WorkflowMove{},
|
||||
model.ExaWfLeave{},
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -147,9 +149,9 @@ func InitDB(conf request.InitDB) error {
|
||||
source.Dictionary,
|
||||
source.DictionaryDetail,
|
||||
source.File,
|
||||
source.BaseMenu,
|
||||
source.Workflow)
|
||||
source.BaseMenu)
|
||||
if err != nil {
|
||||
_ = writeConfig(global.GVA_VP, baseSetting)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -1,445 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gin-vue-admin/constant"
|
||||
"gin-vue-admin/global"
|
||||
"gin-vue-admin/model"
|
||||
"gin-vue-admin/model/request"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func getTable(businessType string) interface{} {
|
||||
return model.WorkflowBusinessTable[businessType]()
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: CreateWorkflowProcess
|
||||
//@description: 创建工作流相关信息
|
||||
//@param: workflowProcess model.WorkflowProcess
|
||||
//@return: err error
|
||||
|
||||
func CreateWorkflowProcess(workflowProcess model.WorkflowProcess) (err error) {
|
||||
err = global.GVA_DB.Create(&workflowProcess).Error
|
||||
return err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: DeleteWorkflowProcess
|
||||
//@description: 删除工作流相关信息
|
||||
//@param: workflowProcess model.WorkflowProcess
|
||||
//@return: err error
|
||||
|
||||
func DeleteWorkflowProcess(workflowProcess model.WorkflowProcess) (err error) {
|
||||
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
var txErr error
|
||||
txErr = tx.Delete(&workflowProcess).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
var edges []model.WorkflowEdge
|
||||
txErr = tx.Delete(&model.WorkflowNode{}, "workflow_process_id = ?", workflowProcess.ID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = tx.Find(&edges, "workflow_process_id = ?", workflowProcess.ID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
if len(edges) > 0 {
|
||||
txErr = tx.Select("StartPoint", "EndPoint").Delete(&edges).Error
|
||||
}
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: CreateWorkflowProcess
|
||||
//@description: 批量删除工作流信息(暂未启用)
|
||||
//@param: ids request.IdsReq
|
||||
//@return: err error
|
||||
|
||||
func DeleteWorkflowProcessByIds(ids request.IdsReq) (err error) {
|
||||
err = global.GVA_DB.Delete(&[]model.WorkflowProcess{}, "id in ?", ids.Ids).Error
|
||||
return err
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: UpdateWorkflowProcess
|
||||
//@description: 更新工作流相关信息
|
||||
//@param: workflowProcess *model.WorkflowProcess
|
||||
//@return: err error
|
||||
|
||||
func UpdateWorkflowProcess(workflowProcess *model.WorkflowProcess) (err error) {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
var txErr error
|
||||
var edges []model.WorkflowEdge
|
||||
var edgesIds []string
|
||||
txErr = tx.Unscoped().Delete(workflowProcess).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = tx.Unscoped().Delete(&model.WorkflowNode{}, "workflow_process_id = ?", workflowProcess.ID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = tx.Unscoped().Find(&edges, "workflow_process_id = ?", workflowProcess.ID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = tx.Unscoped().Delete(&edges).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
for _, v := range edges {
|
||||
edgesIds = append(edgesIds, v.ID)
|
||||
}
|
||||
txErr = tx.Unscoped().Delete(&model.WorkflowStartPoint{}, "workflow_edge_id in ?", edgesIds).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = tx.Unscoped().Delete(&model.WorkflowEndPoint{}, "workflow_edge_id in ?", edgesIds).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = tx.Create(&workflowProcess).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetWorkflowProcess
|
||||
//@description: 获取工作流相关信息
|
||||
//@param: id string
|
||||
//@return: err error,workflowProcess model.WorkflowProcess
|
||||
|
||||
func GetWorkflowProcess(id string) (err error, workflowProcess model.WorkflowProcess) {
|
||||
err = global.GVA_DB.Preload("Nodes").Preload("Edges").Where("id = ?", id).First(&workflowProcess).Error
|
||||
return
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetWorkflowCreateStep
|
||||
//@description: 获取工作流步骤信息
|
||||
//@param: id string
|
||||
//@return: err error, workflowNodes []model.WorkflowNode
|
||||
|
||||
func FindWorkflowStep(id string) (err error, workflowNode model.WorkflowProcess) {
|
||||
err = global.GVA_DB.Preload("Nodes", "clazz = ?", constant.START).Where("id = ?", id).First(&workflowNode).Error
|
||||
return
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: GetWorkflowProcessInfoList
|
||||
//@description: 获取工作流列表
|
||||
//@param: info request.WorkflowProcessSearch
|
||||
//@return: err error, list interface{}, total int64
|
||||
|
||||
func GetWorkflowProcessInfoList(info request.WorkflowProcessSearch) (err error, list interface{}, total int64) {
|
||||
limit := info.PageSize
|
||||
offset := info.PageSize * (info.Page - 1)
|
||||
// 创建db
|
||||
db := global.GVA_DB.Model(&model.WorkflowProcess{})
|
||||
var workflowProcesss []model.WorkflowProcess
|
||||
// 如果有条件搜索 下方会自动创建搜索语句
|
||||
if info.Name != "" {
|
||||
db = db.Where("`name` LIKE ?", "%"+info.Name+"%")
|
||||
}
|
||||
if info.Label != "" {
|
||||
db = db.Where("`label` LIKE ?", "%"+info.Label+"%")
|
||||
}
|
||||
err = db.Count(&total).Error
|
||||
err = db.Limit(limit).Offset(offset).Find(&workflowProcesss).Error
|
||||
return err, workflowProcesss, total
|
||||
}
|
||||
|
||||
//@author: [piexlmax](https://github.com/piexlmax)
|
||||
//@function: StartWorkflow
|
||||
//@description: 开启一个工作流
|
||||
//@param: wfInterface model.GVA_Workflow
|
||||
//@return: err error
|
||||
|
||||
func StartWorkflow(wfInterface model.GVA_Workflow) (err error) {
|
||||
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
var txErr error
|
||||
tableName := getTable(wfInterface.GetBusinessType()).(schema.Tabler).TableName()
|
||||
txErr = tx.Table(tableName).Create(wfInterface).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
wfm := wfInterface.CreateWorkflowMove()
|
||||
txErr = tx.Create(wfm).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = complete(tx, wfm)
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func CompleteWorkflowMove(wfInterface model.GVA_Workflow) (err error) {
|
||||
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
var txErr error
|
||||
tableName := getTable(wfInterface.GetBusinessType()).(schema.Tabler).TableName()
|
||||
txErr = tx.Table(tableName).Where("id = ?", wfInterface.GetBusinessID()).Updates(wfInterface).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
nowWorkflowMove := wfInterface.CreateWorkflowMove()
|
||||
txErr = complete(tx, nowWorkflowMove)
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
func complete(tx *gorm.DB, wfm *model.WorkflowMove) (err error) {
|
||||
var returnWfm model.WorkflowMove
|
||||
var nodeInfo model.WorkflowNode
|
||||
var Edges []model.WorkflowEdge
|
||||
txErr := tx.First(&returnWfm, "id = ? AND is_active = ?", wfm.ID, true).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = tx.First(&nodeInfo, "id = ?", wfm.WorkflowNodeID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
|
||||
if nodeInfo.Clazz == constant.START || nodeInfo.Clazz == constant.USER_TASK {
|
||||
txErr = tx.Find(&Edges, "workflow_process_id = ? and source = ?", wfm.WorkflowProcessID, wfm.WorkflowNodeID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
if len(Edges) == 0 {
|
||||
return errors.New("不存在当前节点为起点的后续流程")
|
||||
}
|
||||
if len(Edges) == 1 {
|
||||
txErr = tx.Model(&returnWfm).Update("param", wfm.Param).Update("is_active", false).Update("action", wfm.Action).Update("operator_id", wfm.OperatorID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr, newWfm := createNewWorkflowMove(tx, &returnWfm, Edges[0].Target)
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
if len(newWfm) > 0 {
|
||||
txErr = tx.Create(&newWfm).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
}
|
||||
// 当target为自动节点时候 需要做一些事情 这里暂时先不处理 后续慢慢完善
|
||||
}
|
||||
if len(Edges) > 1 {
|
||||
var needUseTargetNodeID string
|
||||
|
||||
txErr = tx.Model(&returnWfm).Update("param", wfm.Param).Update("is_active", false).Update("action", wfm.Action).Update("operator_id", wfm.OperatorID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
for _, v := range Edges {
|
||||
if v.ConditionExpression == wfm.Param {
|
||||
needUseTargetNodeID = v.Target
|
||||
break
|
||||
}
|
||||
}
|
||||
if needUseTargetNodeID == "" {
|
||||
return errors.New("未发现流转参数,流转失败")
|
||||
}
|
||||
txErr, newWfm := createNewWorkflowMove(tx, &returnWfm, needUseTargetNodeID)
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
if len(newWfm) > 0 {
|
||||
txErr = tx.Create(&newWfm).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if nodeInfo.Clazz == constant.EXCLUSIVE_GATEWAY {
|
||||
return errors.New("目前只支持start节点和userTask功能,其他功能正在开发中")
|
||||
} else if nodeInfo.Clazz == constant.INCLUSIVE_GATEWAY {
|
||||
return errors.New("目前只支持start节点和userTask功能,其他功能正在开发中")
|
||||
} else if nodeInfo.Clazz == constant.PARELLEL_GATEWAY {
|
||||
return errors.New("目前只支持start节点和userTask功能,其他功能正在开发中")
|
||||
} else {
|
||||
return errors.New("目前只支持start节点和userTask功能,其他功能正在开发中")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func createNewWorkflowMove(tx *gorm.DB, oldWfm *model.WorkflowMove, targetNodeID string) (err error, newWfm []model.WorkflowMove) {
|
||||
// 以下所有非 default的节点的下一步流转均应该处理为递归形式
|
||||
var nodeInfo model.WorkflowNode
|
||||
var edge model.WorkflowEdge
|
||||
var edges []model.WorkflowEdge
|
||||
var wfms []model.WorkflowMove
|
||||
txErr := tx.First(&nodeInfo, "id = ?", targetNodeID).Error
|
||||
if txErr != nil {
|
||||
return txErr, []model.WorkflowMove{}
|
||||
}
|
||||
switch nodeInfo.Clazz {
|
||||
case constant.EXCLUSIVE_GATEWAY:
|
||||
// 当为排他网关时候 选择一个参数进行排他线路选择
|
||||
txErr := tx.First(&edge, "workflow_process_id = ? and source = ? and condition_expression = ?", oldWfm.WorkflowProcessID, nodeInfo.ID, oldWfm.Param).Error
|
||||
if txErr != nil {
|
||||
return txErr, []model.WorkflowMove{}
|
||||
}
|
||||
newWfm = append(newWfm, model.WorkflowMove{
|
||||
BusinessID: oldWfm.BusinessID,
|
||||
BusinessType: oldWfm.BusinessType,
|
||||
PromoterID: oldWfm.PromoterID,
|
||||
OperatorID: 0,
|
||||
WorkflowNodeID: edge.Target,
|
||||
WorkflowProcessID: oldWfm.WorkflowProcessID,
|
||||
Param: "",
|
||||
Action: "",
|
||||
IsActive: true})
|
||||
return nil, newWfm
|
||||
case constant.INCLUSIVE_GATEWAY:
|
||||
// 当为包容网关时,需要等待其他网关执行结束才进行创建
|
||||
txErr := tx.Find(&edges, "workflow_process_id = ? and target = ?", oldWfm.WorkflowProcessID, nodeInfo.ID).Error
|
||||
if txErr != nil {
|
||||
return txErr, []model.WorkflowMove{}
|
||||
}
|
||||
var sourceIds []string
|
||||
for _, v := range edges {
|
||||
sourceIds = append(sourceIds, v.Source)
|
||||
}
|
||||
txErr = tx.Find(&wfms, "workflow_process_id = ? and business_id = ? and workflow_node_id in (?) and is_active = ?", oldWfm.WorkflowProcessID, oldWfm.BusinessID, sourceIds, false).Error
|
||||
if txErr != nil {
|
||||
return txErr, []model.WorkflowMove{}
|
||||
}
|
||||
if len(wfms) != len(edges) {
|
||||
return nil, []model.WorkflowMove{}
|
||||
}
|
||||
if len(wfms) == len(edges) {
|
||||
params := make(map[string]int)
|
||||
var param string
|
||||
var temp int
|
||||
for _, v := range wfms {
|
||||
params[v.Param]++
|
||||
}
|
||||
for k, v := range params {
|
||||
if temp < v {
|
||||
temp = v
|
||||
param = k
|
||||
}
|
||||
}
|
||||
//参数携带模式暂时未定 暂时为少数服从多数原则 后续会增加原则配置 (少数服从多数,仅一关键字即为关键字,所有关键字才为关键字 三种方案)
|
||||
txErr := tx.First(&edge, "workflow_process_id = ? and source = ? and condition_expression = ?", oldWfm.WorkflowProcessID, nodeInfo.ID, param).Error
|
||||
if txErr != nil {
|
||||
return txErr, []model.WorkflowMove{}
|
||||
}
|
||||
newWfm = append(newWfm, model.WorkflowMove{
|
||||
BusinessID: oldWfm.BusinessID,
|
||||
BusinessType: oldWfm.BusinessType,
|
||||
PromoterID: oldWfm.PromoterID,
|
||||
OperatorID: 0,
|
||||
WorkflowNodeID: edge.Target,
|
||||
WorkflowProcessID: oldWfm.WorkflowProcessID,
|
||||
Param: "",
|
||||
Action: "",
|
||||
IsActive: true})
|
||||
}
|
||||
return nil, newWfm
|
||||
|
||||
case constant.PARELLEL_GATEWAY:
|
||||
// 当为并行网关时候 找出所有线路创建并行节点
|
||||
txErr := tx.Find(&edges, "workflow_process_id = ? and source = ?", oldWfm.WorkflowProcessID, nodeInfo.ID).Error
|
||||
if txErr != nil {
|
||||
return txErr, []model.WorkflowMove{}
|
||||
}
|
||||
for _, v := range edges {
|
||||
newWfm = append(newWfm, model.WorkflowMove{
|
||||
BusinessID: oldWfm.BusinessID,
|
||||
BusinessType: oldWfm.BusinessType,
|
||||
PromoterID: oldWfm.PromoterID,
|
||||
OperatorID: 0,
|
||||
WorkflowNodeID: v.Target,
|
||||
WorkflowProcessID: oldWfm.WorkflowProcessID,
|
||||
Param: "",
|
||||
Action: "",
|
||||
IsActive: true})
|
||||
}
|
||||
|
||||
return nil, newWfm
|
||||
case constant.END:
|
||||
newWfm = append(newWfm, model.WorkflowMove{
|
||||
BusinessID: oldWfm.BusinessID,
|
||||
BusinessType: oldWfm.BusinessType,
|
||||
PromoterID: oldWfm.PromoterID,
|
||||
OperatorID: oldWfm.OperatorID,
|
||||
WorkflowNodeID: targetNodeID,
|
||||
WorkflowProcessID: oldWfm.WorkflowProcessID,
|
||||
Param: "",
|
||||
Action: "",
|
||||
IsActive: false})
|
||||
return nil, newWfm
|
||||
default:
|
||||
newWfm = append(newWfm, model.WorkflowMove{
|
||||
BusinessID: oldWfm.BusinessID,
|
||||
BusinessType: oldWfm.BusinessType,
|
||||
PromoterID: oldWfm.PromoterID,
|
||||
OperatorID: 0,
|
||||
WorkflowNodeID: targetNodeID,
|
||||
WorkflowProcessID: oldWfm.WorkflowProcessID,
|
||||
Param: "",
|
||||
Action: "",
|
||||
IsActive: true})
|
||||
return nil, newWfm
|
||||
}
|
||||
}
|
||||
|
||||
func GetMyStated(userID uint) (err error, wfms []model.WorkflowMove) {
|
||||
err = global.GVA_DB.Preload("Promoter").Preload("Operator").Preload("WorkflowNode").Preload("WorkflowProcess").Joins("INNER JOIN workflow_nodes as node ON workflow_moves.workflow_node_id = node.id").Find(&wfms, "promoter_id = ? and ( is_active = ? OR node.clazz = ?)", userID, true, "end").Error
|
||||
return err, wfms
|
||||
}
|
||||
|
||||
func GetMyNeed(userID uint, AuthorityID string) (err error, wfms []model.WorkflowMove) {
|
||||
user := "%," + strconv.Itoa(int(userID)) + ",%"
|
||||
auth := "%," + AuthorityID + ",%"
|
||||
err = global.GVA_DB.Preload("Promoter").Preload("Operator").Preload("WorkflowNode").Preload("WorkflowProcess").Joins("INNER JOIN workflow_nodes as node ON workflow_moves.workflow_node_id = node.id").Where("is_active = ? AND ((node.assign_type = ? AND node.assign_value LIKE ? ) OR (node.assign_type = ? AND node.assign_value LIKE ? ) OR (node.assign_type = ? AND promoter_id = ? ))", true, "user", user, "authority", auth, "self", userID).Find(&wfms).Error
|
||||
return err, wfms
|
||||
}
|
||||
|
||||
func GetWorkflowMoveByID(id float64) (err error, move model.WorkflowMove, moves []model.WorkflowMove, business interface{}) {
|
||||
var result interface{}
|
||||
err = global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
var txErr error
|
||||
txErr = tx.Preload("Promoter").Preload("Operator").Preload("WorkflowNode").Preload("WorkflowProcess").First(&move, "id = ?", id).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
txErr = tx.Preload("Promoter").Preload("Operator").Preload("WorkflowNode").Preload("WorkflowProcess").Find(&moves, "business_id = ? AND business_type = ?", move.BusinessID, move.BusinessType).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
result = getTable(move.BusinessType)
|
||||
fmt.Println(result)
|
||||
txErr = tx.First(result, "id = ?", move.BusinessID).Error
|
||||
if txErr != nil {
|
||||
return txErr
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return err, move, moves, result
|
||||
}
|
||||
@@ -80,18 +80,6 @@ var apis = []model.SysApi{
|
||||
{global.GVA_MODEL{ID: 65, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/user/setUserInfo", "设置用户信息", "user", "PUT"},
|
||||
{global.GVA_MODEL{ID: 66, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/system/getServerInfo", "获取服务器信息", "system", "POST"},
|
||||
{global.GVA_MODEL{ID: 67, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/email/emailTest", "发送测试邮件", "email", "POST"},
|
||||
{global.GVA_MODEL{ID: 68, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/createWorkflowProcess", "新建工作流", "workflowProcess", "POST"},
|
||||
{global.GVA_MODEL{ID: 69, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/deleteWorkflowProcess", "删除工作流", "workflowProcess", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 70, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/deleteWorkflowProcessByIds", "批量删除工作流", "workflowProcess", "DELETE"},
|
||||
{global.GVA_MODEL{ID: 71, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/updateWorkflowProcess", "更新工作流", "workflowProcess", "PUT"},
|
||||
{global.GVA_MODEL{ID: 72, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/findWorkflowProcess", "根据ID获取工作流", "workflowProcess", "GET"},
|
||||
{global.GVA_MODEL{ID: 73, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getWorkflowProcessList", "获取工作流", "workflowProcess", "GET"},
|
||||
{global.GVA_MODEL{ID: 74, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/findWorkflowStep", "获取工作流步骤", "workflowProcess", "GET"},
|
||||
{global.GVA_MODEL{ID: 75, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/startWorkflow", "启动工作流", "workflowProcess", "POST"},
|
||||
{global.GVA_MODEL{ID: 76, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getMyStated", "获取我发起的工作流", "workflowProcess", "GET"},
|
||||
{global.GVA_MODEL{ID: 77, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getMyNeed", "获取我的待办", "workflowProcess", "GET"},
|
||||
{global.GVA_MODEL{ID: 78, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/getWorkflowMoveByID", "根据id获取当前节点详情和历史", "workflowProcess", "GET"},
|
||||
{global.GVA_MODEL{ID: 79, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/workflowProcess/completeWorkflowMove", "提交工作流", "workflowProcess", "POST"},
|
||||
{global.GVA_MODEL{ID: 80, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/autoCode/preview", "预览自动化代码", "autoCode", "POST"},
|
||||
{global.GVA_MODEL{ID: 81, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/excel/importExcel", "导入excel", "excel", "POST"},
|
||||
{global.GVA_MODEL{ID: 82, CreatedAt: time.Now(), UpdatedAt: time.Now()}, "/excel/loadExcel", "下载excel", "excel", "GET"},
|
||||
|
||||
@@ -39,12 +39,6 @@ var authorityMenus = []AuthorityMenus{
|
||||
{"888", 21},
|
||||
{"888", 22},
|
||||
{"888", 23},
|
||||
{"888", 24},
|
||||
{"888", 25},
|
||||
{"888", 26},
|
||||
{"888", 27},
|
||||
{"888", 28},
|
||||
{"888", 29},
|
||||
{"8881", 1},
|
||||
{"8881", 2},
|
||||
{"8881", 8},
|
||||
|
||||
@@ -80,18 +80,6 @@ var carbines = []gormadapter.CasbinRule{
|
||||
{PType: "p", V0: "888", V1: "/simpleUploader/upload", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/simpleUploader/checkFileMd5", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/simpleUploader/mergeFileMd5", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/createWorkflowProcess", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/deleteWorkflowProcess", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/deleteWorkflowProcessByIds", V2: "DELETE"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/updateWorkflowProcess", V2: "PUT"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/findWorkflowProcess", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/getWorkflowProcessList", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/findWorkflowStep", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/startWorkflow", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/completeWorkflowMove", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/getMyStated", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/getMyNeed", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/workflowProcess/getWorkflowMoveByID", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/excel/importExcel", V2: "POST"},
|
||||
{PType: "p", V0: "888", V1: "/excel/loadExcel", V2: "GET"},
|
||||
{PType: "p", V0: "888", V1: "/excel/exportExcel", V2: "POST"},
|
||||
|
||||
@@ -37,12 +37,6 @@ var menus = []model.SysBaseMenu{
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 21, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, Hidden: false, ParentId: "9", Path: "simpleUploader", Name: "simpleUploader", Component: "view/example/simpleUploader/simpleUploader", Sort: 6, Meta: model.Meta{Title: "断点续传(插件版)", Icon: "upload"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 22, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "https://www.gin-vue-admin.com", Name: "https://www.gin-vue-admin.com", Hidden: false, Component: "/", Sort: 0, Meta: model.Meta{Title: "官方网站", Icon: "s-home"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 23, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "state", Name: "state", Hidden: false, Component: "view/system/state.vue", Sort: 6, Meta: model.Meta{Title: "服务器状态", Icon: "cloudy"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 24, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "0", Path: "workflow", Name: "workflow", Hidden: false, Component: "view/workflow/index.vue", Sort: 5, Meta: model.Meta{Title: "工作流功能", Icon: "phone"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 25, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "24", Path: "workflowCreate", Name: "workflowCreate", Hidden: false, Component: "view/workflow/workflowCreate/workflowCreate.vue", Sort: 0, Meta: model.Meta{Title: "工作流绘制", Icon: "circle-plus"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 26, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "24", Path: "workflowProcess", Name: "workflowProcess", Hidden: false, Component: "view/workflow/workflowProcess/workflowProcess.vue", Sort: 0, Meta: model.Meta{Title: "工作流列表", Icon: "s-cooperation"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 27, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "24", Path: "workflowUse", Name: "workflowUse", Hidden: true, Component: "view/workflow/workflowUse/workflowUse.vue", Sort: 0, Meta: model.Meta{Title: "使用工作流", Icon: "video-play"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 28, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "24", Path: "started", Name: "started", Hidden: false, Component: "view/workflow/userList/started.vue", Sort: 0, Meta: model.Meta{Title: "我发起的", Icon: "s-order"}},
|
||||
{GVA_MODEL: global.GVA_MODEL{ID: 29, CreatedAt: time.Now(), UpdatedAt: time.Now()}, MenuLevel: 0, ParentId: "24", Path: "need", Name: "need", Hidden: false, Component: "view/workflow/userList/need.vue", Sort: 0, Meta: model.Meta{Title: "我的待办", Icon: "s-platform"}},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
package source
|
||||
|
||||
import (
|
||||
"gin-vue-admin/global"
|
||||
"gin-vue-admin/model"
|
||||
"time"
|
||||
|
||||
"github.com/gookit/color"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var Workflow = new(workflow)
|
||||
|
||||
type workflow struct{}
|
||||
|
||||
var WorkflowProcess = []model.WorkflowProcess{
|
||||
{ID: "leaveFlow", CreatedAt: time.Now(), UpdatedAt: time.Now(), Name: "leaveFlow", Clazz: "process", Label: "请假流程(演示)", HideIcon: false, Description: "请假流程演示", View: "view/iconList/index.vue"},
|
||||
}
|
||||
|
||||
var WorkflowNodes = []model.WorkflowNode{
|
||||
{ID: "end1603681358043", CreatedAt: time.Now(), UpdatedAt: time.Now(), WorkflowProcessID: "leaveFlow", Clazz: "end", Label: "请假失败", Type: "end-node", Shape: "end-node", Description: "", View: "view/exa_wf_leave/exa_wf_leaveFrom.vue", X: 302, Y: 545.5, HideIcon: false, AssignType: "", AssignValue: "", Success: false},
|
||||
{ID: "end1603681360882", CreatedAt: time.Now(), UpdatedAt: time.Now(), WorkflowProcessID: "leaveFlow", Clazz: "end", Label: "请假成功", Type: "end-node", Shape: "end-node", Description: "请假完成,具体结果等待提交", View: "view/exa_wf_leave/exa_wf_leaveFrom.vue", X: 83.5, Y: 546, HideIcon: false, AssignType: "", AssignValue: "", Success: true},
|
||||
{ID: "start1603681292875", CreatedAt: time.Now(), UpdatedAt: time.Now(), WorkflowProcessID: "leaveFlow", Clazz: "start", Label: "发起请假", Type: "start-node", Shape: "start-node", Description: "发起一个请假流程", View: "view/exa_wf_leave/exa_wf_leaveFrom.vue", X: 201, Y: 109, HideIcon: false, AssignType: "", AssignValue: "", Success: false},
|
||||
{ID: "userTask1603681299962", CreatedAt: time.Now(), UpdatedAt: time.Now(), WorkflowProcessID: "leaveFlow", Clazz: "userTask", Label: "审批", Type: "user-task-node", Shape: "user-task-node", Description: "审批会签", View: "view/exa_wf_leave/exa_wf_leaveFrom.vue", X: 202, Y: 320.5, HideIcon: false, AssignType: "user", AssignValue: ",1,2,", Success: false},
|
||||
}
|
||||
var WorkflowEdge = []model.WorkflowEdge{
|
||||
{ID: "flow1604985849039", CreatedAt: time.Now(), UpdatedAt: time.Now(), WorkflowProcessID: "leaveFlow", Clazz: "flow", Source: "start1603681292875", Target: "userTask1603681299962", SourceAnchor: 1, TargetAnchor: 3, Shape: "flow-polyline-round", Label: "", HideIcon: false, ConditionExpression: "", Reverse: false},
|
||||
{ID: "flow1604985879574", CreatedAt: time.Now(), UpdatedAt: time.Now(), WorkflowProcessID: "leaveFlow", Clazz: "flow", Source: "userTask1603681299962", Target: "end1603681360882", SourceAnchor: 0, TargetAnchor: 2, Shape: "flow-polyline-round", Label: "同意", HideIcon: false, ConditionExpression: "yes", Reverse: false},
|
||||
{ID: "flow1604985881207", CreatedAt: time.Now(), UpdatedAt: time.Now(), WorkflowProcessID: "leaveFlow", Clazz: "flow", Source: "userTask1603681299962", Target: "end1603681358043", SourceAnchor: 2, TargetAnchor: 2, Shape: "flow-polyline-round", Label: "不同意", HideIcon: false, ConditionExpression: "no", Reverse: false},
|
||||
}
|
||||
var WorkflowStartPoint = []model.WorkflowStartPoint{
|
||||
{WorkflowEdgeID: "flow1604985849039", GVA_MODEL: global.GVA_MODEL{ID: 31, CreatedAt: time.Now(), UpdatedAt: time.Now()}, X: 137, Y: 201, Index: 1},
|
||||
{WorkflowEdgeID: "flow1604985879574", GVA_MODEL: global.GVA_MODEL{ID: 32, CreatedAt: time.Now(), UpdatedAt: time.Now()}, X: 320.5, Y: 174, Index: 0},
|
||||
{WorkflowEdgeID: "flow1604985881207", GVA_MODEL: global.GVA_MODEL{ID: 33, CreatedAt: time.Now(), UpdatedAt: time.Now()}, X: 320.5, Y: 230, Index: 2},
|
||||
}
|
||||
|
||||
var WorkflowEndPoint = []model.WorkflowEndPoint{
|
||||
{WorkflowEdgeID: "flow1604985849039", GVA_MODEL: global.GVA_MODEL{ID: 31, CreatedAt: time.Now(), UpdatedAt: time.Now()}, X: 270, Y: 202, Index: 3},
|
||||
{WorkflowEdgeID: "flow1604985879574", GVA_MODEL: global.GVA_MODEL{ID: 32, CreatedAt: time.Now(), UpdatedAt: time.Now()}, X: 518, Y: 83.5, Index: 2},
|
||||
{WorkflowEdgeID: "flow1604985881207", GVA_MODEL: global.GVA_MODEL{ID: 33, CreatedAt: time.Now(), UpdatedAt: time.Now()}, X: 517.5, Y: 302, Index: 2},
|
||||
}
|
||||
|
||||
//@author: [SliverHorn](https://github.com/SliverHorn)
|
||||
//@description: 工作流相关 表数据初始化
|
||||
func (w *workflow) Init() error {
|
||||
return global.GVA_DB.Transaction(func(tx *gorm.DB) error {
|
||||
if tx.Where("id IN ?", []string{"leaveFlow"}).Find(&[]model.WorkflowProcess{}).RowsAffected == 1 {
|
||||
// continue
|
||||
} else if err := tx.Create(&WorkflowProcess).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
|
||||
if tx.Where("id IN ?", []string{"end1603681358043", "end1603681360882", "start1603681292875", "userTask1603681299962"}).Find(&[]model.WorkflowNode{}).RowsAffected == 4 {
|
||||
// continue
|
||||
} else if err := tx.Create(&WorkflowNodes).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
|
||||
if tx.Where("id IN ?", []string{"flow1604985849039", "flow1604985879574", "flow1604985881207"}).Find(&[]model.WorkflowEdge{}).RowsAffected == 3 {
|
||||
|
||||
} else if err := tx.Create(&WorkflowEdge).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
|
||||
if tx.Where("workflow_edge_id IN ?", []string{"flow1604985849039", "flow1604985879574", "flow1604985881207"}).Find(&[]model.WorkflowStartPoint{}).RowsAffected == 3 {
|
||||
|
||||
} else if err := tx.Create(&WorkflowStartPoint).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
|
||||
if tx.Where("workflow_edge_id IN ?", []string{"flow1604985849039", "flow1604985879574", "flow1604985881207"}).Find(&[]model.WorkflowEndPoint{}).RowsAffected == 3 {
|
||||
|
||||
} else if err := tx.Create(&WorkflowEndPoint).Error; err != nil { // 遇到错误时回滚事务
|
||||
return err
|
||||
}
|
||||
color.Info.Println("\n[Mysql] --> 工作流相关 表初始数据成功!")
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user