Documentation
¶
Overview ¶
Package models contains tools for working with solve objects stored in different databases like SQLite or Postgres.
Index ¶
- Constants
- func GetAccountID(ctx context.Context) int64
- func GetBuiltInRoles() []string
- func WithAccountID(ctx context.Context, id int64) context.Context
- type Account
- type AccountEvent
- func (e AccountEvent) EventID() int64
- func (e AccountEvent) EventKind() EventKind
- func (e AccountEvent) EventTime() time.Time
- func (e AccountEvent) Object() Account
- func (o AccountEvent) ObjectID() int64
- func (e *AccountEvent) SetEventAccountID(accountID int64)
- func (e *AccountEvent) SetEventID(id int64)
- func (e *AccountEvent) SetEventKind(typ EventKind)
- func (e *AccountEvent) SetEventTime(t time.Time)
- func (e *AccountEvent) SetObject(o Account)
- func (o *AccountEvent) SetObjectID(id int64)
- type AccountKind
- type AccountRole
- type AccountRoleEvent
- func (e AccountRoleEvent) EventID() int64
- func (e AccountRoleEvent) EventKind() EventKind
- func (e AccountRoleEvent) EventTime() time.Time
- func (e AccountRoleEvent) Object() AccountRole
- func (o AccountRoleEvent) ObjectID() int64
- func (e *AccountRoleEvent) SetEventAccountID(accountID int64)
- func (e *AccountRoleEvent) SetEventID(id int64)
- func (e *AccountRoleEvent) SetEventKind(typ EventKind)
- func (e *AccountRoleEvent) SetEventTime(t time.Time)
- func (e *AccountRoleEvent) SetObject(o AccountRole)
- func (o *AccountRoleEvent) SetObjectID(id int64)
- type AccountRoleStore
- func (s *AccountRoleStore) Create(ctx context.Context, object TPtr) error
- func (s *AccountRoleStore) DB() *gosql.DB
- func (s *AccountRoleStore) Delete(ctx context.Context, id int64) error
- func (s *AccountRoleStore) FindByAccount(id int64) ([]AccountRole, error)
- func (s *AccountRoleStore) Get(id int64) (AccountRole, error)
- func (s *AccountRoleStore) Init(ctx context.Context) error
- func (s *AccountRoleStore) Sync(ctx context.Context) error
- func (s *AccountRoleStore) Update(ctx context.Context, object T) error
- type AccountStore
- func (s *AccountStore) Create(ctx context.Context, object TPtr) error
- func (s *AccountStore) DB() *gosql.DB
- func (s *AccountStore) Delete(ctx context.Context, id int64) error
- func (s *AccountStore) Get(id int64) (Account, error)
- func (s *AccountStore) Init(ctx context.Context) error
- func (s *AccountStore) Sync(ctx context.Context) error
- func (s *AccountStore) Update(ctx context.Context, object T) error
- type Cloner
- type EventKind
- type JSON
- type NInt64
- type NString
- type ObjectEventPtr
- type Pool
- type PoolEvent
- func (e PoolEvent) EventID() int64
- func (e PoolEvent) EventKind() EventKind
- func (e PoolEvent) EventTime() time.Time
- func (e PoolEvent) Object() Pool
- func (o PoolEvent) ObjectID() int64
- func (e *PoolEvent) SetEventAccountID(accountID int64)
- func (e *PoolEvent) SetEventID(id int64)
- func (e *PoolEvent) SetEventKind(typ EventKind)
- func (e *PoolEvent) SetEventTime(t time.Time)
- func (e *PoolEvent) SetObject(o Pool)
- func (o *PoolEvent) SetObjectID(id int64)
- type PoolStore
- func (s *PoolStore) Create(ctx context.Context, object TPtr) error
- func (s *PoolStore) DB() *gosql.DB
- func (s *PoolStore) Delete(ctx context.Context, id int64) error
- func (s *PoolStore) Init(ctx context.Context) error
- func (s *PoolStore) Sync(ctx context.Context) error
- func (s *PoolStore) Update(ctx context.Context, object T) error
- type Problem
- type ProblemEvent
- func (e ProblemEvent) EventID() int64
- func (e ProblemEvent) EventKind() EventKind
- func (e ProblemEvent) EventTime() time.Time
- func (e ProblemEvent) Object() Problem
- func (o ProblemEvent) ObjectID() int64
- func (e *ProblemEvent) SetEventAccountID(accountID int64)
- func (e *ProblemEvent) SetEventID(id int64)
- func (e *ProblemEvent) SetEventKind(typ EventKind)
- func (e *ProblemEvent) SetEventTime(t time.Time)
- func (e *ProblemEvent) SetObject(o Problem)
- func (o *ProblemEvent) SetObjectID(id int64)
- type ProblemStore
- func (s *ProblemStore) Create(ctx context.Context, object TPtr) error
- func (s *ProblemStore) DB() *gosql.DB
- func (s *ProblemStore) Delete(ctx context.Context, id int64) error
- func (s *ProblemStore) Init(ctx context.Context) error
- func (s *ProblemStore) Sync(ctx context.Context) error
- func (s *ProblemStore) Update(ctx context.Context, object T) error
- type Quiz
- type QuizEvent
- func (e QuizEvent) EventID() int64
- func (e QuizEvent) EventKind() EventKind
- func (e QuizEvent) EventTime() time.Time
- func (e QuizEvent) Object() Quiz
- func (o QuizEvent) ObjectID() int64
- func (e *QuizEvent) SetEventAccountID(accountID int64)
- func (e *QuizEvent) SetEventID(id int64)
- func (e *QuizEvent) SetEventKind(typ EventKind)
- func (e *QuizEvent) SetEventTime(t time.Time)
- func (e *QuizEvent) SetObject(o Quiz)
- func (o *QuizEvent) SetObjectID(id int64)
- type QuizStore
- func (s *QuizStore) Create(ctx context.Context, object TPtr) error
- func (s *QuizStore) DB() *gosql.DB
- func (s *QuizStore) Delete(ctx context.Context, id int64) error
- func (s *QuizStore) Init(ctx context.Context) error
- func (s *QuizStore) Sync(ctx context.Context) error
- func (s *QuizStore) Update(ctx context.Context, object T) error
- type Role
- type RoleEdge
- type RoleEdgeEvent
- func (e RoleEdgeEvent) EventID() int64
- func (e RoleEdgeEvent) EventKind() EventKind
- func (e RoleEdgeEvent) EventTime() time.Time
- func (e RoleEdgeEvent) Object() RoleEdge
- func (o RoleEdgeEvent) ObjectID() int64
- func (e *RoleEdgeEvent) SetEventAccountID(accountID int64)
- func (e *RoleEdgeEvent) SetEventID(id int64)
- func (e *RoleEdgeEvent) SetEventKind(typ EventKind)
- func (e *RoleEdgeEvent) SetEventTime(t time.Time)
- func (e *RoleEdgeEvent) SetObject(o RoleEdge)
- func (o *RoleEdgeEvent) SetObjectID(id int64)
- type RoleEdgeStore
- func (s *RoleEdgeStore) Create(ctx context.Context, object TPtr) error
- func (s *RoleEdgeStore) DB() *gosql.DB
- func (s *RoleEdgeStore) Delete(ctx context.Context, id int64) error
- func (s *RoleEdgeStore) FindByRole(id int64) ([]RoleEdge, error)
- func (s *RoleEdgeStore) Get(id int64) (RoleEdge, error)
- func (s *RoleEdgeStore) Init(ctx context.Context) error
- func (s *RoleEdgeStore) Sync(ctx context.Context) error
- func (s *RoleEdgeStore) Update(ctx context.Context, object T) error
- type RoleEvent
- func (e RoleEvent) EventID() int64
- func (e RoleEvent) EventKind() EventKind
- func (e RoleEvent) EventTime() time.Time
- func (e RoleEvent) Object() Role
- func (o RoleEvent) ObjectID() int64
- func (e *RoleEvent) SetEventAccountID(accountID int64)
- func (e *RoleEvent) SetEventID(id int64)
- func (e *RoleEvent) SetEventKind(typ EventKind)
- func (e *RoleEvent) SetEventTime(t time.Time)
- func (e *RoleEvent) SetObject(o Role)
- func (o *RoleEvent) SetObjectID(id int64)
- type RoleStore
- func (s *RoleStore) All() ([]Role, error)
- func (s *RoleStore) Create(ctx context.Context, object TPtr) error
- func (s *RoleStore) DB() *gosql.DB
- func (s *RoleStore) Delete(ctx context.Context, id int64) error
- func (s *RoleStore) Get(id int64) (Role, error)
- func (s *RoleStore) GetByName(name string) (Role, error)
- func (s *RoleStore) Init(ctx context.Context) error
- func (s *RoleStore) Sync(ctx context.Context) error
- func (s *RoleStore) Update(ctx context.Context, object T) error
- type Session
- type SessionEvent
- func (e SessionEvent) EventID() int64
- func (e SessionEvent) EventKind() EventKind
- func (e SessionEvent) EventTime() time.Time
- func (e SessionEvent) Object() Session
- func (o SessionEvent) ObjectID() int64
- func (e *SessionEvent) SetEventAccountID(accountID int64)
- func (e *SessionEvent) SetEventID(id int64)
- func (e *SessionEvent) SetEventKind(typ EventKind)
- func (e *SessionEvent) SetEventTime(t time.Time)
- func (e *SessionEvent) SetObject(o Session)
- func (o *SessionEvent) SetObjectID(id int64)
- type SessionStore
- func (s *SessionStore) Create(ctx context.Context, object TPtr) error
- func (s *SessionStore) DB() *gosql.DB
- func (s *SessionStore) Delete(ctx context.Context, id int64) error
- func (s *SessionStore) FindByAccount(id int64) ([]Session, error)
- func (s *SessionStore) Get(id int64) (Session, error)
- func (s *SessionStore) GetByCookie(cookie string) (Session, error)
- func (s *SessionStore) Init(ctx context.Context) error
- func (s *SessionStore) Sync(ctx context.Context) error
- func (s *SessionStore) Update(ctx context.Context, object T) error
- type Setting
- type SettingEvent
- func (e SettingEvent) EventID() int64
- func (e SettingEvent) EventKind() EventKind
- func (e SettingEvent) EventTime() time.Time
- func (e SettingEvent) Object() Setting
- func (o SettingEvent) ObjectID() int64
- func (e *SettingEvent) SetEventAccountID(accountID int64)
- func (e *SettingEvent) SetEventID(id int64)
- func (e *SettingEvent) SetEventKind(typ EventKind)
- func (e *SettingEvent) SetEventTime(t time.Time)
- func (e *SettingEvent) SetObject(o Setting)
- func (o *SettingEvent) SetObjectID(id int64)
- type SettingStore
- func (s *SettingStore) All() ([]Setting, error)
- func (s *SettingStore) Create(ctx context.Context, object TPtr) error
- func (s *SettingStore) DB() *gosql.DB
- func (s *SettingStore) Delete(ctx context.Context, id int64) error
- func (s *SettingStore) Get(id int64) (Setting, error)
- func (s *SettingStore) GetByKey(key string) (Setting, error)
- func (s *SettingStore) Init(ctx context.Context) error
- func (s *SettingStore) Sync(ctx context.Context) error
- func (s *SettingStore) Update(ctx context.Context, object T) error
- type Store
- type User
- type UserEvent
- func (e UserEvent) EventID() int64
- func (e UserEvent) EventKind() EventKind
- func (e UserEvent) EventTime() time.Time
- func (e UserEvent) Object() User
- func (o UserEvent) ObjectID() int64
- func (e *UserEvent) SetEventAccountID(accountID int64)
- func (e *UserEvent) SetEventID(id int64)
- func (e *UserEvent) SetEventKind(typ EventKind)
- func (e *UserEvent) SetEventTime(t time.Time)
- func (e *UserEvent) SetObject(o User)
- func (o *UserEvent) SetObjectID(id int64)
- type UserStore
- func (s *UserStore) CheckPassword(user User, password string) bool
- func (s *UserStore) Create(ctx context.Context, object TPtr) error
- func (s *UserStore) DB() *gosql.DB
- func (s *UserStore) Delete(ctx context.Context, id int64) error
- func (s *UserStore) Get(id int64) (User, error)
- func (s *UserStore) GetByAccount(id int64) (User, error)
- func (s *UserStore) GetByLogin(login string) (User, error)
- func (s *UserStore) Init(ctx context.Context) error
- func (s *UserStore) SetPassword(user *User, password string) error
- func (s *UserStore) Sync(ctx context.Context) error
- func (s *UserStore) Update(ctx context.Context, object T) error
- type Visit
- type VisitStore
Constants ¶
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 ¶
GetAccountID returns account ID or zero if there is no account.
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) 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) 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 ¶
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) 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) 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 ¶
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) 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.
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.
type Cloner ¶
type Cloner[T any] interface { Clone() T }
Cloner represents object that can be cloned.
type JSON ¶
type JSON []byte
JSON represents json value.
func (*JSON) UnmarshalJSON ¶
UnmarshalJSON unmarshals JSON.
type NString ¶
type NString string
NString represents nullable string with empty value means null value.
type ObjectEventPtr ¶
type PoolEvent ¶
type PoolEvent struct {
Pool
// contains filtered or unexported fields
}
func (PoolEvent) EventKind ¶
func (e PoolEvent) EventKind() EventKind
EventKind returns type of this event.
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 ¶
SetEventTime updates time of this event.
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 ¶
NewPoolStore creates a new instance of PoolStore.
type Problem ¶
type Problem struct {
// contains filtered or unexported fields
}
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) 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 ¶
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.
type QuizEvent ¶
type QuizEvent struct {
Quiz
// contains filtered or unexported fields
}
func (QuizEvent) EventKind ¶
func (e QuizEvent) EventKind() EventKind
EventKind returns type of this event.
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 ¶
SetEventTime updates time of this event.
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 ¶
NewQuizStore creates a new instance of QuizStore.
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.
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) 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) 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 ¶
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) FindByRole ¶
func (s *RoleEdgeStore) FindByRole(id int64) ([]RoleEdge, error)
FindByRole returns edges by parent ID.
type RoleEvent ¶
type RoleEvent struct {
Role
// contains filtered or unexported fields
}
RoleEvent represents role event.
func (RoleEvent) EventKind ¶
func (e RoleEvent) EventKind() EventKind
EventKind returns type of this event.
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 ¶
SetEventTime updates time of this event.
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 ¶
NewRoleStore creates a new instance of RoleStore.
func (*RoleStore) Get ¶
Get returns role by ID.
If there is no role with specified ID then sql.ErrNoRows will be returned.
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) GenerateSecret ¶
GenerateSecret generates a new value for session secret.
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) 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 ¶
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) 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.
type Setting ¶
type Setting struct {
Key string `db:"key"`
Value string `db:"value"`
// contains filtered or unexported fields
}
Setting represents setting.
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) 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 ¶
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)
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.
type UserEvent ¶
type UserEvent struct {
User
// contains filtered or unexported fields
}
UserEvent represents an user event.
func (UserEvent) EventKind ¶
func (e UserEvent) EventKind() EventKind
EventKind returns type of this event.
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 ¶
SetEventTime updates time of this event.
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 ¶
NewUserStore creates new instance of user store.
func (*UserStore) CheckPassword ¶
CheckPassword checks that passwords are the same.
func (*UserStore) GetByAccount ¶
GetByAccount returns user by login.
func (*UserStore) GetByLogin ¶
GetByLogin returns user by login.
func (*UserStore) SetPassword ¶
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.
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.
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.