model

package
v0.0.0-...-4c4b7df Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(user, password, host, database string)

Connects to database. Will panic on error. Pass host and database to use.

func Disconnect

func Disconnect()

Disconnect from database. Call on shutdown!

func Get

func Get() *sqlx.DB

Returns the database handle.

func GetDBType

func GetDBType() string

Returns the database type used in lower case.

Types

type Car

type Car struct {
	Id            int64  `json:"id"`
	Configuration int64  `json:"configuration"`
	Car           string `json:"car"`
	Painting      string `json:"painting"`
	Spectator     bool   `json:"spectator"`
	Driver        string `json:"driver"`
	Team          string `json:"team"`
	GUID          string `json:"guid"`
	Position      int    `json:"position"`
	FixedSetup    string `db:"fixed_setup" json:"fixed_setup"`
	Ballast       int    `json:"ballast"`
	Restrictor    int    `json:"restrictor"`
}

func GetCarsByConfiguration

func GetCarsByConfiguration(id int64) ([]Car, error)

func (*Car) Remove

func (m *Car) Remove() error

type Configuration

type Configuration struct {
	Id                    int64  `json:"id"`
	Name                  string `json:"name"`
	Pwd                   string `json:"pwd"`
	AdminPwd              string `db:"admin_pwd" json:"admin_pwd"`
	PickupMode            bool   `db:"pickup_mode" json:"pickup_mode"`
	LockEntryList         bool   `db:"lock_entry_list" json:"lock_entry_list"`
	RaceOvertime          int    `db:"race_overtime" json:"race_overtime"`
	MaxSlots              int    `db:"max_slots" json:"max_slots"`
	Welcome               string `json:"welcome"`
	Description           string `json:"description"`
	UDP                   int    `json:"udp"`
	TCP                   int    `json:"tcp"`
	HTTP                  int    `json:"http"`
	PacketsHz             int    `db:"packets_hz" json:"packets_hz"`
	LoopMode              bool   `db:"loop_mode" json:"loop_mode"`
	ShowInLobby           bool   `db:"show_in_lobby" json:"show_in_lobby"`
	Threads               int    `json:"threads"`
	AuthPluginAddress     int    `db:"auth_plugin_address" json:"auth_plugin_address"`
	ABS                   int    `json:"abs"`
	TC                    int    `json:"tc"`
	StabilityAid          bool   `db:"stability_aid" json:"stability_aid"`
	AutoClutch            bool   `db:"auto_clutch" json:"auto_clutch"`
	TyreBlankets          bool   `db:"tyre_blankets" json:"tyre_blankets"`
	ForceVirtualMirror    bool   `db:"force_virtual_mirror" json:"force_virtual_mirror"`
	FuelRate              int    `db:"fuel_rate" json:"fuel_rate"`
	DamageRate            int    `db:"damage_rate" json:"damage_rate"`
	TiresWearRate         int    `db:"tires_wear_rate" json:"tires_wear_rate"`
	AllowedTiresOut       int    `db:"allowed_tires_out" json:"allowed_tires_out"`
	MaxBallast            int    `db:"max_ballast" json:"max_ballast"`
	StartRule             int    `db:"start_rule" json:"start_rule"`
	DisableGasCutPenality bool   `db:"disable_gas_cut_penality" json:"disable_gas_cut_penality"`
	TimeOfDayMult         int    `db:"time_of_day_mult" json:"time_of_day_mult"`
	ResultScreenTime      int    `db:"result_screen_time" json:"result_screen_time"`
	DynamicTrack          bool   `db:"dynamic_track" json:"dynamic_track"`
	Condition             string `db:"track_condition" json:"condition"`
	StartValue            int    `db:"start_value" json:"start_value"`
	Randomness            int    `json:"randomness"`
	TransferredGrip       int    `db:"transferred_grip" json:"transferred_grip"`
	LapsToImproveGrip     int    `db:"laps_to_improve_grip" json:"laps_to_improve_grip"`
	KickVoteQuorum        int    `db:"kick_vote_quorum" json:"kick_vote_quorum"`
	SessionVoteQuorum     int    `db:"session_vote_quorum" json:"session_vote_quorum"`
	VoteDuration          int    `db:"vote_duration" json:"vote_duration"`
	Blacklist             int    `json:"blacklist"`
	MaxCollisionsKm       int    `db:"max_collisions_km" json:"max_collisions_km"`
	Booking               bool   `json:"booking"`
	BookingTime           int    `db:"booking_time" json:"booking_time"`
	Practice              bool   `json:"practice"`
	PracticeTime          int    `db:"practice_time" json:"practice_time"`
	CanJoinPractice       bool   `db:"can_join_practice" json:"can_join_practice"`
	Qualify               bool   `json:"qualify"`
	QualifyTime           int    `db:"qualify_time" json:"qualify_time"`
	CanJoinQualify        bool   `db:"can_join_qualify" json:"can_join_qualify"`
	Race                  bool   `json:"race"`
	RaceLaps              int    `db:"race_laps" json:"race_laps"`
	RaceTime              int    `db:"race_time" json:"race_time"`
	RaceWaitTime          int    `db:"race_wait_time" json:"race_wait_time"`
	RaceExtraLap          bool   `db:"race_extra_lap" json:"race_extra_lap"`
	JoinType              int    `db:"join_type" json:"join_type"`
	SunAngle              int    `db:"sun_angle" json:"sun_angle"`
	Track                 string `json:"track"`
	TrackConfig           string `db:"track_config" json:"track_config"`
	LegalTyres            string `db:"legal_tyres" json:"legal_tyres"`
	UdpPluginPort         int    `db:"udp_plugin_local_port" json:"udp_plugin_local_port"`
	UdpPluginAddr         string `db:"udp_plugin_address" json:"udp_plugin_address"`
	RacePitWindowStart    int    `db:"race_pit_window_start" json:"race_pit_window_start"`
	RacePitWindowEnd      int    `db:"race_pit_window_end" json:"race_pit_window_end"`
	ReversedGridRacePos   int    `db:"reversed_grid_race_positions" json:"reversed_grid_race_positions"`
	ServerCfgIni          string `db:"server_cfg_ini" json:"server_cfg_ini"`
	EntryListIni          string `db:"entry_list_ini" json:"entry_list_ini"`

	Weather []Weather `db:"-" json:"weather"`
	Cars    []Car     `db:"-" json:"cars"`
}

