2025-09-28 01:53:09 +00:00
|
|
|
package entity
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"time"
|
2025-10-01 06:18:48 +00:00
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
2025-09-28 01:53:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ApprovalWorkflowSteps struct {
|
2025-10-01 06:18:48 +00:00
|
|
|
ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"`
|
|
|
|
|
WorkflowId uint `json:"workflow_id" gorm:"type:int4;not null"`
|
|
|
|
|
StepOrder int `json:"step_order" gorm:"type:int4;not null"`
|
|
|
|
|
StepName string `json:"step_name" gorm:"type:varchar;not null"`
|
|
|
|
|
RequiredUserLevelId uint `json:"required_user_level_id" gorm:"type:int4;not null"`
|
|
|
|
|
CanSkip *bool `json:"can_skip" gorm:"type:bool;default:false"`
|
|
|
|
|
AutoApproveAfterHours *int `json:"auto_approve_after_hours" gorm:"type:int4"`
|
|
|
|
|
IsActive *bool `json:"is_active" gorm:"type:bool;default:true"`
|
|
|
|
|
|
|
|
|
|
// Multi-branch support fields
|
|
|
|
|
ParentStepId *uint `json:"parent_step_id" gorm:"type:int4;references:approval_workflow_steps(id)"`
|
|
|
|
|
ConditionType *string `json:"condition_type" gorm:"type:varchar(50)"` // 'user_level', 'user_level_hierarchy', 'always', 'custom'
|
|
|
|
|
ConditionValue *string `json:"condition_value" gorm:"type:text"` // JSON string for conditions
|
|
|
|
|
IsParallel *bool `json:"is_parallel" gorm:"type:bool;default:false"`
|
|
|
|
|
BranchName *string `json:"branch_name" gorm:"type:varchar(100)"`
|
|
|
|
|
BranchOrder *int `json:"branch_order" gorm:"type:int4"` // Order within the same branch
|
|
|
|
|
|
|
|
|
|
ClientId *uuid.UUID `json:"client_id" gorm:"type:UUID"`
|
|
|
|
|
CreatedAt time.Time `json:"created_at" gorm:"default:now()"`
|
|
|
|
|
UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"`
|
2025-09-28 01:53:09 +00:00
|
|
|
|
|
|
|
|
// Relations
|
2025-10-01 06:18:48 +00:00
|
|
|
Workflow ApprovalWorkflows `json:"workflow" gorm:"foreignKey:WorkflowId;constraint:OnDelete:CASCADE"`
|
|
|
|
|
RequiredUserLevel UserLevels `json:"required_user_level" gorm:"foreignKey:RequiredUserLevelId"`
|
|
|
|
|
ParentStep *ApprovalWorkflowSteps `json:"parent_step" gorm:"foreignKey:ParentStepId"`
|
|
|
|
|
ChildSteps []ApprovalWorkflowSteps `json:"child_steps" gorm:"foreignKey:ParentStepId"`
|
|
|
|
|
}
|