This commit is contained in:
panda
2023-03-29 22:08:53 +08:00
parent b9f0bd744c
commit b247985bbe
18 changed files with 529 additions and 50 deletions

View File

@@ -45,7 +45,7 @@ func (p *FlowWorkClassifyApi) GetFlowWorkClassify(rc *restfulx.ReqCtx) {
func (p *FlowWorkClassifyApi) InsertFlowWorkClassify(rc *restfulx.ReqCtx) {
var data entity.FlowWorkClassify
restfulx.BindQuery(rc, &data)
data.Creator = int(rc.LoginAccount.UserId)
p.FlowWorkClassifyApp.Insert(data)
}

View File

@@ -0,0 +1,66 @@
package api
// ==========================================================================
// 生成日期2023-03-29 20:01:11 +0800 CST
// 生成路径: apps/flow/api/flow_work_info.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 FlowWorkInfoApi struct {
FlowWorkInfoApp services.FlowWorkInfoModel
}
// GetFlowWorkInfoList WorkInfo列表数据
func (p *FlowWorkInfoApi) GetFlowWorkInfoList(rc *restfulx.ReqCtx) {
data := entity.FlowWorkInfo{}
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
data.Name = restfulx.QueryParam(rc, "name")
data.Icon = restfulx.QueryParam(rc, "icon")
list, total := p.FlowWorkInfoApp.FindListPage(pageNum, pageSize, data)
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}
// GetFlowWorkInfo 获取WorkInfo
func (p *FlowWorkInfoApi) GetFlowWorkInfo(rc *restfulx.ReqCtx) {
id := restfulx.PathParamInt(rc, "id")
rc.ResData = p.FlowWorkInfoApp.FindOne(int64(id))
}
// InsertFlowWorkInfo 添加WorkInfo
func (p *FlowWorkInfoApi) InsertFlowWorkInfo(rc *restfulx.ReqCtx) {
var data entity.FlowWorkInfo
restfulx.BindQuery(rc, &data)
data.Creator = int(rc.LoginAccount.UserId)
p.FlowWorkInfoApp.Insert(data)
}
// UpdateFlowWorkInfo 修改WorkInfo
func (p *FlowWorkInfoApi) UpdateFlowWorkInfo(rc *restfulx.ReqCtx) {
var data entity.FlowWorkInfo
restfulx.BindQuery(rc, &data)
p.FlowWorkInfoApp.Update(data)
}
// DeleteFlowWorkInfo 删除WorkInfo
func (p *FlowWorkInfoApi) DeleteFlowWorkInfo(rc *restfulx.ReqCtx) {
id := restfulx.PathParam(rc, "id")
ids := utils.IdsStrToIdsIntGroup(id)
p.FlowWorkInfoApp.Delete(ids)
}

View File

@@ -0,0 +1,64 @@
package api
// ==========================================================================
// 生成日期2023-03-29 19:46:55 +0800 CST
// 生成路径: apps/flow/api/flow_work_templates.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 FlowWorkTemplatesApi struct {
FlowWorkTemplatesApp services.FlowWorkTemplatesModel
}
// GetFlowWorkTemplatesList WorkTemplates列表数据
func (p *FlowWorkTemplatesApi) GetFlowWorkTemplatesList(rc *restfulx.ReqCtx) {
data := entity.FlowWorkTemplates{}
pageNum := restfulx.QueryInt(rc, "pageNum", 1)
pageSize := restfulx.QueryInt(rc, "pageSize", 10)
data.Name = restfulx.QueryParam(rc, "name")
list, total := p.FlowWorkTemplatesApp.FindListPage(pageNum, pageSize, data)
rc.ResData = model.ResultPage{
Total: total,
PageNum: int64(pageNum),
PageSize: int64(pageNum),
Data: list,
}
}
// GetFlowWorkTemplates 获取WorkTemplates
func (p *FlowWorkTemplatesApi) GetFlowWorkTemplates(rc *restfulx.ReqCtx) {
id := restfulx.PathParamInt(rc, "id")
rc.ResData = p.FlowWorkTemplatesApp.FindOne(int64(id))
}
// InsertFlowWorkTemplates 添加WorkTemplates
func (p *FlowWorkTemplatesApi) InsertFlowWorkTemplates(rc *restfulx.ReqCtx) {
var data entity.FlowWorkTemplates
restfulx.BindQuery(rc, &data)
data.Creator = int(rc.LoginAccount.UserId)
p.FlowWorkTemplatesApp.Insert(data)
}
// UpdateFlowWorkTemplates 修改WorkTemplates
func (p *FlowWorkTemplatesApi) UpdateFlowWorkTemplates(rc *restfulx.ReqCtx) {
var data entity.FlowWorkTemplates
restfulx.BindQuery(rc, &data)
p.FlowWorkTemplatesApp.Update(data)
}
// DeleteFlowWorkTemplates 删除WorkTemplates
func (p *FlowWorkTemplatesApi) DeleteFlowWorkTemplates(rc *restfulx.ReqCtx) {
id := restfulx.PathParam(rc, "id")
ids := utils.IdsStrToIdsIntGroup(id)
p.FlowWorkTemplatesApp.Delete(ids)
}

View File

@@ -5,8 +5,8 @@ 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"` // 创建者
Name string `gorm:"column:name; type: varchar(128)" json:"name"` // 分类名称
Creator int `gorm:"column:creator; type: int" json:"creator"` // 创建者
}
func (FlowWorkClassify) TableName() string {

View File

@@ -8,16 +8,13 @@ import (
// 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"` // 流程备注
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" json:"classify"` // 分类ID
SubmitCount int `gorm:"column:submit_count; type:int; default:0" json:"submitCount"` // 提交统计
Creator int `gorm:"column:creator; type:int" json:"creator"` // 创建者
Remarks string `gorm:"column:remarks; type:varchar(1024)" json:"remarks"` // 流程备注
}
func (FlowWorkInfo) TableName() string {

View File

@@ -8,17 +8,17 @@ import (
// 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"` // 上一次催促时间
Title string `gorm:"column:title; type:varchar(128)" json:"title"` // 工单标题
Priority int `gorm:"column:priority; type:int" json:"priority"` // 工单优先级 1正常 2紧急 3非常紧急
Process int `gorm:"column:process; type:int" json:"process"` // 流程ID
Classify int `gorm:"column:classify; type:int" json:"classify"` // 分类ID
IsEnd int `gorm:"column:is_end; type:int; default:0" json:"is_end"` // 是否结束, 0 未结束1 已结束
IsDenied int `gorm:"column:is_denied; type:int; 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" json:"creator"` // 创建人
UrgeCount int `gorm:"column:urge_count; type:int; default:0" json:"urge_count"` // 催办次数
UrgeLastTime int `gorm:"column:urge_last_time; type:int; default:0" json:"urge_last_time"` // 上一次催促时间
}
func (FlowWorkOrder) TableName() string {

View File

@@ -8,7 +8,7 @@ import (
// FlowWorkOrderTemplate 工单绑定模版数据
type FlowWorkOrderTemplate struct {
model.BaseAutoModel
WorkOrder int `gorm:"column:work_order; type: int(11)" json:"work_order"` // 工单ID
WorkOrder int `gorm:"column:work_order; type: int" 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"` // 表单数据
}

View File

@@ -7,17 +7,17 @@ import (
// 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"` // 备注
Title string `gorm:"column:title; type: varchar(128)" json:"title"` // 工单标题
WorkOrder int `gorm:"column:work_order; type: int" 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" json:"status"` // 流转状态 1 同意, 0 拒绝, 2 其他
Processor string `gorm:"column:processor; type: varchar(45)" json:"processor"` // 处理人
ProcessorId int `gorm:"column:processor_id; type: int" json:"processor_id"` // 处理人ID
CostDuration int64 `gorm:"column:cost_duration; type: int" json:"cost_duration"` // 处理时长
Remarks string `gorm:"column:remarks; type: text" json:"remarks"` // 备注
}
func (FlowWorkStage) TableName() string {

View File

@@ -9,9 +9,9 @@ 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"` // 备注
Content string `gorm:"column:content; type: text" json:"content"` // 任务内容
Creator int `gorm:"column:creator; type: int" json:"creator"` // 创建者
Remarks string `gorm:"column:remarks; type: text" json:"remarks"` // 备注
}
func (FlowWorkTask) TableName() string {
@@ -21,11 +21,11 @@ func (FlowWorkTask) TableName() string {
// FlowWorkTaskHistory 工作流任务执行历史
type FlowWorkTaskHistory struct {
model.BaseAutoModel
Task int `gorm:"column:task; type: int(11)" json:"task"` // 任务ID
Task int `gorm:"column:task; type: int" 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
TaskType int `gorm:"column:task_type; type: int" 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"` // 任务返回
Result string `gorm:"column:result; type: text" json:"result"` // 任务返回
}
func (FlowWorkTaskHistory) TableName() string {

View File

@@ -1,17 +1,16 @@
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"` // 备注
Name string `gorm:"column:name; type: varchar(128)" json:"name" binding:"required"` // 模板名称
FormStructure model.JSONB `gorm:"column:form_structure; type: json" json:"form_structure"` // 表单结构
Creator int `gorm:"column:creator; type: int" json:"creator"` // 创建者
Remarks string `gorm:"column:remarks; type: text" json:"remarks"` // 备注
}
func (FlowWorkTemplates) TableName() string {

View File

@@ -0,0 +1,70 @@
// ==========================================================================
// 生成日期2023-03-29 20:01:11 +0800 CST
// 生成路径: apps/flow/router/flow_work_info.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 InitFlowWorkInfoRouter(container *restful.Container) {
s := &api.FlowWorkInfoApi{
FlowWorkInfoApp: services.FlowWorkInfoModelDao,
}
ws := new(restful.WebService)
ws.Path("/flow/workinfo").Produces(restful.MIME_JSON)
tags := []string{"workinfo"}
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("获取WorkInfo分页列表").Handle(s.GetFlowWorkInfoList)
}).
Doc("获取WorkInfo分页列表").
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("获取WorkInfo信息").Handle(s.GetFlowWorkInfo)
}).
Doc("获取WorkInfo信息").
Param(ws.PathParameter("id", "Id").DataType("int")).
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(entity.FlowWorkInfo{}). // on the response
Returns(200, "OK", entity.FlowWorkInfo{}).
Returns(404, "Not Found", nil))
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("添加WorkInfo信息").Handle(s.InsertFlowWorkInfo)
}).
Doc("添加WorkInfo信息").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(entity.FlowWorkInfo{}))
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("修改WorkInfo信息").Handle(s.UpdateFlowWorkInfo)
}).
Doc("修改WorkInfo信息").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(entity.FlowWorkInfo{}))
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("删除WorkInfo信息").Handle(s.DeleteFlowWorkInfo)
}).
Doc("删除WorkInfo信息").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
container.Add(ws)
}