func GetAllConfigurations

func GetAllConfigurations() ([]Configuration, error)

func GetConfigurationById

func GetConfigurationById(id int64) (*Configuration, error)

func (*Configuration) Join

func (m *Configuration) Join() error

Joins weather and cars.

func (*Configuration) Remove

func (m *Configuration) Remove() error

func (*Configuration) Save

func (m *Configuration) Save() error

type Settings

type Settings struct {
	Id         int64  `json:"id"`
	Folder     string `json:"folder"`
	Executable string `json:"executable"`
	Args       string `json:"args"`
}

func GetSettings

func GetSettings() (*Settings, error)

func (*Settings) Save

func (s *Settings) Save() error

type User

type User struct {
	Id        int64  `json:"id"`
	Login     string `json:"login"`
	Email     string `json:"email"`
	Pwd       string `db:"password"` // do not send this to client
	Admin     bool   `json:"admin"`
	Moderator bool   `json:"moderator"`
}

func FindUserByLoginOrEmail

func FindUserByLoginOrEmail(login, email string) (*User, error)

func GetAllUser

func GetAllUser() ([]User, error)

func GetUserById

func GetUserById(id int64) (*User, error)

func GetUserByLoginOrEmailAndPassword

func GetUserByLoginOrEmailAndPassword(login, email, pwd string) (*User, error)

func (*User) Remove

func (m *User) Remove() error

func (*User) Save

func (m *User) Save() error

type Weather

type Weather struct {
	Id                     int64  `json:"id"`
	Configuration          int64  `json:"configuration"`
	Weather                string `json:"weather"`
	BaseAmbientTemp        int    `db:"base_ambient_temp" json:"base_ambient_temp"`
	BaseRoadTemp           int    `db:"base_road_temp" json:"base_road_temp"`
	AmbientVariation       int    `db:"ambient_variation" json:"ambient_variation"`
	RoadVariation          int    `db:"road_variation" json:"road_variation"`
	WindBaseSpeedMin       int    `db:"wind_base_speed_min" json:"wind_base_speed_min"`
	WindBaseSpeedMax       int    `db:"wind_base_speed_max" json:"wind_base_speed_max"`
	WindBaseDirection      int    `db:"wind_base_direction" json:"wind_base_direction"`
	WindVariationDirection int    `db:"wind_variation_direction" json:"wind_variation_direction"`
}

func GetWeatherByConfiguration

func GetWeatherByConfiguration(id int64) ([]Weather, error)

func (*Weather) Remove

func (m *Weather) Remove() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL