package models

import (
	"github.com/beego/beego/v2/client/orm"
	"time"
)

type StatusType string
type SourceType string
type MetaType string

const (
	UserNoticeType    MetaType   = "USER_NOTICE"
	InitStatusType    StatusType = "INIT"
	PendingStatusType StatusType = "PENDING"
	FinishStatusType  StatusType = "FINISH"
	FailedStatusType  StatusType = "FAILED"

	ReportSourceType SourceType = "REPORT"
	VideoSourceType  SourceType = "VIDEO"
	AudioSourceType  SourceType = "AUDIO"
)

// MetaInfo 表示 meta_infos 表的模型
type MetaInfo struct {
	Id          int        `description:"id"`
	Uid         string     `description:"uid"`
	Meta        string     `description:"meta"`
	From        string     `description:"from"`
	To          string     `description:"column:to"`
	SourceType  SourceType `description:"source_type"`
	MetaType    MetaType   `gorm:"column:meta_type;type:enum('USER_NOTICE')"`
	Status      StatusType `gorm:"column:status;type:enum('INIT','PENDING','FINISH','FAILED')"`
	CreatedTime time.Time
	UpdatedTime time.Time
}

type MetaData struct {
	SourceId      int    `json:"reportId"`
	AuthorId      int    `json:"AuthorId"`
	AuthorName    string `json:"authorName"`
	PublishedTime string `json:"publishedTime"`
}

func (m *MetaInfo) TableName() string {
	return "meta_infos"
}
func (m *MetaInfo) Insert() (insert int64, err error) {
	o := orm.NewOrm()
	insert, err = o.Insert(m)
	return
}
