package models

import "intent-system/pkg/utils"

type QAState int

const (
	QAState_Drafted   QAState = 0 //已存草稿
	QAState_Published QAState = 1 //已上架
	QAState_Removed   QAState = 2 //已下架
)

type OperType = string

const (
	OperType_Create OperType = "create"
	OperType_Edit   OperType = "edit"
	OperType_Delete OperType = "delete"
)

type ChangeLog struct {
	OperUser string   `json:"oper_user"`
	OperTime string   `json:"oper_time"`
	OperType OperType `json:"oper_type"`
}

func MakeChangeLog(logs []*ChangeLog, strUserName, strOperType OperType) []*ChangeLog {
	if logs == nil {
		logs = make([]*ChangeLog, 0)
	}
	strOperTime := utils.Now()
	logs = append(logs, &ChangeLog{
		OperUser: strUserName,
		OperTime: strOperTime,
		OperType: strOperType,
	})
	return logs
}

type CommonExtraData struct {
	Logs []*ChangeLog `json:"logs"`
}

type Privilege struct {
	Label    string        `json:"label" db:"label"`
	Name     string        `json:"name" db:"name"`
	Path     string        `json:"path" db:"path"`
	Children TreePrivilege `json:"children" db:"children"`
}

// 权限树结构
type TreePrivilege []Privilege

type SubscriberExtraData struct {
	UnsubscribeReason string `json:"unsubscribe_reason"`
}

type LanguageType = string

const (
	Language_Null LanguageType = ""
	Language_EN   LanguageType = "en"
	Language_CN   LanguageType = "zh-CN"
)

type TemplateType = int32

const (
	TemplateType_SubscriptionWelcome TemplateType = 1 //订阅欢迎邮件模板
)