View File

@@ -0,0 +1,70 @@
// ==========================================================================
// 生成日期2023-03-29 19:46:55 +0800 CST
// 生成路径: apps/flow/router/flow_work_templates.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 InitFlowWorkTemplatesRouter(container *restful.Container) {
s := &api.FlowWorkTemplatesApi{
FlowWorkTemplatesApp: services.FlowWorkTemplatesModelDao,
}
ws := new(restful.WebService)
ws.Path("/flow/worktemplates").Produces(restful.MIME_JSON)
tags := []string{"worktemplates"}
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("获取WorkTemplates分页列表").Handle(s.GetFlowWorkTemplatesList)
}).
Doc("获取WorkTemplates分页列表").
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("获取WorkTemplates信息").Handle(s.GetFlowWorkTemplates)
}).
Doc("获取WorkTemplates信息").
Param(ws.PathParameter("id", "Id").DataType("int")).
Metadata(restfulspec.KeyOpenAPITags, tags).
Writes(entity.FlowWorkTemplates{}). // on the response
Returns(200, "OK", entity.FlowWorkTemplates{}).
Returns(404, "Not Found", nil))
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("添加WorkTemplates信息").Handle(s.InsertFlowWorkTemplates)
}).
Doc("添加WorkTemplates信息").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(entity.FlowWorkTemplates{}))
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("修改WorkTemplates信息").Handle(s.UpdateFlowWorkTemplates)
}).
Doc("修改WorkTemplates信息").
Metadata(restfulspec.KeyOpenAPITags, tags).
Reads(entity.FlowWorkTemplates{}))
ws.Route(ws.DELETE("/{id}").To(func(request *restful.Request, response *restful.Response) {
restfulx.NewReqCtx(request, response).WithLog("删除WorkTemplates信息").Handle(s.DeleteFlowWorkTemplates)
}).
Doc("删除WorkTemplates信息").
Metadata(restfulspec.KeyOpenAPITags, tags).
Param(ws.PathParameter("id", "多id 1,2,3").DataType("string")))
container.Add(ws)
}

