258 lines
8.9 KiB
Go
258 lines
8.9 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
// ====================================================================
|
|
// Adianti tables
|
|
|
|
type SystemGroup struct {
|
|
ID int `gorm:"primaryKey"`
|
|
Name string `gorm:"size:256"`
|
|
}
|
|
|
|
func (SystemGroup) TableName() string {
|
|
return "system_group"
|
|
}
|
|
|
|
type SystemProgram struct {
|
|
ID int `gorm:"primaryKey"`
|
|
Name string `gorm:"size:256"`
|
|
Controller string `gorm:"size:256"`
|
|
}
|
|
|
|
type SystemUnit struct {
|
|
ID int `gorm:"primaryKey"`
|
|
Name string `gorm:"size:256"`
|
|
ConnectionName string `gorm:"size:256"`
|
|
CustomCode string `gorm:"size:256"`
|
|
}
|
|
|
|
type SystemRole struct {
|
|
ID int `gorm:"primaryKey"`
|
|
Name string `gorm:"size:256"`
|
|
CustomCode string `gorm:"size:256"`
|
|
}
|
|
|
|
type SystemPreference struct {
|
|
ID string `gorm:"primaryKey;size:256"`
|
|
Value string `gorm:"type:citext"`
|
|
}
|
|
|
|
type SystemUser struct {
|
|
ID int `gorm:"primaryKey"`
|
|
Name string `gorm:"size:256"`
|
|
Login string `gorm:"size:256"`
|
|
Password string `gorm:"size:256"`
|
|
Email string `gorm:"size:256"`
|
|
AcceptedTermPolicy string `gorm:"size:1"`
|
|
Phone string `gorm:"size:256"`
|
|
Address string `gorm:"size:256"`
|
|
FunctionName string `gorm:"size:256"`
|
|
About string `gorm:"type:citext"`
|
|
AcceptedTermPolicyAt string `gorm:"size:20"`
|
|
AcceptedTermPolicyData string `gorm:"type:citext"`
|
|
FrontpageID int `gorm:"index"`
|
|
SystemUnitID int `gorm:"index"`
|
|
Active string `gorm:"size:1"`
|
|
CustomCode string `gorm:"size:256"`
|
|
OTPSecret string `gorm:"size:256"`
|
|
SystemUnit SystemUnit `gorm:"foreignKey:SystemUnitID"`
|
|
Frontpage SystemProgram `gorm:"foreignKey:FrontpageID"`
|
|
}
|
|
|
|
type SystemUserUnit struct {
|
|
ID int `gorm:"primaryKey"`
|
|
SystemUserID int
|
|
SystemUnitID int
|
|
SystemUser SystemUser `gorm:"foreignKey:SystemUserID"`
|
|
SystemUnit SystemUnit `gorm:"foreignKey:SystemUnitID"`
|
|
}
|
|
|
|
type SystemUserGroup struct {
|
|
ID int `gorm:"primaryKey"`
|
|
SystemUserID int
|
|
SystemGroupID int
|
|
SystemUser SystemUser `gorm:"foreignKey:SystemUserID"`
|
|
SystemGroup SystemGroup `gorm:"foreignKey:SystemGroupID"`
|
|
}
|
|
|
|
type SystemUserRole struct {
|
|
ID int `gorm:"primaryKey"`
|
|
SystemUserID int
|
|
SystemRoleID int
|
|
SystemUser SystemUser `gorm:"foreignKey:SystemUserID"`
|
|
SystemRole SystemRole `gorm:"foreignKey:SystemRoleID"`
|
|
}
|
|
|
|
type SystemGroupProgram struct {
|
|
ID int `gorm:"primaryKey"`
|
|
SystemGroupID int
|
|
SystemProgramID int
|
|
SystemGroup SystemGroup `gorm:"foreignKey:SystemGroupID"`
|
|
SystemProgram SystemProgram `gorm:"foreignKey:SystemProgramID"`
|
|
}
|
|
|
|
type SystemUserProgram struct {
|
|
ID int `gorm:"primaryKey"`
|
|
SystemUserID int
|
|
SystemProgramID int
|
|
SystemUser SystemUser `gorm:"foreignKey:SystemUserID"`
|
|
SystemProgram SystemProgram `gorm:"foreignKey:SystemProgramID"`
|
|
}
|
|
|
|
type SystemUserOldPassword struct {
|
|
ID int `gorm:"primaryKey"`
|
|
SystemUserID int
|
|
Password string `gorm:"size:256"`
|
|
CreatedAt string `gorm:"size:20"`
|
|
SystemUser SystemUser `gorm:"foreignKey:SystemUserID"`
|
|
}
|
|
|
|
type SystemProgramMethodRole struct {
|
|
ID int `gorm:"primaryKey"`
|
|
SystemProgramID int
|
|
SystemRoleID int
|
|
MethodName string `gorm:"size:256"`
|
|
SystemProgram SystemProgram `gorm:"foreignKey:SystemProgramID"`
|
|
SystemRole SystemRole `gorm:"foreignKey:SystemRoleID"`
|
|
}
|
|
|
|
// ====================================================================
|
|
// PCast tables
|
|
|
|
type Customer struct {
|
|
ID int32 `gorm:"primaryKey;autoIncrement;column:id"`
|
|
CNPJ string `gorm:"unique;column:cnpj"`
|
|
NIC string `gorm:"unique;column:nic"`
|
|
Nome string `gorm:"not null;column:nome"`
|
|
NomeFantasia string `gorm:"column:nome_fantasia"`
|
|
Tipo string `gorm:"column:tipo"`
|
|
Porte string `gorm:"column:porte"`
|
|
Situacao string `gorm:"column:situacao"`
|
|
Abertura string `gorm:"column:abertura"`
|
|
NaturezaJuridica string `gorm:"column:natureza_juridica"`
|
|
Logradouro string `gorm:"column:logradouro"`
|
|
Numero string `gorm:"column:numero"`
|
|
Complemento string `gorm:"column:complemento"`
|
|
Municipio string `gorm:"column:municipio"`
|
|
Bairro string `gorm:"column:bairro"`
|
|
UF string `gorm:"column:uf"`
|
|
CEP string `gorm:"column:cep"`
|
|
CustomerLocal string `gorm:"not null;column:customer_local"`
|
|
CustomerType string `gorm:"not null;column:customer_type"`
|
|
UserFullName string `gorm:"not null;column:userfullname"`
|
|
UserEmail string `gorm:"not null;column:useremail"`
|
|
UserName string `gorm:"not null;column:username"`
|
|
Password []byte `gorm:"not null;column:password"`
|
|
}
|
|
|
|
type Email struct {
|
|
ID int
|
|
Name string
|
|
EmailText string
|
|
}
|
|
|
|
// Server represents the servers table in the database
|
|
type Server struct {
|
|
ID uint `gorm:"primaryKey;column:id;autoIncrement"`
|
|
Name string `gorm:"column:name;type:text;not null"`
|
|
IP string `gorm:"column:ip;type:text;not null"`
|
|
Subdomain string `gorm:"column:subdomain;type:text;not null"`
|
|
|
|
// Relationship (back-reference)
|
|
Channels []Channel `gorm:"foreignKey:ServerID"`
|
|
}
|
|
|
|
// TableName overrides the table name
|
|
func (Server) TableName() string {
|
|
return "servers"
|
|
}
|
|
|
|
// Plan represents the plans table in the database
|
|
type Plan struct {
|
|
ID uint `gorm:"primaryKey;column:id;autoIncrement"`
|
|
Name string `gorm:"column:name;type:text;not null"`
|
|
DailyLimitTransmission int `gorm:"column:daily_limit_transmission;type:integer;not null"`
|
|
MonthValue float64 `gorm:"column:month_value;type:numeric(10,2);not null"`
|
|
YearValue float64 `gorm:"column:year_value;type:numeric(10,2);not null"`
|
|
|
|
// Relationship (back-reference)
|
|
Channels []Channel `gorm:"foreignKey:PlanID"`
|
|
}
|
|
|
|
// TableName overrides the table name
|
|
func (Plan) TableName() string {
|
|
return "plans"
|
|
}
|
|
|
|
// ChannelStat represents the channel_stats table in the database
|
|
type ChannelStat struct {
|
|
ID uint `gorm:"primaryKey;column:id;autoIncrement"`
|
|
Name string `gorm:"column:name;type:text;not null;uniqueIndex"`
|
|
Description string `gorm:"column:description;type:text;not null"`
|
|
|
|
// Relationship (back-reference)
|
|
Channels []Channel `gorm:"foreignKey:ChannelStatID"`
|
|
}
|
|
|
|
// TableName overrides the table name
|
|
func (ChannelStat) TableName() string {
|
|
return "channel_stats"
|
|
}
|
|
|
|
type Channel struct {
|
|
ID uint `gorm:"primaryKey;column:id;autoIncrement"`
|
|
Name string `gorm:"column:name;type:text;not null;uniqueIndex"`
|
|
TransmissionKey string `gorm:"column:transmission_key;type:text;not null;uniqueIndex"`
|
|
DateLimit time.Time `gorm:"column:date_limit;type:date;not null"`
|
|
CustomerID uint `gorm:"column:customer_id;not null"`
|
|
ServerID uint `gorm:"column:server_id;not null"`
|
|
PlanID uint `gorm:"column:plan_id;not null"`
|
|
Status string `gorm:"column:status;not null"`
|
|
|
|
// Define relationships
|
|
Customer Customer `gorm:"foreignKey:CustomerID;references:ID"`
|
|
Server Server `gorm:"foreignKey:ServerID;references:ID"`
|
|
Plan Plan `gorm:"foreignKey:PlanID;references:ID"`
|
|
}
|
|
|
|
// TableName overrides the table name
|
|
func (Channel) TableName() string {
|
|
return "channels"
|
|
}
|
|
|
|
// TransmissionLog represents the transmissionlog table in the database
|
|
type TransmissionLog struct {
|
|
ID uint `gorm:"primaryKey;column:id;autoIncrement"`
|
|
Datetime time.Time `gorm:"column:datetime;type:timestamp;not null"`
|
|
Channel string `gorm:"column:channel;type:text;not null"`
|
|
Message string `gorm:"column:message;type:text;not null"`
|
|
}
|
|
|
|
// TableName overrides the table name
|
|
func (TransmissionLog) TableName() string {
|
|
return "transmissionlog"
|
|
}
|
|
|
|
// Available on RAM during the execution
|
|
// CurrentTransmission represents the transmissions table in the database
|
|
type CurrentTransmission struct {
|
|
ID uint `gorm:"primaryKey;column:id;autoIncrement"`
|
|
Channel string `gorm:"column:channel;type:text;not null"`
|
|
CustomerID uint `gorm:"column:customer_id;not null"`
|
|
StartTime time.Time `gorm:"column:starttime;type:timestamp;not null"`
|
|
Duration int `gorm:"column:duration;not null"`
|
|
Limit time.Time `gorm:"-"`
|
|
SessionID string `gorm:"-"`
|
|
PlayerKey string `gorm:"-"`
|
|
PlanDailyLimit int `gorm:"-"`
|
|
Watchers int `gorm:"column:watchers;not null"`
|
|
Desktop int `gorm:"column:desktop;not null"`
|
|
Mobile int `gorm:"column:mobile;not null"`
|
|
}
|
|
|
|
// TableName overrides the table name
|
|
func (CurrentTransmission) TableName() string {
|
|
return "transmissions"
|
|
}
|