Documentation ¶
Index ¶
- type AuthService
- func (a *AuthService) Auhenticate(ctx context.Context, opts *entity.AuthUserOptions) (*entity.Auth, error)
- func (s *AuthService) CreateAuth(ctx context.Context, auth *entity.Auth) error
- func (s *AuthService) DeleteAuth(ctx context.Context, id int64) error
- func (s *AuthService) FindAuthByID(ctx context.Context, id int64) (*entity.Auth, error)
- func (s *AuthService) FindAuths(ctx context.Context, filter service.AuthFilter) (entity.Auths, int, error)
- type ContractService
- func (cs *ContractService) CreateContract(ctx context.Context, contract *entity.Contract) error
- func (cs *ContractService) DeleteContract(ctx context.Context, id int64) error
- func (cs *ContractService) FindContractByID(ctx context.Context, id int64) (*entity.Contract, error)
- func (cs *ContractService) FindContracts(ctx context.Context, filter service.ContractFilter) (entity.Contracts, int, error)
- func (cs *ContractService) FindRevisionByContractAndRev(ctx context.Context, contractID int64, rev entity.RevisionNumber) (*entity.Revision, error)
- func (cs *ContractService) MakeRevision(ctx context.Context, revision *entity.Revision) error
- func (cs *ContractService) UpdateContract(ctx context.Context, id int64, upd service.ContractUpdate) (*entity.Contract, error)
- type DB
- type StateService
- func (s *StateService) CreateState(ctx context.Context, state *entity.State) error
- func (s *StateService) FindStateByRevisionID(ctx context.Context, revisionID int64) (*entity.State, error)
- func (s *StateService) UpdateState(ctx context.Context, revisionID int64, value entity.StateValue) (*entity.State, error)
- type Tx
- type UserService
- func (s *UserService) CreateUser(ctx context.Context, user *entity.User) error
- func (s *UserService) DeleteUser(ctx context.Context, id int64) error
- func (s *UserService) FindUserByEmail(ctx context.Context, email string) (*entity.User, error)
- func (s *UserService) FindUserByID(ctx context.Context, id int64) (*entity.User, error)
- func (s *UserService) FindUsers(ctx context.Context, filter service.UserFilter) (entity.Users, int, error)
- func (u *UserService) UpdateUser(ctx context.Context, id int64, upd service.UserUpdate) (*entity.User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthService ¶
type AuthService struct {
// contains filtered or unexported fields
}
AuthService is a service for managing authentication.
func NewAuthService ¶
func NewAuthService(db *DB) *AuthService
NewAuthService creates a new AuthService.
func (*AuthService) Auhenticate ¶
func (a *AuthService) Auhenticate(ctx context.Context, opts *entity.AuthUserOptions) (*entity.Auth, error)
Auhenticate not implemented.
func (*AuthService) CreateAuth ¶
CreateAuth creates a new auth. If is attached to a user, links the auth to the user, otherwise creates a new user. On success, the auth.ID is set.
func (*AuthService) DeleteAuth ¶
func (s *AuthService) DeleteAuth(ctx context.Context, id int64) error
DeleteAuth deletes an auth. Do not delete underlying user.
func (*AuthService) FindAuthByID ¶
FindAuthByID returns a single auth by its id. Returns ENOTFOUND if the auth does not exist.
type ContractService ¶
type ContractService struct {
// contains filtered or unexported fields
}
ContractService is the postgres implementation of the contract service.
func NewContractService ¶
func NewContractService(db *DB) *ContractService
NewContractService creates a new contract service.
func (*ContractService) CreateContract ¶
CreateContract creates a new contract. Return EINVALID if the contract is invalid. Return EEXISTS if the contract already exists. Return EFORBIDDEN if the user is not allowed to create a contract. Return EUNAUTHORIZED if the contract owner is not the authenticated user or user is not authenticated.
func (*ContractService) DeleteContract ¶
func (cs *ContractService) DeleteContract(ctx context.Context, id int64) error
DeleteContract deletes the contract with the given id. Return EUNAUTHORIZED if the contract is not the same as the authenticated user. Return ENOTFOUND if the contract does not exist. This service also deletes the revisions of the contract.
func (*ContractService) FindContractByID ¶
func (cs *ContractService) FindContractByID(ctx context.Context, id int64) (*entity.Contract, error)
FindContractByID returns the contract with the given id. Return ENOTFOUND if the contract does not exist.
func (*ContractService) FindContracts ¶
func (cs *ContractService) FindContracts(ctx context.Context, filter service.ContractFilter) (entity.Contracts, int, error)
FindContracts returns a list of contracts filtered by the given options. Also returns the total count of contracts.
func (*ContractService) FindRevisionByContractAndRev ¶
func (cs *ContractService) FindRevisionByContractAndRev(ctx context.Context, contractID int64, rev entity.RevisionNumber) (*entity.Revision, error)
FindRevisionByContractAndRev returns the revision searched by the given contract and revision number. if rev passed is eq 0, it returns the latest revision. Return ENOTFOUND if the revision does not exist.
func (*ContractService) MakeRevision ¶
MakeRevision creates a new revision of the contract. Return ENOTFOUND if the contract does not exist. Return EINVALID if the revision is invalid. It shouldn't return ECONFLICT because there's a UNIQUE constraint on the revision number and the Contract ID.
func (*ContractService) UpdateContract ¶
func (cs *ContractService) UpdateContract(ctx context.Context, id int64, upd service.ContractUpdate) (*entity.Contract, error)
UpdateContract updates the given contract. Return ENOTFOUND if the contract does not exist. Return EUNAUTHORIZED if the contract is not owned by the authenticated user.
type DB ¶
DB represents the database connection.
type StateService ¶ added in v0.0.7
type StateService struct { // CacheStateSearchService is the cache for searching states. // It is used to avoid querying the database when the state is already in the cache. // Can be nil if the cache is not enabled. CacheStateSearchService service.StateSearchService // LockService is the service for locking the state during I/O operations. CreateLockService func(ctx context.Context, revisionID int64) (service.LockService, error) // contains filtered or unexported fields }
StateService is the implementation of service.StateService for PostgreSQL.
func NewStateService ¶ added in v0.0.7
func NewStateService(db *DB) *StateService
NewStateService creates a new StateService.
func (*StateService) CreateState ¶ added in v0.0.7
CreateState creates a new state.
func (*StateService) FindStateByRevisionID ¶ added in v0.0.7
func (s *StateService) FindStateByRevisionID(ctx context.Context, revisionID int64) (*entity.State, error)
FindStateByRevisionID finds the state by revision ID and the authenticated user retrieved from the context. If cache is enabled, it tries to find the state in the cache first.
func (*StateService) UpdateState ¶ added in v0.0.7
func (s *StateService) UpdateState(ctx context.Context, revisionID int64, value entity.StateValue) (*entity.State, error)
UpdateState updates the state.
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
UserService represents a service for managing users.
func NewUserService ¶
func NewUserService(db *DB) *UserService
NewUserService creates a new user service.
func (*UserService) CreateUser ¶
CreateUser creates a new user.
func (*UserService) DeleteUser ¶
func (s *UserService) DeleteUser(ctx context.Context, id int64) error
DeleteUser deletes the user with the given id. Return EUNAUTHORIZED if the user is not the same as the authenticated user. Return ENOTFOUND if the user does not exist.
func (*UserService) FindUserByEmail ¶
FindUserByEmail returns the user with the given email. Return ENOTFOUND if the user does not exist.
func (*UserService) FindUserByID ¶
FindUserByID returns the user with the given id. Return ENOTFOUND if the user does not exist.
func (*UserService) FindUsers ¶
func (s *UserService) FindUsers(ctx context.Context, filter service.UserFilter) (entity.Users, int, error)
FindUsers retrieves a list of users by filter. Also returns total count of matching users which may differ from returned results if filter.Limit is specified.
func (*UserService) UpdateUser ¶
func (u *UserService) UpdateUser(ctx context.Context, id int64, upd service.UserUpdate) (*entity.User, error)
UpdateUser updates the given user. Return EUNAUTHORIZED if the user is not the same as the authenticated user. Return ENOTFOUND if the user does not exist.