View File

@@ -0,0 +1,101 @@
// ==========================================================================
// 生成日期2023-03-29 20:01:11 +0800 CST
// 生成路径: apps/flow/services/flow_work_info.go
// 生成人panda
// ==========================================================================
package services
import (
"github.com/XM-GO/PandaKit/biz"
"pandax/apps/flow/entity"
"pandax/pkg/global"
)
type (
FlowWorkInfoModel interface {
Insert(data entity.FlowWorkInfo) *entity.FlowWorkInfo
FindOne(id int64) *entity.FlowWorkInfo
FindListPage(page, pageSize int, data entity.FlowWorkInfo) (*[]entity.FlowWorkInfo, int64)
FindList(data entity.FlowWorkInfo) *[]entity.FlowWorkInfo
Update(data entity.FlowWorkInfo) *entity.FlowWorkInfo
Delete(ids []int64)
}
workinfoModelImpl struct {
table string
}
)
var FlowWorkInfoModelDao FlowWorkInfoModel = &workinfoModelImpl{
table: `flow_work_info`,
}
func (m *workinfoModelImpl) Insert(data entity.FlowWorkInfo) *entity.FlowWorkInfo {
err := global.Db.Table(m.table).Create(&data).Error
biz.ErrIsNil(err, "添加流程失败")
return &data
}
func (m *workinfoModelImpl) FindOne(id int64) *entity.FlowWorkInfo {
resData := new(entity.FlowWorkInfo)
db := global.Db.Table(m.table).Where("id = ?", id)
err := db.First(resData).Error
biz.ErrIsNil(err, "查询流程失败")
return resData
}
func (m *workinfoModelImpl) FindListPage(page, pageSize int, data entity.FlowWorkInfo) (*[]entity.FlowWorkInfo, int64) {
list := make([]entity.FlowWorkInfo, 0)
var total int64 = 0
offset := pageSize * (page - 1)
db := global.Db.Table(m.table)
// 此处填写 where参数判断
db.Where("delete_time IS NULL")
if data.Name != "" {
db = db.Where("name like ?", "%"+data.Name+"%")
}
if data.Creator != 0 {
db = db.Where("creator = ?", data.Creator)
}
if data.Remarks != "" {
db = db.Where("remarks like ?", "%"+data.Remarks+"%")
}
if data.Classify != 0 {
db = db.Where("classify = ?", data.Classify)
}
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 *workinfoModelImpl) FindList(data entity.FlowWorkInfo) *[]entity.FlowWorkInfo {
list := make([]entity.FlowWorkInfo, 0)
db := global.Db.Table(m.table)
// 此处填写 where参数判断
db.Where("delete_time IS NULL")
if data.Name != "" {
db = db.Where("name like ?", "%"+data.Name+"%")
}
if data.Creator != 0 {
db = db.Where("creator = ?", data.Creator)
}
if data.Remarks != "" {
db = db.Where("remarks like ?", "%"+data.Remarks+"%")
}
if data.Classify != 0 {
db = db.Where("classify = ?", data.Classify)
}
biz.ErrIsNil(db.Order("create_time").Find(&list).Error, "查询流程列表失败")
return &list
}
func (m *workinfoModelImpl) Update(data entity.FlowWorkInfo) *entity.FlowWorkInfo {
biz.ErrIsNil(global.Db.Table(m.table).Updates(&data).Error, "修改流程失败")
return &data
}
func (m *workinfoModelImpl) Delete(ids []int64) {
biz.ErrIsNil(global.Db.Table(m.table).Delete(&entity.FlowWorkInfo{}, "id in (?)", ids).Error, "删除流程失败")
}

