package v1

import (
	"database/sql"
	"time"

	"gorm.io/gorm"
)

type Company struct {
	ID            uint64         `gorm:"primaryKey;autoIncrement:true" json:"id"`
	CreatedAt     time.Time      `gorm:"not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt     sql.NullTime   `gorm:"default:null" json:"updated_at,omitempty"`
	DeletedAt     gorm.DeletedAt `gorm:"default:null" json:"deleted_at,omitempty"`
	Name          string         `gorm:"size:128" json:"name"`
	Country       string         `gorm:"size:20" json:"country"`
	From          string         `gorm:"size:20" json:"from"`
	Status        int            `json:"status"`
	RiskIcons     string         `gorm:"type:varchar(1024)" json:"risk_icons"`
	SancCount     int            `json:"sanc_count"`
	BannedCountry int            `json:"banned_country"`
}

func (Company) TableName() string {
	return "company"
}

type CompanyProblem struct {
	ID                   uint64         `gorm:"primaryKey;autoIncrement:true" json:"id"`
	CreatedAt            time.Time      `gorm:"not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt            sql.NullTime   `gorm:"default:null" json:"updated_at,omitempty"`
	DeletedAt            gorm.DeletedAt `gorm:"default:null" json:"deleted_at,omitempty"`
	CompanyID            uint64         `json:"company_id"`
	CompanyName          string         `gorm:"type:varchar(128)" json:"company_name"`
	EntityID             string         `gorm:"-" json:"-"`
	PrimaryName          string         `gorm:"type:varchar(64)" json:"primary_name"`
	CountryISOAlpha2Code string         `gorm:"type:varchar(32)" json:"country_iso_alpha2_code"`
	EntityType           string         `gorm:"type:varchar(32);unique" json:"entity_type"`
	RiskIcons            string         `gorm:"type:varchar(255)" json:"risk_icons"`
	Title                string         `gorm:"type:varchar(128)" json:"title"`
	MatchedName          string         `gorm:"type:varchar(128)" json:"matched_name"`
	MatchedNameType      string         `gorm:"type:varchar(128)" json:"matched_name_type"`
	MatchScore           string         `gorm:"type:varchar(20)" json:"match_score"`
}

func (CompanyProblem) TableName() string {
	return "company_problem"
}

type CompanyBasic struct {
	ID          uint64         `gorm:"primaryKey;autoIncrement:true" json:"id"`
	CreatedAt   time.Time      `gorm:"not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt   sql.NullTime   `gorm:"default:null" json:"updated_at,omitempty"`
	DeletedAt   gorm.DeletedAt `gorm:"default:null" json:"deleted_at,omitempty"`
	CompanyID   uint64         `json:"company_id"`
	CompanyName string         `gorm:"type:varchar(128)" json:"company_name"`
	PrimaryName string         `gorm:"type:varchar(128)" json:"primary_name"`
	Country     string         `gorm:"type:varchar(20)" json:"country"`
	Status      string         `json:"status"`
	Address     string         `gorm:"type:varchar(255)" json:"address"`
	RegNumber   string         `gorm:"type:varchar(1024)" json:"reg_number"`
}

func (CompanyBasic) TableName() string {
	return "company_basic"
}

type CompanySanction struct {
	ID                     uint64         `gorm:"primaryKey;autoIncrement:true" json:"id"`
	CreatedAt              time.Time      `gorm:"not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt              sql.NullTime   `gorm:"default:null" json:"updated_at,omitempty"`
	DeletedAt              gorm.DeletedAt `gorm:"default:null" json:"deleted_at,omitempty"`
	CompanyID              uint64         `json:"company_id"`
	CompanyName            string         `gorm:"type:varchar(128)" json:"company_name"`
	PrimaryName            string         `gorm:"type:varchar(128)" json:"primary_name"`
	EntityID               string         `gorm:"type:varchar(128);unique" json:"entity_id"`
	OrganizationNames      string         `gorm:"type:varchar(1024)" json:"organization_names"`
	WatchListContentStatus string         `gorm:"type:varchar(32)" json:"watch_list_content_status"`
	WatchListContentNotes  string         `gorm:"type:text" json:"watch_list_content_notes"`
	DataProviders          string         `gorm:"type:text" json:"data_providers"`
}

func (CompanySanction) TableName() string {
	return "company_sanction"
}

type CompanySanctionReferences struct {
	ID           uint64         `gorm:"primaryKey;autoIncrement:true" json:"id"`
	CreatedAt    time.Time      `gorm:"not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt    sql.NullTime   `gorm:"default:null" json:"updated_at,omitempty"`
	DeletedAt    gorm.DeletedAt `gorm:"default:null" json:"deleted_at,omitempty"`
	CompanyID    uint64         `json:"company_id"`
	CompanyName  string         `gorm:"type:varchar(128)" json:"company_name"`
	PrimaryName  string         `gorm:"type:varchar(128)" json:"primary_name"`
	SanctionID   uint64         `json:"sanction_id"`
	Reference    string         `gorm:"type:varchar(255)" json:"reference"`
	ProviderName string         `gorm:"type:varchar(255)" json:"provider_name"`
	ProviderCode string         `gorm:"type:varchar(128)" json:"provider_code"`
	Description  string         `gorm:"type:varchar(1024)" json:"description"`
	Status       string         `gorm:"type:varchar(64)" json:"status"`
	StartDate    string         `gorm:"type:varchar(64)" json:"start_year"`
	EndDate      string         `gorm:"type:varchar(64)" json:"end_year"`
}

func (CompanySanctionReferences) TableName() string {
	return "company_sanction_references"
}

type UserLog struct {
	ID        uint64         `gorm:"primaryKey;autoIncrement:true" json:"id"`
	CreatedAt time.Time      `gorm:"not null;default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt sql.NullTime   `gorm:"default:null" json:"updated_at,omitempty"`
	DeletedAt gorm.DeletedAt `gorm:"default:null" json:"deleted_at,omitempty"`
	UserID    string         `gorm:"type:varchar(128)" json:"user_id"`
	MessageID string         `gorm:"type:varchar(255)" json:"message_id"`
	Content   string         `gorm:"type:varchar(1024)" json:"content"`
}

func (UserLog) TableName() string {
	return "user_log"
}
