models

package
v0.0.0-...-1709d23 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package models contains tools for working with solve objects stored in different databases like SQLite or Postgres.

Index

Constants

View Source
const (
	// LoginRole represents name of role for login action.
	LoginRole = "login"
	// LogoutRole represents name of role for logout action.
	LogoutRole = "logout"
	// RegisterRole represents name of role for register action.
	RegisterRole = "register"
	// StatusRole represents name of role for status check.
	StatusRole = "status"
	// ObserveSettingsRole represents name of role for observing settings.
	ObserveSettingsRole = "observe_settings"
	// CreateSettingRole represents name of role for creating new setting.
	CreateSettingRole = "create_setting"
	// UpdateSettingRole represents name of role for updating setting.
	UpdateSettingRole = "update_setting"
	// DeleteSettingRole represents name of role for deleting setting.
	DeleteSettingRole = "delete_setting"
	// ObserveRolesRole represents name of role for observing roles.
	ObserveRolesRole = "observe_roles"
	// CreateRoleRole represents name of role for creating new role.
	CreateRoleRole = "create_role"
	// DeleteRoleRole represents name of role for deleting role.
	DeleteRoleRole = "delete_role"
	// ObserveRoleRolesRole represents name of role for observing role roles.
	ObserveRoleRolesRole = "observe_role_roles"
	// CreateRoleRoleRole represents name of role for creating new role role.
	CreateRoleRoleRole = "create_role_role"
	// DeleteRoleRoleRole represents name of role for deleting role role.
	DeleteRoleRoleRole = "delete_role_role"
	// ObserveUserRolesRole represents name of role for observing user roles.
	ObserveUserRolesRole = "observe_user_roles"
	// CreateUserRoleRole represents name of role for attaching role to user.
	CreateUserRoleRole = "create_user_role"
	// DeleteUserRoleRole represents name of role for detaching role from user.
	DeleteUserRoleRole = "delete_user_role"
	// ObserveUserRole represents name of role for observing user.
	ObserveUserRole = "observe_user"
	// UpdateUserRole represents name of role for updating user.
	UpdateUserRole = "update_user"
	// ObserveUserEmailRole represents name of role for observing user email.
	ObserveUserEmailRole = "observe_user_email"
	// ObserveUserFirstNameRole represents name of role for observing
	// user first name.
	ObserveUserFirstNameRole = "observe_user_first_name"
	// ObserveUserLastNameRole represents name of role for observing
	// user last name.
	ObserveUserLastNameRole = "observe_user_last_name"
	// ObserveUserMiddleNameRole represents name of role for observing
	// user middle name.
	ObserveUserMiddleNameRole = "observe_user_middle_name"
	// ObserveUserSessionsRole represents name of role for observing
	// user sessions.
	ObserveUserSessionsRole = "observe_user_sessions"
	// UpdateUserPasswordRole represents name of role for updating
	// user password.
	UpdateUserPasswordRole = "update_user_password"
	// UpdateUserEmailRole represents name of role for updating user email.
	UpdateUserEmailRole = "update_user_email"
	// UpdateUserFirstNameRole represents name of role for updating
	// user first name.
	UpdateUserFirstNameRole = "update_user_first_name"
	// UpdateUserLastNameRole represents name of role for updating
	// user last name.
	UpdateUserLastNameRole = "update_user_last_name"
	// UpdateUserMiddleNameRole represents name of role for updating
	// user middle name.
	UpdateUserMiddleNameRole = "update_user_middle_name"
	// ObserveSessionRole represents role for observing session.
	ObserveSessionRole = "observe_session"
	// DeleteSessionRole represents role for deleting session.
	DeleteSessionRole = "delete_session"
	// ObserveProblemsRole represents role for observing problem list.
	ObserveProblemsRole = "observe_problems"
	// ObserveProblemRole represents role for observing problem.
	ObserveProblemRole = "observe_problem"
	// CreateProblemRole represents role for creating problem.
	CreateProblemRole = "create_problem"
	// UpdateProblemRole represents role for updating problem.
	UpdateProblemRole = "update_problem"
	// DeleteProblemRole represents role for deleting problem.
	DeleteProblemRole = "delete_problem"
	// ObserveCompilersRole represents role for observing compiler list.
	ObserveCompilersRole = "observe_compilers"
	// ObserveCompilerRole represents role for observing compiler.
	ObserveCompilerRole = "observe_compiler"
	// CreateCompilerRole represents role for creating compiler.
	CreateCompilerRole = "create_compiler"
	// UpdateCompilerRole represents role for updating compiler.
	UpdateCompilerRole = "update_compiler"
	// DeleteCompilerRole represents role for deleting compiler.
	DeleteCompilerRole = "delete_compiler"
	// ObserveSolutionsRole represents role for observing solution list.
	ObserveSolutionsRole = "observe_solutions"
	// ObserveSolutionRole represents role for observing solution.
	ObserveSolutionRole = "observe_solution"
	// ObserveContestsRole represents role for observing contest list.
	ObserveContestsRole = "observe_contests"
	// ObserveContestRole represents role for observing contest.
	ObserveContestRole = "observe_contest"
	// ObserveContestProblemsRole represents role for observing
	// contest problem list.
	ObserveContestProblemsRole = "observe_contest_problems"
	// ObserveContestProblemRole represents role for observing
	// contest problem.
	ObserveContestProblemRole = "observe_contest_problem"
	// CreateContestProblemRole represents role for creating
	// contest problem.
	CreateContestProblemRole = "create_contest_problem"
	// DeleteContestProblemRole represents role for deleting
	// contest problem.
	DeleteContestProblemRole = "delete_contest_problem"
	// ObserveContestParticipantsRole represents role for observing
	// contest participant list.
	ObserveContestParticipantsRole = "observe_contest_participants"
	// ObserveContestParticipantRole represents role for observing
	// contest participant.
	ObserveContestParticipantRole = "observe_contest_participant"
	// CreateContestProblemRole represents role for creating
	// contest participant.
	CreateContestParticipantRole = "create_contest_participant"
	// DeleteContestParticipantRole represents role for deleting
	// contest participant.
	DeleteContestParticipantRole = "delete_contest_participant"
	// ObserveContestSolutionsRole represents role for observing
	// contest solution list.
	ObserveContestSolutionsRole = "observe_contest_solutions"
	// ObserveContestSolutionRole represents role for observing
	// contest solution.
	ObserveContestSolutionRole = "observe_contest_solution"
	// CreateContestSolutionRole represents role for creating
	// contest solution.
	CreateContestSolutionRole = "create_contest_solution"
	// SubmitContestSolutionRole represents role for submitting
	// contest solution.
	SubmitContestSolutionRole = "submit_contest_solution"
	// UpdateContestSolutionRole represents role for updating
	// contest solution.
	UpdateContestSolutionRole = "update_contest_solution"
	// DeleteContestSolutionRole represents role for deleting
	// contest solution.
	DeleteContestSolutionRole = "delete_contest_solution"
	// CreateContestRole represents role for creating contest.
	CreateContestRole = "create_contest"
	// UpdateContestRole represents role for updating contest.
	UpdateContestRole = "update_contest"
	// DeleteContestRole represents role for deleting contest.
	DeleteContestRole = "delete_contest"
)

Variables

This section is empty.

Functions

func GetAccountID

func GetAccountID(ctx context.Context) int64

GetAccountID returns account ID or zero if there is no account.

func GetBuiltInRoles

func GetBuiltInRoles() []string

GetBuildInRoles returns all built-in roles.

func WithAccountID

func WithAccountID(ctx context.Context, id int64) context.Context

Types

type Account

type Account struct {

	// Kind contains kind of account.
	Kind AccountKind `db:"kind"`
	// contains filtered or unexported fields
}

Account represents an account.

func (Account) Clone

func (o Account) Clone() Account

Clone creates copy of account.

func (Account) ObjectID

func (o Account) ObjectID() int64

ObjectID returns ID of object.

func (*Account) SetObjectID

func (o *Account) SetObjectID(id int64)

SetObjectID updates ID of object.

type AccountEvent

type AccountEvent struct {
	Account
	// contains filtered or unexported fields
}

AccountEvent represents an account event.

func (AccountEvent) EventID

func (e AccountEvent) EventID() int64

EventID returns id of this event.

func (AccountEvent) EventKind

func (e AccountEvent) EventKind() EventKind

EventKind returns type of this event.

func (AccountEvent) EventTime

func (e AccountEvent) EventTime() time.Time

EventTime returns time of this event.

func (AccountEvent) Object

func (e AccountEvent) Object() Account

Object returns event account.

func (AccountEvent) ObjectID

func (o AccountEvent) ObjectID() int64

ObjectID returns ID of object.

func (*AccountEvent) SetEventAccountID

func (e *AccountEvent) SetEventAccountID(accountID int64)

func (*AccountEvent) SetEventID

func (e *AccountEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*AccountEvent) SetEventKind

func (e *AccountEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*AccountEvent) SetEventTime

func (e *AccountEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*AccountEvent) SetObject

func (e *AccountEvent) SetObject(o Account)

SetObject sets event account.

func (*AccountEvent) SetObjectID

func (o *AccountEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type AccountKind

type AccountKind int

AccountKind represents kind of account.

const (
	// UserAccount represents kind of account for user.
	UserAccount AccountKind = 1
)

type AccountRole

type AccountRole struct {

	// AccountID contains account ID.
	AccountID int64 `db:"account_id"`
	// RoleID contains role ID.
	RoleID int64 `db:"role_id"`
	// contains filtered or unexported fields
}

AccountRole represents a account role.

func (AccountRole) Clone

func (o AccountRole) Clone() AccountRole

Clone creates copy of account role.

func (AccountRole) ObjectID

func (o AccountRole) ObjectID() int64

ObjectID returns ID of object.

func (*AccountRole) SetObjectID

func (o *AccountRole) SetObjectID(id int64)

SetObjectID updates ID of object.

type AccountRoleEvent

type AccountRoleEvent struct {
	AccountRole
	// contains filtered or unexported fields
}

AccountRoleEvent represents account role event.

func (AccountRoleEvent) EventID

func (e AccountRoleEvent) EventID() int64

EventID returns id of this event.

func (AccountRoleEvent) EventKind

func (e AccountRoleEvent) EventKind() EventKind

EventKind returns type of this event.

func (AccountRoleEvent) EventTime

func (e AccountRoleEvent) EventTime() time.Time

EventTime returns time of this event.

func (AccountRoleEvent) Object

func (e AccountRoleEvent) Object() AccountRole

Object returns account role.

func (AccountRoleEvent) ObjectID

func (o AccountRoleEvent) ObjectID() int64

ObjectID returns ID of object.

func (*AccountRoleEvent) SetEventAccountID

func (e *AccountRoleEvent) SetEventAccountID(accountID int64)

func (*AccountRoleEvent) SetEventID

func (e *AccountRoleEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*AccountRoleEvent) SetEventKind

func (e *AccountRoleEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*AccountRoleEvent) SetEventTime

func (e *AccountRoleEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*AccountRoleEvent) SetObject

func (e *AccountRoleEvent) SetObject(o AccountRole)

SetObject sets event account role.

func (*AccountRoleEvent) SetObjectID

func (o *AccountRoleEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type AccountRoleStore

type AccountRoleStore struct {
	// contains filtered or unexported fields
}

AccountRoleStore represents store for account roles.

func NewAccountRoleStore

func NewAccountRoleStore(
	db *gosql.DB, table, eventTable string,
) *AccountRoleStore

NewAccountRoleStore creates a new instance of AccountRoleStore.

func (*AccountRoleStore) Create

func (s *AccountRoleStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*AccountRoleStore) DB

func (s *AccountRoleStore) DB() *gosql.DB

DB returns store database.

func (*AccountRoleStore) Delete

func (s *AccountRoleStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*AccountRoleStore) FindByAccount

func (s *AccountRoleStore) FindByAccount(id int64) ([]AccountRole, error)

FindByAccount returns roles by account ID.

func (*AccountRoleStore) Get

func (s *AccountRoleStore) Get(id int64) (AccountRole, error)

Get returns account role by ID.

If there is no role with specified id then sql.ErrNoRows will be returned.

func (*AccountRoleStore) Init

func (s *AccountRoleStore) Init(ctx context.Context) error

func (*AccountRoleStore) Sync

func (s *AccountRoleStore) Sync(ctx context.Context) error

func (*AccountRoleStore) Update

func (s *AccountRoleStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type AccountStore

type AccountStore struct {
	// contains filtered or unexported fields
}

AccountStore represents store for accounts.

func NewAccountStore

func NewAccountStore(
	db *gosql.DB, table, eventTable string,
) *AccountStore

NewAccountStore creates a new instance of AccountStore.

func (*AccountStore) Create

func (s *AccountStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*AccountStore) DB

func (s *AccountStore) DB() *gosql.DB

DB returns store database.

func (*AccountStore) Delete

func (s *AccountStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*AccountStore) Get

func (s *AccountStore) Get(id int64) (Account, error)

Get returns account by ID.

func (*AccountStore) Init

func (s *AccountStore) Init(ctx context.Context) error

func (*AccountStore) Sync

func (s *AccountStore) Sync(ctx context.Context) error

func (*AccountStore) Update

func (s *AccountStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Cloner

type Cloner[T any] interface {
	Clone() T
}

Cloner represents object that can be cloned.

type EventKind

type EventKind int8

EventKind represents kind of object event.

const (
	// CreateEvent means that this is event of object creation.
	CreateEvent EventKind = 1
	// DeleteEvent means that this is event of object deletion.
	DeleteEvent EventKind = 2
	// UpdateEvent means that this is event of object modification.
	UpdateEvent EventKind = 3
)

func (EventKind) String

func (t EventKind) String() string

String returns string representation of event.

type JSON

type JSON []byte

JSON represents json value.

func (JSON) Clone

func (v JSON) Clone() JSON

func (JSON) MarshalJSON

func (v JSON) MarshalJSON() ([]byte, error)

MarshalJSON marshals JSON.

func (*JSON) Scan

func (v *JSON) Scan(value any) error

Scan scans value.

func (*JSON) UnmarshalJSON

func (v *JSON) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals JSON.

func (JSON) Value

func (v JSON) Value() (driver.Value, error)

Value returns value.

type NInt64

type NInt64 int64

NInt64 represents nullable int64 with zero value means null value.

func (*NInt64) Scan

func (v *NInt64) Scan(value any) error

Scan scans value.

func (NInt64) Value

func (v NInt64) Value() (driver.Value, error)

Value returns value.

type NString

type NString string

NString represents nullable string with empty value means null value.

func (*NString) Scan

func (v *NString) Scan(value any) error

Scan scans value.

func (NString) Value

func (v NString) Value() (driver.Value, error)

Value returns value.

type ObjectEventPtr

type ObjectEventPtr[T any, E any] interface {
	*E
	EventID() int64
	SetEventID(int64)
	EventTime() time.Time
	SetEventTime(time.Time)
	EventKind() EventKind
	SetEventKind(EventKind)
	SetEventAccountID(int64)
	Object() T
	SetObject(T)
	ObjectID() int64
	SetObjectID(int64)
}

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

func (Pool) ObjectID

func (o Pool) ObjectID() int64

ObjectID returns ID of object.

func (*Pool) SetObjectID

func (o *Pool) SetObjectID(id int64)

SetObjectID updates ID of object.

type PoolEvent

type PoolEvent struct {
	Pool
	// contains filtered or unexported fields
}

func (PoolEvent) EventID

func (e PoolEvent) EventID() int64

EventID returns id of this event.

func (PoolEvent) EventKind

func (e PoolEvent) EventKind() EventKind

EventKind returns type of this event.

func (PoolEvent) EventTime

func (e PoolEvent) EventTime() time.Time

EventTime returns time of this event.

func (PoolEvent) Object

func (e PoolEvent) Object() Pool

func (PoolEvent) ObjectID

func (o PoolEvent) ObjectID() int64

ObjectID returns ID of object.

func (*PoolEvent) SetEventAccountID

func (e *PoolEvent) SetEventAccountID(accountID int64)

func (*PoolEvent) SetEventID

func (e *PoolEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*PoolEvent) SetEventKind

func (e *PoolEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*PoolEvent) SetEventTime

func (e *PoolEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*PoolEvent) SetObject

func (e *PoolEvent) SetObject(o Pool)

func (*PoolEvent) SetObjectID

func (o *PoolEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type PoolStore

type PoolStore struct {
	// contains filtered or unexported fields
}

func NewPoolStore

func NewPoolStore(
	db *gosql.DB, table, eventTable string,
) *PoolStore

NewPoolStore creates a new instance of PoolStore.

func (*PoolStore) Create

func (s *PoolStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*PoolStore) DB

func (s *PoolStore) DB() *gosql.DB

DB returns store database.

func (*PoolStore) Delete

func (s *PoolStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*PoolStore) Init

func (s *PoolStore) Init(ctx context.Context) error

func (*PoolStore) Sync

func (s *PoolStore) Sync(ctx context.Context) error

func (*PoolStore) Update

func (s *PoolStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Problem

type Problem struct {
	// contains filtered or unexported fields
}

func (Problem) ObjectID

func (o Problem) ObjectID() int64

ObjectID returns ID of object.

func (*Problem) SetObjectID

func (o *Problem) SetObjectID(id int64)

SetObjectID updates ID of object.

type ProblemEvent

type ProblemEvent struct {
	Problem
	// contains filtered or unexported fields
}

func (ProblemEvent) EventID

func (e ProblemEvent) EventID() int64

EventID returns id of this event.

func (ProblemEvent) EventKind

func (e ProblemEvent) EventKind() EventKind

EventKind returns type of this event.

func (ProblemEvent) EventTime

func (e ProblemEvent) EventTime() time.Time

EventTime returns time of this event.

func (ProblemEvent) Object

func (e ProblemEvent) Object() Problem

func (ProblemEvent) ObjectID

func (o ProblemEvent) ObjectID() int64

ObjectID returns ID of object.

func (*ProblemEvent) SetEventAccountID

func (e *ProblemEvent) SetEventAccountID(accountID int64)

func (*ProblemEvent) SetEventID

func (e *ProblemEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*ProblemEvent) SetEventKind

func (e *ProblemEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*ProblemEvent) SetEventTime

func (e *ProblemEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*ProblemEvent) SetObject

func (e *ProblemEvent) SetObject(o Problem)

func (*ProblemEvent) SetObjectID

func (o *ProblemEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type ProblemStore

type ProblemStore struct {
	// contains filtered or unexported fields
}

func NewProblemStore

func NewProblemStore(
	db *gosql.DB, table, eventTable string,
) *ProblemStore

NewProblemStore creates a new instance of ProblemStore.

func (*ProblemStore) Create

func (s *ProblemStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*ProblemStore) DB

func (s *ProblemStore) DB() *gosql.DB

DB returns store database.

func (*ProblemStore) Delete

func (s *ProblemStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*ProblemStore) Init

func (s *ProblemStore) Init(ctx context.Context) error

func (*ProblemStore) Sync

func (s *ProblemStore) Sync(ctx context.Context) error

func (*ProblemStore) Update

func (s *ProblemStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Quiz

type Quiz struct {
	// contains filtered or unexported fields
}

func (Quiz) ObjectID

func (o Quiz) ObjectID() int64

ObjectID returns ID of object.

func (*Quiz) SetObjectID

func (o *Quiz) SetObjectID(id int64)

SetObjectID updates ID of object.

type QuizEvent

type QuizEvent struct {
	Quiz
	// contains filtered or unexported fields
}

func (QuizEvent) EventID

func (e QuizEvent) EventID() int64

EventID returns id of this event.

func (QuizEvent) EventKind

func (e QuizEvent) EventKind() EventKind

EventKind returns type of this event.

func (QuizEvent) EventTime

func (e QuizEvent) EventTime() time.Time

EventTime returns time of this event.

func (QuizEvent) Object

func (e QuizEvent) Object() Quiz

func (QuizEvent) ObjectID

func (o QuizEvent) ObjectID() int64

ObjectID returns ID of object.

func (*QuizEvent) SetEventAccountID

func (e *QuizEvent) SetEventAccountID(accountID int64)

func (*QuizEvent) SetEventID

func (e *QuizEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*QuizEvent) SetEventKind

func (e *QuizEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*QuizEvent) SetEventTime

func (e *QuizEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*QuizEvent) SetObject

func (e *QuizEvent) SetObject(o Quiz)

func (*QuizEvent) SetObjectID

func (o *QuizEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type QuizStore

type QuizStore struct {
	// contains filtered or unexported fields
}

func NewQuizStore

func NewQuizStore(
	db *gosql.DB, table, eventTable string,
) *QuizStore

NewQuizStore creates a new instance of QuizStore.

func (*QuizStore) Create

func (s *QuizStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*QuizStore) DB

func (s *QuizStore) DB() *gosql.DB

DB returns store database.

func (*QuizStore) Delete

func (s *QuizStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*QuizStore) Init

func (s *QuizStore) Init(ctx context.Context) error

func (*QuizStore) Sync

func (s *QuizStore) Sync(ctx context.Context) error

func (*QuizStore) Update

func (s *QuizStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Role

type Role struct {

	// Name contains role name.
	//
	// Name should be unique for all roles in the events.
	Name string `db:"name"`
	// contains filtered or unexported fields
}

Role represents a role.

func (Role) Clone

func (o Role) Clone() Role

Clone creates copy of role.

func (Role) IsBuiltIn

func (o Role) IsBuiltIn() bool

IsBuiltIn returns flag that role is built-in.

func (Role) ObjectID

func (o Role) ObjectID() int64

ObjectID returns ID of object.

func (*Role) SetObjectID

func (o *Role) SetObjectID(id int64)

SetObjectID updates ID of object.

type RoleEdge

type RoleEdge struct {

	// RoleID contains ID of parent role.
	RoleID int64 `db:"role_id" json:"role_id"`
	// ChildID contains ID of child role.
	ChildID int64 `db:"child_id" json:"child_id"`
	// contains filtered or unexported fields
}

RoleEdge represents connection for roles.

func (RoleEdge) Clone

func (o RoleEdge) Clone() RoleEdge

Clone creates copy of role edge.

func (RoleEdge) ObjectID

func (o RoleEdge) ObjectID() int64

ObjectID returns ID of object.

func (*RoleEdge) SetObjectID

func (o *RoleEdge) SetObjectID(id int64)

SetObjectID updates ID of object.

type RoleEdgeEvent

type RoleEdgeEvent struct {
	RoleEdge
	// contains filtered or unexported fields
}

RoleEdgeEvent represents role edge event.

func (RoleEdgeEvent) EventID

func (e RoleEdgeEvent) EventID() int64

EventID returns id of this event.

func (RoleEdgeEvent) EventKind

func (e RoleEdgeEvent) EventKind() EventKind

EventKind returns type of this event.

func (RoleEdgeEvent) EventTime

func (e RoleEdgeEvent) EventTime() time.Time

EventTime returns time of this event.

func (RoleEdgeEvent) Object

func (e RoleEdgeEvent) Object() RoleEdge

Object returns event role edge.

func (RoleEdgeEvent) ObjectID

func (o RoleEdgeEvent) ObjectID() int64

ObjectID returns ID of object.

func (*RoleEdgeEvent) SetEventAccountID

func (e *RoleEdgeEvent) SetEventAccountID(accountID int64)

func (*RoleEdgeEvent) SetEventID

func (e *RoleEdgeEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*RoleEdgeEvent) SetEventKind

func (e *RoleEdgeEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*RoleEdgeEvent) SetEventTime

func (e *RoleEdgeEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*RoleEdgeEvent) SetObject

func (e *RoleEdgeEvent) SetObject(o RoleEdge)

SetObject sets event role edge.

func (*RoleEdgeEvent) SetObjectID

func (o *RoleEdgeEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type RoleEdgeStore

type RoleEdgeStore struct {
	// contains filtered or unexported fields
}

RoleEdgeStore represents a role edge store.

func NewRoleEdgeStore

func NewRoleEdgeStore(
	db *gosql.DB, table, eventTable string,
) *RoleEdgeStore

NewRoleEdgeStore creates a new instance of RoleEdgeStore.

func (*RoleEdgeStore) Create

func (s *RoleEdgeStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*RoleEdgeStore) DB

func (s *RoleEdgeStore) DB() *gosql.DB

DB returns store database.

func (*RoleEdgeStore) Delete

func (s *RoleEdgeStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*RoleEdgeStore) FindByRole

func (s *RoleEdgeStore) FindByRole(id int64) ([]RoleEdge, error)

FindByRole returns edges by parent ID.

func (*RoleEdgeStore) Get

func (s *RoleEdgeStore) Get(id int64) (RoleEdge, error)

Get returns role edge by ID.

If there is no role with specified ID then sql.ErrNoRows will be returned.

func (*RoleEdgeStore) Init

func (s *RoleEdgeStore) Init(ctx context.Context) error

func (*RoleEdgeStore) Sync

func (s *RoleEdgeStore) Sync(ctx context.Context) error

func (*RoleEdgeStore) Update

func (s *RoleEdgeStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type RoleEvent

type RoleEvent struct {
	Role
	// contains filtered or unexported fields
}

RoleEvent represents role event.

func (RoleEvent) EventID

func (e RoleEvent) EventID() int64

EventID returns id of this event.

func (RoleEvent) EventKind

func (e RoleEvent) EventKind() EventKind

EventKind returns type of this event.

func (RoleEvent) EventTime

func (e RoleEvent) EventTime() time.Time

EventTime returns time of this event.

func (RoleEvent) Object

func (e RoleEvent) Object() Role

Object returns event role.

func (RoleEvent) ObjectID

func (o RoleEvent) ObjectID() int64

ObjectID returns ID of object.

func (*RoleEvent) SetEventAccountID

func (e *RoleEvent) SetEventAccountID(accountID int64)

func (*RoleEvent) SetEventID

func (e *RoleEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*RoleEvent) SetEventKind

func (e *RoleEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*RoleEvent) SetEventTime

func (e *RoleEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*RoleEvent) SetObject

func (e *RoleEvent) SetObject(o Role)

SetObject sets event role.

func (*RoleEvent) SetObjectID

func (o *RoleEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type RoleStore

type RoleStore struct {
	// contains filtered or unexported fields
}

RoleStore represents a role store.

func NewRoleStore

func NewRoleStore(
	db *gosql.DB, table, eventTable string,
) *RoleStore

NewRoleStore creates a new instance of RoleStore.

func (*RoleStore) All

func (s *RoleStore) All() ([]Role, error)

All returns all roles.

func (*RoleStore) Create

func (s *RoleStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*RoleStore) DB

func (s *RoleStore) DB() *gosql.DB

DB returns store database.

func (*RoleStore) Delete

func (s *RoleStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*RoleStore) Get

func (s *RoleStore) Get(id int64) (Role, error)

Get returns role by ID.

If there is no role with specified ID then sql.ErrNoRows will be returned.

func (*RoleStore) GetByName

func (s *RoleStore) GetByName(name string) (Role, error)

GetByName returns role by name.

If there is no role with specified name then sql.ErrNoRows will be returned.

func (*RoleStore) Init

func (s *RoleStore) Init(ctx context.Context) error

func (*RoleStore) Sync

func (s *RoleStore) Sync(ctx context.Context) error

func (*RoleStore) Update

func (s *RoleStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Session

type Session struct {

	// AccountID contains ID of account.
	AccountID int64 `db:"account_id"`
	// Secret contains secret string of session.
	Secret string `db:"secret"`
	// CreateTime contains time when session was created.
	CreateTime int64 `db:"create_time"`
	// ExpireTime contains time when session should be expired.
	ExpireTime int64 `db:"expire_time"`
	// RemoteAddr contains remote address of user for created session.
	RemoteAddr string `db:"remote_addr"`
	// UserAgent contains user agent header for created session.
	UserAgent string `db:"user_agent"`
	// contains filtered or unexported fields
}

Session represents account session.

func (Session) Clone

func (o Session) Clone() Session

Clone creates copy of session.

func (Session) Cookie

func (o Session) Cookie() http.Cookie

Cookie returns cookie object.

func (*Session) GenerateSecret

func (o *Session) GenerateSecret() error

GenerateSecret generates a new value for session secret.

func (Session) ObjectID

func (o Session) ObjectID() int64

ObjectID returns ID of object.

func (*Session) SetObjectID

func (o *Session) SetObjectID(id int64)

SetObjectID updates ID of object.

type SessionEvent

type SessionEvent struct {
	Session
	// contains filtered or unexported fields
}

SessionEvent represents session event.

func (SessionEvent) EventID

func (e SessionEvent) EventID() int64

EventID returns id of this event.

func (SessionEvent) EventKind

func (e SessionEvent) EventKind() EventKind

EventKind returns type of this event.

func (SessionEvent) EventTime

func (e SessionEvent) EventTime() time.Time

EventTime returns time of this event.

func (SessionEvent) Object

func (e SessionEvent) Object() Session

Object returns session.

func (SessionEvent) ObjectID

func (o SessionEvent) ObjectID() int64

ObjectID returns ID of object.

func (*SessionEvent) SetEventAccountID

func (e *SessionEvent) SetEventAccountID(accountID int64)

func (*SessionEvent) SetEventID

func (e *SessionEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*SessionEvent) SetEventKind

func (e *SessionEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*SessionEvent) SetEventTime

func (e *SessionEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*SessionEvent) SetObject

func (e *SessionEvent) SetObject(o Session)

SetObject sets event session.

func (*SessionEvent) SetObjectID

func (o *SessionEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type SessionStore

type SessionStore struct {
	// contains filtered or unexported fields
}

SessionStore represents store for sessions.

func NewSessionStore

func NewSessionStore(
	db *gosql.DB, table, eventTable string,
) *SessionStore

NewSessionStore creates a new instance of SessionStore.

func (*SessionStore) Create

func (s *SessionStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*SessionStore) DB

func (s *SessionStore) DB() *gosql.DB

DB returns store database.

func (*SessionStore) Delete

func (s *SessionStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*SessionStore) FindByAccount

func (s *SessionStore) FindByAccount(id int64) ([]Session, error)

FindByAccount returns sessions by account ID.

func (*SessionStore) Get

func (s *SessionStore) Get(id int64) (Session, error)

Get returns session by session ID.

func (*SessionStore) GetByCookie

func (s *SessionStore) GetByCookie(cookie string) (Session, error)

GetByCookie returns session for specified cookie value.

func (*SessionStore) Init

func (s *SessionStore) Init(ctx context.Context) error

func (*SessionStore) Sync

func (s *SessionStore) Sync(ctx context.Context) error

func (*SessionStore) Update

func (s *SessionStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Setting

type Setting struct {
	Key   string `db:"key"`
	Value string `db:"value"`
	// contains filtered or unexported fields
}

Setting represents setting.

func (Setting) Clone

func (o Setting) Clone() Setting

Clone creates copy of setting.

func (Setting) ObjectID

func (o Setting) ObjectID() int64

ObjectID returns ID of object.

func (*Setting) SetObjectID

func (o *Setting) SetObjectID(id int64)

SetObjectID updates ID of object.

type SettingEvent

type SettingEvent struct {
	Setting
	// contains filtered or unexported fields
}

SettingEvent represents setting event.

func (SettingEvent) EventID

func (e SettingEvent) EventID() int64

EventID returns id of this event.

func (SettingEvent) EventKind

func (e SettingEvent) EventKind() EventKind

EventKind returns type of this event.

func (SettingEvent) EventTime

func (e SettingEvent) EventTime() time.Time

EventTime returns time of this event.

func (SettingEvent) Object

func (e SettingEvent) Object() Setting

Object returns event compiler.

func (SettingEvent) ObjectID

func (o SettingEvent) ObjectID() int64

ObjectID returns ID of object.

func (*SettingEvent) SetEventAccountID

func (e *SettingEvent) SetEventAccountID(accountID int64)

func (*SettingEvent) SetEventID

func (e *SettingEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*SettingEvent) SetEventKind

func (e *SettingEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*SettingEvent) SetEventTime

func (e *SettingEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*SettingEvent) SetObject

func (e *SettingEvent) SetObject(o Setting)

SetObject sets event setting.

func (*SettingEvent) SetObjectID

func (o *SettingEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type SettingStore

type SettingStore struct {
	// contains filtered or unexported fields
}

SettingStore represents store for settings.

func NewSettingStore

func NewSettingStore(db *gosql.DB, table, eventTable string) *SettingStore

NewSettingStore creates a new instance of SettingStore.

func (*SettingStore) All

func (s *SettingStore) All() ([]Setting, error)

func (*SettingStore) Create

func (s *SettingStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*SettingStore) DB

func (s *SettingStore) DB() *gosql.DB

DB returns store database.

func (*SettingStore) Delete

func (s *SettingStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*SettingStore) Get

func (s *SettingStore) Get(id int64) (Setting, error)

Get returns setting by specified ID.

func (*SettingStore) GetByKey

func (s *SettingStore) GetByKey(key string) (Setting, error)

func (*SettingStore) Init

func (s *SettingStore) Init(ctx context.Context) error

func (*SettingStore) Sync

func (s *SettingStore) Sync(ctx context.Context) error

func (*SettingStore) Update

func (s *SettingStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Store

type Store interface {
	Init(ctx context.Context) error
	Sync(ctx context.Context) error
}

Store represents cached store.

type User

type User struct {
	AccountID    int64   `db:"account_id"`
	Login        string  `db:"login"`
	PasswordHash string  `db:"password_hash"`
	PasswordSalt string  `db:"password_salt"`
	Email        NString `db:"email"`
	FirstName    NString `db:"first_name"`
	LastName     NString `db:"last_name"`
	MiddleName   NString `db:"middle_name"`
	// contains filtered or unexported fields
}

User contains common information about user.

func (User) AccountKind

func (o User) AccountKind() AccountKind

AccountKind returns UserAccount kind.

func (User) Clone

func (o User) Clone() User

Clone creates copy of user.

func (User) ObjectID

func (o User) ObjectID() int64

ObjectID returns ID of object.

func (*User) SetObjectID

func (o *User) SetObjectID(id int64)

SetObjectID updates ID of object.

type UserEvent

type UserEvent struct {
	User
	// contains filtered or unexported fields
}

UserEvent represents an user event.

func (UserEvent) EventID

func (e UserEvent) EventID() int64

EventID returns id of this event.

func (UserEvent) EventKind

func (e UserEvent) EventKind() EventKind

EventKind returns type of this event.

func (UserEvent) EventTime

func (e UserEvent) EventTime() time.Time

EventTime returns time of this event.

func (UserEvent) Object

func (e UserEvent) Object() User

Object returns user.

func (UserEvent) ObjectID

func (o UserEvent) ObjectID() int64

ObjectID returns ID of object.

func (*UserEvent) SetEventAccountID

func (e *UserEvent) SetEventAccountID(accountID int64)

func (*UserEvent) SetEventID

func (e *UserEvent) SetEventID(id int64)

SetEventID updates id of this event.

func (*UserEvent) SetEventKind

func (e *UserEvent) SetEventKind(typ EventKind)

SetEventKind updates type of this event.

func (*UserEvent) SetEventTime

func (e *UserEvent) SetEventTime(t time.Time)

SetEventTime updates time of this event.

func (*UserEvent) SetObject

func (e *UserEvent) SetObject(o User)

SetObject sets event user.

func (*UserEvent) SetObjectID

func (o *UserEvent) SetObjectID(id int64)

SetObjectID updates ID of object.

type UserStore

type UserStore struct {
	// contains filtered or unexported fields
}

UserStore represents users store.

func NewUserStore

func NewUserStore(
	db *gosql.DB, table, eventTable, salt string,
) *UserStore

NewUserStore creates new instance of user store.

func (*UserStore) CheckPassword

func (s *UserStore) CheckPassword(user User, password string) bool

CheckPassword checks that passwords are the same.

func (*UserStore) Create

func (s *UserStore) Create(ctx context.Context, object TPtr) error

Create creates object and returns copy with valid ID.

func (*UserStore) DB

func (s *UserStore) DB() *gosql.DB

DB returns store database.

func (*UserStore) Delete

func (s *UserStore) Delete(ctx context.Context, id int64) error

Delete deletes compiler with specified ID.

func (*UserStore) Get

func (s *UserStore) Get(id int64) (User, error)

Get returns user by ID.

func (*UserStore) GetByAccount

func (s *UserStore) GetByAccount(id int64) (User, error)

GetByAccount returns user by login.

func (*UserStore) GetByLogin

func (s *UserStore) GetByLogin(login string) (User, error)

GetByLogin returns user by login.

func (*UserStore) Init

func (s *UserStore) Init(ctx context.Context) error

func (*UserStore) SetPassword

func (s *UserStore) SetPassword(user *User, password string) error

SetPassword modifies PasswordHash and PasswordSalt fields.

PasswordSalt will be replaced with random 16 byte string and PasswordHash will be calculated using password, salt and global salt.

func (*UserStore) Sync

func (s *UserStore) Sync(ctx context.Context) error

func (*UserStore) Update

func (s *UserStore) Update(ctx context.Context, object T) error

Update updates object with specified ID.

type Visit

type Visit struct {
	ID         int64  `db:"id"`
	Time       int64  `db:"time"`
	AccountID  NInt64 `db:"account_id"`
	SessionID  NInt64 `db:"session_id"`
	Host       string `db:"host"`
	Protocol   string `db:"protocol"`
	Method     string `db:"method" `
	RemoteAddr string `db:"remote_addr"`
	UserAgent  string `db:"user_agent"`
	Path       string `db:"path"`
	RealIP     string `db:"real_ip"`
	Status     int    `db:"status"`
}

Visit represents user visit.

func (Visit) EventID

func (o Visit) EventID() int64

EventID returns ID of visit.

func (Visit) EventTime

func (o Visit) EventTime() time.Time

EventTime return time of visit.

func (*Visit) SetEventID

func (o *Visit) SetEventID(id int64)

SetEventID sets ID of visit.

type VisitStore

type VisitStore struct {
	// contains filtered or unexported fields
}

VisitStore represents visit store.

func NewVisitStore

func NewVisitStore(dbConn *gosql.DB, table string) *VisitStore

NewVisitStore creates a new instance of ViewStore.

func (*VisitStore) Create

func (s *VisitStore) Create(ctx context.Context, visit *Visit) error

Create creates a new visit in the events.

func (*VisitStore) MakeFromContext

func (s *VisitStore) MakeFromContext(c echo.Context) Visit

MakeFromContext creates Visit from context.

Jump to

Keyboard shortcuts

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