service/erp/workflow.go

152 lines
4.6 KiB
Go
Raw Normal View History

2024-08-01 14:51:51 +08:00
package erp
import (
"context"
"git.kumo.work/shama/service/client"
2024-08-08 10:50:16 +08:00
workflow2 "git.kumo.work/shama/service/erp/workflow"
"git.kumo.work/shama/service/lib/bean"
"time"
2024-08-01 14:51:51 +08:00
)
type workflow struct {
2024-08-08 10:50:16 +08:00
workflow2.Workflow
2024-08-01 14:51:51 +08:00
}
2024-08-08 10:50:16 +08:00
type ArgsWorkflowList struct {
Page bean.Page
Search WorkflowSearch
2024-08-01 14:51:51 +08:00
}
2024-08-08 10:50:16 +08:00
type WorkflowSearch struct {
BusinessId int64 // 业务id
BusinessType string
Status AuditStatus
}
type ReplyWorkflowList struct {
List []WorkflowItem
Total int64
}
type WorkflowItem struct {
Id int64 `json:"id"` // 审批流id
BusinessId int64 `json:"businessId"` // 业务id
BusinessType string `json:"businessType"` // 业务类型
BusinessName string `json:"businessName"` // 业务名称
Title string `json:"title"` // 审批流标题
Content string `json:"content"` // 审批流内容
Status AuditStatus `json:"status"` // 审批流状态
2024-08-13 16:06:41 +08:00
ReviewComments string `json:"reviewComments"` // 审批意见
2024-08-08 10:50:16 +08:00
CreatedStaffId int64 `json:"createdStaffId"` // 创建人
CreatedAt *time.Time `json:"createdAt"` // 创建时间
2024-08-13 16:06:41 +08:00
UpdatedAt *time.Time `json:"updatedAt"` // 更新时间
2024-10-12 14:46:31 +08:00
Data string `json:"data"`
2024-08-08 10:50:16 +08:00
}
// List @TITLE 审核列表
func (w *workflow) List(ctx context.Context, args ArgsWorkflowList) (reply ReplyWorkflowList, err error) {
2024-08-01 14:51:51 +08:00
xClient, err := client.GetClient(w)
if err != nil {
return
}
2024-08-08 10:50:16 +08:00
err = xClient.Call(ctx, "List", args, &reply)
2024-08-01 14:51:51 +08:00
return
}
2024-08-08 10:50:16 +08:00
type ReplyWorkflowInfo struct {
Id int64 `json:"id"` // 审批流id
BusinessId int64 `json:"businessId"` // 业务id
BusinessType string `json:"businessType"` // 业务类型
BusinessName string `json:"businessName"` // 业务名称
Title string `json:"title"` // 审批流标题
Content string `json:"content"` // 审批流内容
Status AuditStatus `json:"status"` // 审批流状态
2024-08-13 16:06:41 +08:00
ReviewComments string `json:"reviewComments"` // 审批意见
2024-08-08 10:50:16 +08:00
CreatedStaffId int64 `json:"createdStaffId"` // 创建人
CreatedAt *time.Time `json:"createdAt"` // 创建时间
Nodes []WorkflowNodeItem `json:"nodes"`
}
type WorkflowNodeItem struct {
Id int64 `json:"id"` // 审批流节点id
Status AuditStatus `json:"status"` // 审批流节点状态
ReviewStaffId int64 `json:"reviewStaffId"` // 审批流节点审核人
ReviewAt *time.Time `json:"reviewAt"` // 审批流节点审核时间
ReviewComments string `json:"reviewComments"` // 审批流节点审核意见
Index int64 `json:"index"` // 审批流节点顺序
}
type ArgsWorkflowInfo struct {
WorkflowId int64 // 审批流id
WorkflowNodeId int64 // 审批流节点
2024-08-01 14:51:51 +08:00
}
2024-08-08 10:50:16 +08:00
// Info @TITLE 审核详情
func (w *workflow) Info(ctx context.Context, args ArgsWorkflowInfo) (reply ReplyWorkflowInfo, err error) {
2024-08-01 14:51:51 +08:00
xClient, err := client.GetClient(w)
if err != nil {
return
}
2024-08-08 10:50:16 +08:00
err = xClient.Call(ctx, "Info", args, &reply)
2024-08-01 14:51:51 +08:00
return
}
2024-08-08 14:53:20 +08:00
type ArgsWorkflowAdopt struct {
StaffId int64 // 审核人
WorkflowId int64 // 工作流
}
// Adopt @TITLE 审核通过
func (w *workflow) Adopt(ctx context.Context, args ArgsWorkflowAdopt) (err error) {
xClient, err := client.GetClient(w)
if err != nil {
return
}
reply := 0
err = xClient.Call(ctx, "Adopt", args, &reply)
return
}
type ArgsWorkflowReject struct {
StaffId int64 // 审核人
WorkflowId int64 // 工作流
Reason string // 审核结果
}
// Reject @TITLE 审核驳回
func (w *workflow) Reject(ctx context.Context, args ArgsWorkflowReject) (err error) {
xClient, err := client.GetClient(w)
if err != nil {
return
}
reply := 0
err = xClient.Call(ctx, "Reject", args, &reply)
return
}
2024-09-05 17:06:40 +08:00
type ReplyReviewNode struct {
ReviewStaffId int64 `json:"reviewStaffId"`
}
// ReviewNode @TITLE 获取审批节点
func (w *workflow) ReviewNode(ctx context.Context, workflowId int64) (reply ReplyReviewNode, err error) {
xClient, err := client.GetClient(w)
if err != nil {
return
}
err = xClient.Call(ctx, "ReviewNode", workflowId, &reply)
return
}
type ArgsWorkflowCancel struct {
StaffId int64 // 审核人
WorkflowId int64 // 工作流
}
// Cancel @TITLE 审核撤回
func (w *workflow) Cancel(ctx context.Context, args ArgsWorkflowCancel) (err error) {
xClient, err := client.GetClient(w)
if err != nil {
return
}
reply := 0
err = xClient.Call(ctx, "Cancel", args, &reply)
return
}