2018-05-17 18:35:53 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
// Connection model
|
|
|
|
type Connection struct {
|
|
|
|
ID int `gorm:"primary_key"`
|
2018-05-28 18:16:13 +03:00
|
|
|
ClientID string `gorm:"client_id type:varchar(70);not null;unique" json:"clientId,omitempty"`
|
2018-08-14 17:49:01 +03:00
|
|
|
APIKEY string `gorm:"api_key type:varchar(100);not null" json:"api_key,omitempty" binding:"required"`
|
|
|
|
APIURL string `gorm:"api_url type:varchar(255);not null" json:"api_url,omitempty" binding:"required,validatecrmurl"`
|
2018-05-31 16:18:52 +03:00
|
|
|
MGURL string `gorm:"mg_url type:varchar(255);not null;" json:"mg_url,omitempty"`
|
|
|
|
MGToken string `gorm:"mg_token type:varchar(100);not null;unique" json:"mg_token,omitempty"`
|
2018-05-17 18:35:53 +03:00
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
2018-05-28 18:16:13 +03:00
|
|
|
Active bool `json:"active,omitempty"`
|
|
|
|
Bots []Bot `gorm:"foreignkey:ConnectionID"`
|
2018-05-17 18:35:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Bot model
|
|
|
|
type Bot struct {
|
2018-05-28 18:16:13 +03:00
|
|
|
ID int `gorm:"primary_key"`
|
|
|
|
ConnectionID int `gorm:"connection_id" json:"connectionId,omitempty"`
|
2018-05-31 16:18:52 +03:00
|
|
|
Channel uint64 `gorm:"channel;not null;unique" json:"channel,omitempty"`
|
2018-05-28 18:16:13 +03:00
|
|
|
Token string `gorm:"token type:varchar(100);not null;unique" json:"token,omitempty"`
|
|
|
|
Name string `gorm:"name type:varchar(40)" json:"name,omitempty"`
|
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
2018-05-17 18:35:53 +03:00
|
|
|
}
|
|
|
|
|
2018-06-09 17:54:42 +03:00
|
|
|
// User model
|
|
|
|
type User struct {
|
2018-06-04 16:48:04 +03:00
|
|
|
ID int `gorm:"primary_key"`
|
|
|
|
ExternalID int `gorm:"external_id;not null;unique"`
|
2018-06-08 17:40:50 +03:00
|
|
|
UserPhotoURL string `gorm:"user_photo_url type:varchar(255)"`
|
|
|
|
UserPhotoID string `gorm:"user_photo_id type:varchar(100)"`
|
2018-06-04 16:48:04 +03:00
|
|
|
CreatedAt time.Time
|
|
|
|
UpdatedAt time.Time
|
|
|
|
}
|
|
|
|
|
2018-06-09 17:54:42 +03:00
|
|
|
func (User) TableName() string {
|
|
|
|
return "mg_user"
|
|
|
|
}
|
|
|
|
|
2018-05-17 18:35:53 +03:00
|
|
|
//Bots list
|
|
|
|
type Bots []Bot
|