mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 02:48:34 +08:00
规则引擎
This commit is contained in:
@@ -1,65 +0,0 @@
|
||||
package api
|
||||
|
||||
// ==========================================================================
|
||||
// 生成日期:2022-08-24 22:02:33 +0800 CST
|
||||
// 生成路径: apps/flow/api/flow_work_classify.go
|
||||
// 生成人:panda
|
||||
// ==========================================================================
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
|
||||
"github.com/XM-GO/PandaKit/utils"
|
||||
"pandax/apps/flow/entity"
|
||||
"pandax/apps/flow/services"
|
||||
)
|
||||
|
||||
type FlowWorkClassifyApi struct {
|
||||
FlowWorkClassifyApp services.FlowWorkClassifyModel
|
||||
}
|
||||
|
||||
// GetFlowWorkClassifyList Classify列表数据
|
||||
func (p *FlowWorkClassifyApi) GetFlowWorkClassifyList(rc *restfulx.ReqCtx) {
|
||||
data := entity.FlowWorkClassify{}
|
||||
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
|
||||
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
|
||||
data.Name = restfulx.QueryParam(rc, "name")
|
||||
|
||||
list, total := p.FlowWorkClassifyApp.FindListPage(pageNum, pageSize, data)
|
||||
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
PageSize: int64(pageNum),
|
||||
Data: list,
|
||||
}
|
||||
}
|
||||
|
||||
// GetFlowWorkClassify 获取Classify
|
||||
func (p *FlowWorkClassifyApi) GetFlowWorkClassify(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParamInt(rc, "id")
|
||||
p.FlowWorkClassifyApp.FindOne(int64(id))
|
||||
}
|
||||
|
||||
// InsertFlowWorkClassify 添加Classify
|
||||
func (p *FlowWorkClassifyApi) InsertFlowWorkClassify(rc *restfulx.ReqCtx) {
|
||||
var data entity.FlowWorkClassify
|
||||
restfulx.BindQuery(rc, &data)
|
||||
|
||||
p.FlowWorkClassifyApp.Insert(data)
|
||||
}
|
||||
|
||||
// UpdateFlowWorkClassify 修改Classify
|
||||
func (p *FlowWorkClassifyApi) UpdateFlowWorkClassify(rc *restfulx.ReqCtx) {
|
||||
var data entity.FlowWorkClassify
|
||||
restfulx.BindQuery(rc, &data)
|
||||
|
||||
p.FlowWorkClassifyApp.Update(data)
|
||||
}
|
||||
|
||||
// DeleteFlowWorkClassify 删除Classify
|
||||
func (p *FlowWorkClassifyApi) DeleteFlowWorkClassify(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.PathParam(rc, "id")
|
||||
ids := utils.IdsStrToIdsIntGroup(id)
|
||||
p.FlowWorkClassifyApp.Delete(ids)
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package entity
|
||||
|
||||
import "github.com/XM-GO/PandaKit/model"
|
||||
|
||||
// FlowWorkClassify 工作流流程分类
|
||||
type FlowWorkClassify struct {
|
||||
model.BaseAutoModel
|
||||
Name string `gorm:"column:name; type: varchar(128)" json:"name"` // 分类名称
|
||||
Creator int `gorm:"column:creator; type: int(11)" json:"creator"` // 创建者
|
||||
}
|
||||
|
||||
func (FlowWorkClassify) TableName() string {
|
||||
return "flow_work_classify"
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
)
|
||||
|
||||
// FlowWorkInfo 工作流信息
|
||||
type FlowWorkInfo struct {
|
||||
model.BaseAutoModel
|
||||
Name string `gorm:"column:name; type:varchar(128)" json:"name"` // 流程名称
|
||||
Icon string `gorm:"column:icon; type:varchar(128)" json:"icon" ` // 流程标签
|
||||
Structure json.RawMessage `gorm:"column:structure; type:json" json:"structure" ` // 流程结构
|
||||
Classify int `gorm:"column:classify; type:int(11)" json:"classify"` // 分类ID
|
||||
Templates json.RawMessage `gorm:"column:templates; type:json" json:"templates"` // 模版
|
||||
Task json.RawMessage `gorm:"column:task; type:json" json:"task"` // 任务ID, array, 可执行多个任务,可以当成通知任务,每个节点都会去执行
|
||||
SubmitCount int `gorm:"column:submit_count; type:int(11); default:0" json:"submitCount"` // 提交统计
|
||||
Creator int `gorm:"column:creator; type:int(11)" json:"creator"` // 创建者
|
||||
Notice json.RawMessage `gorm:"column:notice; type:json" json:"notice"` // 绑定通知
|
||||
Remarks string `gorm:"column:remarks; type:varchar(1024)" json:"remarks"` // 流程备注
|
||||
}
|
||||
|
||||
func (FlowWorkInfo) TableName() string {
|
||||
return "flow_work_info"
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
)
|
||||
|
||||
// FlowWorkOrder 工作流工单
|
||||
type FlowWorkOrder struct {
|
||||
model.BaseAutoModel
|
||||
Title string `gorm:"column:title; type:varchar(128)" json:"title"` // 工单标题
|
||||
Priority int `gorm:"column:priority; type:int(11)" json:"priority"` // 工单优先级 1,正常 2,紧急 3,非常紧急
|
||||
Process int `gorm:"column:process; type:int(11)" json:"process"` // 流程ID
|
||||
Classify int `gorm:"column:classify; type:int(11)" json:"classify"` // 分类ID
|
||||
IsEnd int `gorm:"column:is_end; type:int(11); default:0" json:"is_end"` // 是否结束, 0 未结束,1 已结束
|
||||
IsDenied int `gorm:"column:is_denied; type:int(11); default:0" json:"is_denied"` // 是否被拒绝, 0 没有,1 有
|
||||
State json.RawMessage `gorm:"column:state; type:json" json:"state"` // 状态信息
|
||||
RelatedPerson json.RawMessage `gorm:"column:related_person; type:json" json:"related_person"` // 工单所有处理人
|
||||
Creator int `gorm:"column:creator; type:int(11)" json:"creator"` // 创建人
|
||||
UrgeCount int `gorm:"column:urge_count; type:int(11); default:0" json:"urge_count"` // 催办次数
|
||||
UrgeLastTime int `gorm:"column:urge_last_time; type:int(11); default:0" json:"urge_last_time"` // 上一次催促时间
|
||||
}
|
||||
|
||||
func (FlowWorkOrder) TableName() string {
|
||||
return "flow_work_order"
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
)
|
||||
|
||||
// FlowWorkOrderTemplate 工单绑定模版数据
|
||||
type FlowWorkOrderTemplate struct {
|
||||
model.BaseAutoModel
|
||||
WorkOrder int `gorm:"column:work_order; type: int(11)" json:"work_order"` // 工单ID
|
||||
FormStructure json.RawMessage `gorm:"column:form_structure; type: json" json:"form_structure"` // 表单结构
|
||||
FormData json.RawMessage `gorm:"column:form_data; type: json" json:"form_data"` // 表单数据
|
||||
}
|
||||
|
||||
func (FlowWorkOrderTemplate) TableName() string {
|
||||
return "flow_work_order_templates"
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
)
|
||||
|
||||
// FlowWorkStage 工作流工序(流转历史)
|
||||
type FlowWorkStage struct {
|
||||
model.BaseAutoModel
|
||||
Title string `gorm:"column:title; type: varchar(128)" json:"title"` // 工单标题
|
||||
WorkOrder int `gorm:"column:work_order; type: int(11)" json:"work_order"` // 工单ID
|
||||
State string `gorm:"column:state; type: varchar(128)" json:"state"` // 工单状态
|
||||
Source string `gorm:"column:source; type: varchar(128)" json:"source"` // 源节点ID
|
||||
Target string `gorm:"column:target; type: varchar(128)" json:"target"` // 目标节点ID
|
||||
Stage string `gorm:"column:stage; type: varchar(128)" json:"stage"` // 流转ID
|
||||
Status int `gorm:"column:status; type: int(11)" json:"status"` // 流转状态 1 同意, 0 拒绝, 2 其他
|
||||
Processor string `gorm:"column:processor; type: varchar(45)" json:"processor"` // 处理人
|
||||
ProcessorId int `gorm:"column:processor_id; type: int(11)" json:"processor_id"` // 处理人ID
|
||||
CostDuration int64 `gorm:"column:cost_duration; type: int(11)" json:"cost_duration"` // 处理时长
|
||||
Remarks string `gorm:"column:remarks; type: longtext" json:"remarks"` // 备注
|
||||
}
|
||||
|
||||
func (FlowWorkStage) TableName() string {
|
||||
return "flow_work_stage"
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
)
|
||||
|
||||
// FlowWorkTask 工作流任务
|
||||
type FlowWorkTask struct {
|
||||
model.BaseAutoModel
|
||||
Name string `gorm:"column:name; type: varchar(256)" json:"name"` // 任务名称
|
||||
TaskType string `gorm:"column:task_type; type: varchar(45)" json:"task_type"` // 任务类型
|
||||
Content string `gorm:"column:content; type: longtext" json:"content"` // 任务内容
|
||||
Creator int `gorm:"column:creator; type: int(11)" json:"creator"` // 创建者
|
||||
Remarks string `gorm:"column:remarks; type: longtext" json:"remarks"` // 备注
|
||||
}
|
||||
|
||||
func (FlowWorkTask) TableName() string {
|
||||
return "flow_work_task"
|
||||
}
|
||||
|
||||
// FlowWorkTaskHistory 工作流任务执行历史
|
||||
type FlowWorkTaskHistory struct {
|
||||
model.BaseAutoModel
|
||||
Task int `gorm:"column:task; type: int(11)" json:"task"` // 任务ID
|
||||
Name string `gorm:"column:name; type: varchar(256)" json:"name"` // 任务名称
|
||||
TaskType int `gorm:"column:task_type; type: int(11)" json:"task_type"` // 任务类型, python, shell
|
||||
ExecutionTime string `gorm:"column:execution_time; type: varchar(128)" json:"execution_time"` // 执行时间
|
||||
Result string `gorm:"column:result; type: longtext" json:"result"` // 任务返回
|
||||
}
|
||||
|
||||
func (FlowWorkTaskHistory) TableName() string {
|
||||
return "flow_work_task_history"
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package entity
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
)
|
||||
|
||||
// FlowWorkTemplates 工作流表单模板
|
||||
type FlowWorkTemplates struct {
|
||||
model.BaseAutoModel
|
||||
Name string `gorm:"column:name; type: varchar(128)" json:"name" binding:"required"` // 模板名称
|
||||
FormStructure json.RawMessage `gorm:"column:form_structure; type: json" json:"form_structure" binding:"required"` // 表单结构
|
||||
Creator int `gorm:"column:creator; type: int(11)" json:"creator"` // 创建者
|
||||
Remarks string `gorm:"column:remarks; type: longtext" json:"remarks"` // 备注
|
||||
}
|
||||
|
||||
func (FlowWorkTemplates) TableName() string {
|
||||
return "flow_work_templates"
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
// ==========================================================================
|
||||
// 生成日期:2022-08-24 22:02:33 +0800 CST
|
||||
// 生成路径: apps/flow/router/flow_work_classify.go
|
||||
// 生成人:panda
|
||||
// ==========================================================================
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/model"
|
||||
"github.com/XM-GO/PandaKit/restfulx"
|
||||
"pandax/apps/flow/api"
|
||||
"pandax/apps/flow/entity"
|
||||
"pandax/apps/flow/services"
|
||||
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
)
|
||||
|
||||
func InitFlowWorkClassifyRouter(container *restful.Container) {
|
||||
s := &api.FlowWorkClassifyApi{
|
||||
FlowWorkClassifyApp: services.FlowWorkClassifyModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/flow/workclassify").Produces(restful.MIME_JSON)
|
||||
tags := []string{"workclassify"}
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Classify分页列表").Handle(s.GetFlowWorkClassifyList)
|
||||
}).
|
||||
Doc("获取Classify分页列表").
|
||||
Param(ws.QueryParameter("pageNum", "页数").Required(true).DataType("int")).
|
||||
Param(ws.QueryParameter("pageSize", "每页条数").Required(true).DataType("int")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(model.ResultPage{}).
|
||||
Returns(200, "OK", model.ResultPage{}))
|
||||
|
||||
ws.Route(ws.GET("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取Classify信息").Handle(s.GetFlowWorkClassify)
|
||||
}).
|
||||
Doc("获取Classify信息").
|
||||
Param(ws.PathParameter("id", "Id").DataType("int")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.FlowWorkClassify{}). // on the response
|
||||
Returns(200, "OK", entity.FlowWorkClassify{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加Classify信息").Handle(s.InsertFlowWorkClassify)
|
||||
}).
|
||||
Doc("添加Classify信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.FlowWorkClassify{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改Classify信息").Handle(s.UpdateFlowWorkClassify)
|
||||
}).
|
||||
Doc("修改Classify信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.FlowWorkClassify{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除Classify信息").Handle(s.DeleteFlowWorkClassify)
|
||||
}).
|
||||
Doc("删除Classify信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
|
||||
|
||||
container.Add(ws)
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
// ==========================================================================
|
||||
// 生成日期:2022-08-24 22:02:33 +0800 CST
|
||||
// 生成路径: apps/flow/services/flow_work_classify.go
|
||||
// 生成人:panda
|
||||
// ==========================================================================
|
||||
|
||||
package services
|
||||
|
||||
import (
|
||||
"github.com/XM-GO/PandaKit/biz"
|
||||
"pandax/apps/flow/entity"
|
||||
"pandax/pkg/global"
|
||||
)
|
||||
|
||||
type (
|
||||
FlowWorkClassifyModel interface {
|
||||
Insert(data entity.FlowWorkClassify) *entity.FlowWorkClassify
|
||||
FindOne(id int64) *entity.FlowWorkClassify
|
||||
FindListPage(page, pageSize int, data entity.FlowWorkClassify) (*[]entity.FlowWorkClassify, int64)
|
||||
FindList(data entity.FlowWorkClassify) *[]entity.FlowWorkClassify
|
||||
Update(data entity.FlowWorkClassify) *entity.FlowWorkClassify
|
||||
Delete(ids []int64)
|
||||
}
|
||||
|
||||
workclassifyModelImpl struct {
|
||||
table string
|
||||
}
|
||||
)
|
||||
|
||||
var FlowWorkClassifyModelDao FlowWorkClassifyModel = &workclassifyModelImpl{
|
||||
table: `flow_work_classify`,
|
||||
}
|
||||
|
||||
func (m *workclassifyModelImpl) Insert(data entity.FlowWorkClassify) *entity.FlowWorkClassify {
|
||||
err := global.Db.Table(m.table).Create(&data).Error
|
||||
biz.ErrIsNil(err, "添加工作流分类失败")
|
||||
return &data
|
||||
}
|
||||
|
||||
func (m *workclassifyModelImpl) FindOne(id int64) *entity.FlowWorkClassify {
|
||||
resData := new(entity.FlowWorkClassify)
|
||||
db := global.Db.Table(m.table).Where("id = ?", id)
|
||||
err := db.First(resData).Error
|
||||
biz.ErrIsNil(err, "查询工作流分类失败")
|
||||
return resData
|
||||
}
|
||||
|
||||
func (m *workclassifyModelImpl) FindListPage(page, pageSize int, data entity.FlowWorkClassify) (*[]entity.FlowWorkClassify, int64) {
|
||||
list := make([]entity.FlowWorkClassify, 0)
|
||||
var total int64 = 0
|
||||
offset := pageSize * (page - 1)
|
||||
db := global.Db.Table(m.table)
|
||||
// 此处填写 where参数判断
|
||||
if data.Name != "" {
|
||||
db = db.Where("name like ?", "%"+data.Name+"%")
|
||||
}
|
||||
if data.Creator != 0 {
|
||||
db = db.Where("creator = ?", data.Creator)
|
||||
}
|
||||
err := db.Count(&total).Error
|
||||
err = db.Order("create_time").Limit(pageSize).Offset(offset).Find(&list).Error
|
||||
biz.ErrIsNil(err, "查询工作流分类分页列表失败")
|
||||
return &list, total
|
||||
}
|
||||
|
||||
func (m *workclassifyModelImpl) FindList(data entity.FlowWorkClassify) *[]entity.FlowWorkClassify {
|
||||
list := make([]entity.FlowWorkClassify, 0)
|
||||
db := global.Db.Table(m.table)
|
||||
// 此处填写 where参数判断
|
||||
if data.Name != "" {
|
||||
db = db.Where("name like ?", "%"+data.Name+"%")
|
||||
}
|
||||
if data.Creator != 0 {
|
||||
db = db.Where("creator = ?", data.Creator)
|
||||
}
|
||||
biz.ErrIsNil(db.Order("create_time").Find(&list).Error, "查询工作流分类列表失败")
|
||||
return &list
|
||||
}
|
||||
|
||||
func (m *workclassifyModelImpl) Update(data entity.FlowWorkClassify) *entity.FlowWorkClassify {
|
||||
biz.ErrIsNil(global.Db.Table(m.table).Updates(&data).Error, "修改工作流分类失败")
|
||||
return &data
|
||||
}
|
||||
|
||||
func (m *workclassifyModelImpl) Delete(ids []int64) {
|
||||
biz.ErrIsNil(global.Db.Table(m.table).Delete(&entity.FlowWorkClassify{}, "id in (?)", ids).Error, "删除工作流分类失败")
|
||||
}
|
||||
Reference in New Issue
Block a user