View File

@@ -0,0 +1,106 @@
// ==========================================================================
// 生成日期2023-03-29 19:46:55 +0800 CST
// 生成路径: apps/flow/services/flow_work_templates.go
// 生成人panda
// ==========================================================================
package services
import (
"github.com/XM-GO/PandaKit/biz"
"pandax/apps/flow/entity"
"pandax/pkg/global"
)
type (
FlowWorkTemplatesModel interface {
Insert(data entity.FlowWorkTemplates) *entity.FlowWorkTemplates
FindOne(id int64) *entity.FlowWorkTemplates
FindListPage(page, pageSize int, data entity.FlowWorkTemplates) (*[]entity.FlowWorkTemplates, int64)
FindList(data entity.FlowWorkTemplates) *[]entity.FlowWorkTemplates
Update(data entity.FlowWorkTemplates) *entity.FlowWorkTemplates
Delete(ids []int64)
}
worktemplatesModelImpl struct {
table string
}
)
var FlowWorkTemplatesModelDao FlowWorkTemplatesModel = &worktemplatesModelImpl{
table: `flow_work_templates`,
}
func (m *worktemplatesModelImpl) Insert(data entity.FlowWorkTemplates) *entity.FlowWorkTemplates {
err := global.Db.Table(m.table).Create(&data).Error
biz.ErrIsNil(err, "添加工作流模板失败")
return &data
}
func (m *worktemplatesModelImpl) FindOne(id int64) *entity.FlowWorkTemplates {
resData := new(entity.FlowWorkTemplates)
db := global.Db.Table(m.table).Where("id = ?", id)
err := db.First(resData).Error
biz.ErrIsNil(err, "查询工作流模板失败")
return resData
}
func (m *worktemplatesModelImpl) FindListPage(page, pageSize int, data entity.FlowWorkTemplates) (*[]entity.FlowWorkTemplates, int64) {
list := make([]entity.FlowWorkTemplates, 0)
var total int64 = 0
offset := pageSize * (page - 1)
db := global.Db.Table(m.table)
// 此处填写 where参数判断
if data.Remarks != "" {
db = db.Where("remarks = ?", data.Remarks)
}
db.Where("delete_time IS NULL")
if data.Name != "" {
db = db.Where("name like ?", "%"+data.Name+"%")
}
if data.Creator != 0 {
db = db.Where("creator = ?", data.Creator)
}
if data.Remarks != "" {
db = db.Where("name like ?", "%"+data.Remarks+"%")
}
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 *worktemplatesModelImpl) FindList(data entity.FlowWorkTemplates) *[]entity.FlowWorkTemplates {
list := make([]entity.FlowWorkTemplates, 0)
db := global.Db.Table(m.table)
// 此处填写 where参数判断
if data.Remarks != "" {
db = db.Where("remarks = ?", data.Remarks)
}
db.Where("delete_time IS NULL")
if data.Name != "" {
db = db.Where("name like ?", "%"+data.Name+"%")
}
if data.Creator != 0 {
db = db.Where("creator = ?", data.Creator)
}
if data.Remarks != "" {
db = db.Where("name like ?", "%"+data.Remarks+"%")
}
biz.ErrIsNil(db.Order("create_time").Find(&list).Error, "查询工作流模板列表失败")
return &list
}
func (m *worktemplatesModelImpl) Update(data entity.FlowWorkTemplates) *entity.FlowWorkTemplates {
err := global.Db.Table(m.table).Updates(&data).Error
if err != nil {
global.Log.Error(err)
biz.ErrIsNil(global.Db.Table(m.table).Updates(&data).Error, "修改工作流模板失败")
}
return &data
}
func (m *worktemplatesModelImpl) Delete(ids []int64) {
biz.ErrIsNil(global.Db.Table(m.table).Delete(&entity.FlowWorkTemplates{}, "id in (?)", ids).Error, "删除工作流模板失败")
}