WiiCITMS/models/oa/workflow_instance.go
2025-11-07 14:14:34 +08:00

53 lines
2.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package oa
import (
"WiiGoLibrary/framework/db/v1/utils/mssql/unique"
"WiiGoLibrary/framework/db/v1/utils/tool"
"WiiGoLibrary/framework/hub/v1/dblib"
"time"
)
// WorkflowInstanceTable 工作流实例表名
const WorkflowInstanceTable = "oa_u_workflow_instance"
// WorkflowInstanceModel 工作流实例模型
type WorkflowInstanceModel struct {
RecordGuid unique.UUID `gorm:"column:RecordGuid;type:UNIQUEIDENTIFIER;primaryKey;not null;default:newid();" json:"RecordGuid"`
InstanceID int64 `gorm:"column:InstanceID;type:BIGINT;not null;" json:"InstanceID"`
WorkflowGuid unique.UUID `gorm:"column:WorkflowGuid;type:UNIQUEIDENTIFIER;index;not null;" json:"WorkflowGuid"` // 关联的工作流定义
Title string `gorm:"column:Title;type:NVARCHAR(100);not null;" json:"Title"` // 实例标题
BusinessType int16 `gorm:"column:BusinessType;type:SMALLINT;not null;" json:"BusinessType"` // 业务类型: 1-请假, 2-报销, 3-采购, ...
BusinessID string `gorm:"column:BusinessID;type:NVARCHAR(50);not null;" json:"BusinessID"` // 业务ID如请假记录ID
InitiatorGuid unique.UUID `gorm:"column:InitiatorGuid;type:UNIQUEIDENTIFIER;not null;" json:"InitiatorGuid"` // 发起人
CurrentNodeID unique.UUID `gorm:"column:CurrentNodeID;type:UNIQUEIDENTIFIER;" json:"CurrentNodeID"` // 当前节点
Status int16 `gorm:"column:Status;type:SMALLINT;not null;default:0;" json:"Status"` // 状态: 0-进行中, 1-已完成, 2-已拒绝, 3-已取消
FormData string `gorm:"column:FormData;type:NVARCHAR(MAX);" json:"FormData"` // 表单数据(JSON)
RecordType int16 `gorm:"column:RecordType;not null;" json:"RecordType"`
RecordStatus int16 `gorm:"column:RecordStatus;not null;default:0;" json:"RecordStatus"`
CreateTime time.Time `gorm:"column:CreateTime;type:DATETIME;default:CURRENT_TIMESTAMP;<-:create;" json:"CreateTime"`
UpdateTime time.Time `gorm:"column:UpdateTime;type:DATETIME;default:CURRENT_TIMESTAMP;autoUpdateTime;" json:"UpdateTime"`
CompletionTime time.Time `gorm:"column:CompletionTime;type:DATETIME;" json:"CompletionTime"` // 完成时间
}
func init() {
dblib.DBIns.RegisterAutoMigrateModel(&WorkflowInstanceModel{})
}
// TableName 返回表名
func (wi *WorkflowInstanceModel) TableName() string {
return WorkflowInstanceTable
}
// WorkflowInstanceInstance 创建工作流实例
func WorkflowInstanceInstance() *WorkflowInstanceModel {
return &WorkflowInstanceModel{
RecordGuid: unique.NewV4(),
InstanceID: tool.GenerateID(),
WorkflowGuid: unique.NilUUID,
BusinessType: 0,
Status: 0, // 进行中
RecordType: 0,
RecordStatus: 0,
}
}