package entities

import (
	"time"
)

type ApprovalAction string

const (
	ApprovalActionApproved ApprovalAction = "APPROVED"
	ApprovalActionRejected ApprovalAction = "REJECTED"
	ApprovalActionCreated  ApprovalAction = "CREATED"
	ApprovalActionUpdated  ApprovalAction = "UPDATED"
)

type Approval struct {
	Id             uint            `gorm:"primaryKey"`
	ApprovableType string          `gorm:"size:50;not null;index:approvals_approvable_lookup,priority:1"`
	ApprovableId   uint            `gorm:"not null;index:approvals_approvable_lookup,priority:2"`
	StepNumber     uint16          `gorm:"not null"`
	StepName       string          `gorm:"not null"`
	Action         *ApprovalAction `gorm:"type:VARCHAR(20)"`
	Notes          *string         `gorm:"type:text"`
	ActionAt       time.Time       `gorm:"autoCreateTime"`
	ActionBy       *uint           `gorm:"index"`

	ActionUser *User `gorm:"foreignKey:ActionBy;references:Id"`
}
