Browse Source

工作流重新定义 以及create路由开发

main
pixel 5 years ago
parent
commit
6e54770e4e
  1. 25
      QMPlusServer/controller/api/workFlow.go
  2. 86
      QMPlusServer/docs/docs.go
  3. 84
      QMPlusServer/docs/swagger.json
  4. 58
      QMPlusServer/docs/swagger.yaml
  5. 1
      QMPlusServer/init/initRouter/initRouter.go
  6. 11
      QMPlusServer/init/registTable/registTable.go
  7. 18
      QMPlusServer/model/dbModel/application.go
  8. 36
      QMPlusServer/model/dbModel/worfFlow.go
  9. 14
      QMPlusServer/model/dbModel/workFlowProcess.go
  10. 14
      QMPlusServer/router/workflow.go

25
QMPlusServer/controller/api/workFlow.go

@ -0,0 +1,25 @@
package api
import (
"fmt"
"github.com/gin-gonic/gin"
"main/controller/servers"
"main/model/dbModel"
)
// @Tags workflow
// @Summary 注册工作流
// @Produce application/json
// @Param data body dbModel.Workflow true "注册工作流接口"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"注册成功"}"
// @Router /workflow/createWorkFlow [post]
func CreateWorkFlow(c *gin.Context) {
var wk dbModel.Workflow
_ = c.ShouldBind(&wk)
err := wk.Create()
if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{})
} else {
servers.ReportFormat(c, true, "获取成功", gin.H{})
}
}

86
QMPlusServer/docs/docs.go

