package model

import (
	"time"

	"gorm.io/datatypes"
)

// WeComApprovalScene 保存稳定业务类型到企微后台模板及控件映射的当前配置。
type WeComApprovalScene struct {
	ID                  uint           `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
	BusinessType        string         `gorm:"column:business_type;type:varchar(64);not null;uniqueIndex" json:"business_type"`
	ApplicationID       uint           `gorm:"column:application_id;not null;index" json:"application_id"`
	TemplateID          string         `gorm:"column:template_id;type:varchar(128);not null" json:"template_id"`
	TemplateName        string         `gorm:"column:template_name;type:varchar(255);not null;default:''" json:"template_name"`
	ControlMapping      datatypes.JSON `gorm:"column:control_mapping;type:jsonb;not null" json:"control_mapping"`
	TemplateSnapshot    datatypes.JSON `gorm:"column:template_snapshot;type:jsonb;not null" json:"template_snapshot"`
	TemplateFingerprint string         `gorm:"column:template_fingerprint;type:char(64);not null" json:"template_fingerprint"`
	Status              int            `gorm:"column:status;type:int;not null;default:1" json:"status"`
	LastVerifiedAt      time.Time      `gorm:"column:last_verified_at;type:timestamptz;not null" json:"last_verified_at"`
	CreatedBy           uint           `gorm:"column:created_by;not null" json:"created_by"`
	UpdatedBy           uint           `gorm:"column:updated_by;not null" json:"updated_by"`
	CreatedAt           time.Time      `gorm:"column:created_at;type:timestamptz;not null;autoCreateTime" json:"created_at"`
	UpdatedAt           time.Time      `gorm:"column:updated_at;type:timestamptz;not null;autoUpdateTime" json:"updated_at"`
}

// TableName 指定企业微信审批场景配置表名。
func (WeComApprovalScene) TableName() string {
	return "tb_wecom_approval_scene"
}