@ -1,6 +1,6 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2019-10-26 23:18:53.1133875 +0800 CST m=+0.203566501
// 2019-11-20 10:46:22.2795763 +0800 CST m=+0.053896201
package docs
@ -1042,6 +1042,37 @@ var doc = `{
}
}
}
},
"/workflow/createWorkFlow": {
"post": {
"produces": [
"application/json"
],
"tags": [
"workflow"
],
"summary": "注册工作流",
"parameters": [
{
"description": "注册工作流接口",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/dbModel.Workflow"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"注册成功\"}",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {
@ -1220,6 +1251,59 @@ var doc = `{
}
}
},
"dbModel.Workflow": {
"type": "object",
"properties": {
"workflowDescription": {
"description": "工作流描述",
"type": "string"
},
"workflowName": {
"description": "工作流英文id",
"type": "string"
},
"workflowNickName": {
"description": "工作流名称",
"type": "string"
},
"workflowStep": {
"description": "工作流步骤",
"type": "array",
"items": {
"$ref": "#/definitions/dbModel.WorkflowStepInfo"
}
}
}
},
"dbModel.WorkflowStepInfo": {
"type": "object",
"properties": {
"isEnd": {
"description": "是否是完结流节点",
"type": "boolean"
},
"isStrat": {
"description": "是否是开始流节点",
"type": "boolean"
},
"stepAuthorityID": {
"description": "操作者级别id",
"type": "string"
},
"stepName": {
"description": "工作流名称",
"type": "string"
},
"stepNo": {
"description": "步骤id (第几步)",
"type": "number"
},
"workflowID": {
"description": "所属工作流ID",
"type": "integer"
}
}
},
"modelInterface.PageInfo": {
"type": "object",
"properties": {

84
QMPlusServer/docs/swagger.json

@ -1025,6 +1025,37 @@
}
}
}
},
"/workflow/createWorkFlow": {
"post": {
"produces": [
"application/json"
],
"tags": [
"workflow"
],
"summary": "注册工作流",
"parameters": [
{
"description": "注册工作流接口",
"name": "data",
"in": "body",
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/dbModel.Workflow"
}
}
],
"responses": {
"200": {
"description": "{\"success\":true,\"data\":{},\"msg\":\"注册成功\"}",
"schema": {
"type": "string"
}
}
}
}
}
},
"definitions": {
@ -1203,6 +1234,59 @@
}
}
},
"dbModel.Workflow": {
"type": "object",
"properties": {
"workflowDescription": {
"description": "工作流描述",
"type": "string"
},
"workflowName": {
"description": "工作流英文id",
"type": "string"
},
"workflowNickName": {
"description": "工作流名称",
"type": "string"
},
"workflowStep": {
"description": "工作流步骤",
"type": "array",
"items": {
"$ref": "#/definitions/dbModel.WorkflowStepInfo"
}
}
}
},
"dbModel.WorkflowStepInfo": {
"type": "object",
"properties": {
"isEnd": {
"description": "是否是完结流节点",
"type": "boolean"
},
"isStrat": {
"description": "是否是开始流节点",
"type": "boolean"
},
"stepAuthorityID": {
"description": "操作者级别id",
"type": "string"
},
"stepName": {
"description": "工作流名称",
"type": "string"
},
"stepNo": {
"description": "步骤id (第几步)",
"type": "number"
},
"workflowID": {
"description": "所属工作流ID",
"type": "integer"
}
}
},
"modelInterface.PageInfo": {
"type": "object",
"properties": {

58
QMPlusServer/docs/swagger.yaml

@ -112,6 +112,44 @@ definitions:
title:
type: string
type: object
dbModel.Workflow:
properties:
workflowDescription:
description: 工作流描述
type: string
workflowName:
description: 工作流英文id
type: string
workflowNickName:
description: 工作流名称
type: string
workflowStep:
description: 工作流步骤
items:
$ref: '#/definitions/dbModel.WorkflowStepInfo'
type: array
type: object
dbModel.WorkflowStepInfo:
properties:
isEnd:
description: 是否是完结流节点
type: boolean
isStrat:
description: 是否是开始流节点
type: boolean
stepAuthorityID:
description: 操作者级别id
type: string
stepName:
description: 工作流名称
type: string
stepNo:
description: 步骤id (第几步)
type: number
workflowID:
description: 所属工作流ID
type: integer
type: object
modelInterface.PageInfo:
properties:
page:
@ -753,6 +791,26 @@ paths:
summary: 用户上传头像
tags:
- User
/workflow/createWorkFlow:
post:
parameters:
- description: 注册工作流接口
in: body
name: data
required: true
schema:
$ref: '#/definitions/dbModel.Workflow'
type: object
produces:
- application/json
responses:
"200":
description: '{"success":true,"data":{},"msg":"注册成功"}'
schema:
type: string
summary: 注册工作流
tags:
- workflow
securityDefinitions:
ApiKeyAuth:
in: header

1
QMPlusServer/init/initRouter/initRouter.go

@ -21,5 +21,6 @@ func InitRouter() *gin.Engine {
router.InitAuthorityRouter(Router) // 注册角色路由
router.InitApiRouter(Router) // 注册功能api路由
router.InitFileUploadAndDownloadRouter(Router) // 文件上传下载功能路由
router.InitWorkflowRouter(Router) // 工作流相关路由
return Router
}

11
QMPlusServer/init/registTable/registTable.go

@ -7,5 +7,14 @@ import (
//注册数据库表专用
func RegistTable(db *gorm.DB) {
db.AutoMigrate(dbModel.User{}, dbModel.Authority{}, dbModel.Menu{}, dbModel.Api{}, dbModel.ApiAuthority{}, dbModel.BaseMenu{}, dbModel.FileUploadAndDownload{})
db.AutoMigrate(dbModel.User{},
dbModel.Authority{},
dbModel.Menu{},
dbModel.Api{},
dbModel.ApiAuthority{},
dbModel.BaseMenu{},
dbModel.FileUploadAndDownload{},
dbModel.Workflow{},
dbModel.WorkflowStepInfo{},
)
}

18
QMPlusServer/model/dbModel/application.go

@ -0,0 +1,18 @@
package dbModel
import (
"github.com/jinzhu/gorm"
"time"
)
//申请model 工作流实例
type Application struct {
gorm.Model
WorkFlowID string // 所属工作流ID
WorkFlowStepInfoID string // 当前节点ID
ApplicationName string // 申请人姓名
ApplicationCause string // 请假原因
ApplicationStartData time.Time // 请假开始日期
ApplicationEndData time.Time // 请假开始日期
}

36
QMPlusServer/model/dbModel/worfFlow.go

@ -2,47 +2,31 @@ package dbModel
import (
"github.com/jinzhu/gorm"
"time"
"main/init/qmsql"
)
type Application struct {
gorm.Model
WorkFlowID string // 所属工作流ID
WorkFlowStepInfoID string // 当前节点ID
ApplicationName string // 申请人姓名
ApplicationCause string // 请假原因
ApplicationStartData time.Time // 请假开始日期
ApplicationEndData time.Time // 请假开始日期
}
// 流转表
type ApplicationWorkFlowProcess struct {
gorm.Model
ApplicationID uint // 当前工作流所属申请的ID
CurrentNode string // 当前进度节点
HistoricalNode string //上一个进度节点
CurrentUser string // 当前进度操作人
HistoricalUser string // 上一个进度的操作人
State bool // 状态 是否是正在进行的状态
}
//工作流属性表
type Workflow struct {
gorm.Model
WorkflowNickName string // 工作流名称
WorkflowName string // 工作流英文id
WorkflowDescription string //工作流描述
WorkflowStep []WorkflowStepInfo //工作流步骤
WorkflowDescription string // 工作流描述
WorkflowStep []WorkflowStepInfo // 工作流步骤
}
// 工作流状态表
type WorkflowStepInfo struct {
gorm.Model
WorkflowID uint // 所属工作流ID
WorkflowID uint `json:"-"` // 所属工作流ID
IsStrat bool // 是否是开始流节点
StepName string // 工作流名称
StepNo float64 // 步骤id (第几步)
StepAuthorityID string // 操作者级别id
IsEnd bool // 是否是完结流节点
}
//创建工作流
func (wk *Workflow) Create() error {
err := qmsql.DEFAULTDB.Create(&wk).Error
return err
}

14
QMPlusServer/model/dbModel/workFlowProcess.go

@ -0,0 +1,14 @@
package dbModel
import "github.com/jinzhu/gorm"
// 工作流流转表
type WorkFlowProcess struct {
gorm.Model
ApplicationID uint // 当前工作流所属申请的ID
CurrentNode string // 当前进度节点
HistoricalNode string //上一个进度节点
CurrentUser string // 当前进度操作人
HistoricalUser string // 上一个进度的操作人
State bool // 状态 是否是正在进行的状态
}

14
QMPlusServer/router/workflow.go

@ -0,0 +1,14 @@
package router
import (
"github.com/gin-gonic/gin"
"main/controller/api"
)
func InitWorkflowRouter(Router *gin.Engine) {
WorkflowRouter := Router.Group("workflow")
//.Use(middleware.JWTAuth())
{
WorkflowRouter.POST("createWorkFlow", api.CreateWorkFlow) // 创建工作流
}
}
Loading…
Cancel
Save