Documentation ¶
Index ¶
- Variables
- type Client
- type GroupRepository
- func (repo *GroupRepository) AddUser(ctx context.Context, roleID int32, groupID, userID uuid.UUID, isAdmin bool) error
- func (repo *GroupRepository) Create(ctx context.Context, group *model.Group) error
- func (repo *GroupRepository) Get(ctx context.Context, id uuid.UUID) (*model.Group, error)
- func (repo *GroupRepository) GetByUser(ctx context.Context, user uuid.UUID) (groups []*model.Group, err error)
- func (repo *GroupRepository) GetRoleOfMember(ctx context.Context, user, group uuid.UUID) (role *model.Role, err error)
- func (repo *GroupRepository) GetUserIDs(ctx context.Context, group uuid.UUID) (ids []uuid.UUID, err error)
- func (repo *GroupRepository) TaskExists(ctx context.Context, group, task uuid.UUID) (ok bool)
- func (repo *GroupRepository) UserExists(ctx context.Context, group, user uuid.UUID) (ok bool)
- type InviteRepository
- func (repo *InviteRepository) Create(ctx context.Context, invite uuid.UUID, role int32, group uuid.UUID, uses int) error
- func (repo *InviteRepository) Exists(ctx context.Context, invite, group uuid.UUID) (ok bool)
- func (repo *InviteRepository) Use(ctx context.Context, invite uuid.UUID, user uuid.UUID) error
- type RoleRepository
- type Store
- func (store *Store) Close()
- func (store *Store) Group() store.GroupRepository
- func (store *Store) Invite() store.InviteRepository
- func (store *Store) Ping(ctx context.Context) error
- func (store *Store) Role() store.RoleRepository
- func (store *Store) Task() store.TaskRepository
- func (store *Store) Token() store.TokenRepository
- func (store *Store) User() store.UserRepository
- type TaskRepository
- func (repo *TaskRepository) AddToGroup(ctx context.Context, task, group uuid.UUID) error
- func (repo *TaskRepository) AddToUser(ctx context.Context, from, task, to uuid.UUID) error
- func (repo *TaskRepository) AllByGroupAndUser(ctx context.Context, group uuid.UUID, user uuid.UUID) ([]*model.Task, error)
- func (repo *TaskRepository) AllByUser(ctx context.Context, user uuid.UUID) ([]*model.Task, error)
- func (repo *TaskRepository) Create(ctx context.Context, task *model.Task) error
- func (repo *TaskRepository) Exists(ctx context.Context, id uuid.UUID) (ok bool)
- func (repo *TaskRepository) ForceAddToUser(ctx context.Context, userID, taskID uuid.UUID) error
- func (repo *TaskRepository) GetByUserAndID(ctx context.Context, user, task uuid.UUID) (*model.Task, error)
- type TokenRepository
- type UserRepository
- func (repo *UserRepository) AddToGroup(ctx context.Context, user, group uuid.UUID, r *model.Role, isAdmin bool) error
- func (repo *UserRepository) Create(ctx context.Context, u *model.User) error
- func (repo *UserRepository) Exists(ctx context.Context, id string) bool
- func (repo *UserRepository) Get(ctx context.Context, id uuid.UUID) (u *model.User, err error)
- func (repo *UserRepository) GetByEmail(ctx context.Context, email string) (u *model.User, err error)
Constants ¶
This section is empty.
Variables ¶
var ( TestUser1 = &model.User{ ID: uuid.New(), Pass: "second_password", Email: "testemail1@xd.ru", } TestUser2 = &model.User{ ID: uuid.New(), Pass: "some_passwords", Email: "good_email2@example.com", } TestUser3 = &model.User{ ID: uuid.New(), Pass: "some_password", Email: TestUser1.Email, } TestGroup1 = &model.Group{ ID: uuid.New(), Name: "test group", Owner: TestUser1.ID, Description: "test description", CreatedAt: time.Now(), } TestGroup2 = &model.Group{ ID: uuid.New(), Name: "another test group", Owner: TestUser1.ID, Description: "another description", CreatedAt: time.Now(), } TestToken1 = &model.Token{ UserID: TestUser1.ID, Token: "some token", ExpiresAt: time.Now().UTC(), Expires: true, } TestToken2 = &model.Token{ UserID: TestUser1.ID, Token: TestToken1.Token, ExpiresAt: time.Now().UTC(), Expires: false, } TestToken3 = &model.Token{ UserID: TestUser1.ID, Token: "another token", ExpiresAt: time.Now().UTC(), Expires: false, } TestInvite1 = uuid.New() TestInvite2 = uuid.New() TestRole1 = &model.Role{ Members: 3, Tasks: 4, Reviews: 2, Comments: 1, } // TEST TASKS // TestTask1 = &model.Task{ ID: uuid.New(), Name: uuid.NewString(), Description: uuid.NewString(), CreatedAt: time.Now(), CreatedBy: TestUser1.ID, Status: "NEW", } )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type GroupRepository ¶
type GroupRepository struct {
// contains filtered or unexported fields
}
GroupRepository ...
func NewGroupRepository ¶
func NewGroupRepository(cli Client) *GroupRepository
NewGroupRepository return new instance of GroupRepository.
func (*GroupRepository) AddUser ¶
func (repo *GroupRepository) AddUser(ctx context.Context, roleID int32, groupID, userID uuid.UUID, isAdmin bool) error
AddUser adds user to group.
func (*GroupRepository) Create ¶
Create created new record about group.
Errors: store.ErrGroupAlreadyExists group with provided ID/Name already exists; store.ErrBadData bad foreign key to create group;
func (*GroupRepository) GetByUser ¶
func (repo *GroupRepository) GetByUser(ctx context.Context, user uuid.UUID) (groups []*model.Group, err error)
GetByUser ...
func (*GroupRepository) GetRoleOfMember ¶
func (repo *GroupRepository) GetRoleOfMember(ctx context.Context, user, group uuid.UUID) (role *model.Role, err error)
GetRoleOfMember return role of user in provided group.
func (*GroupRepository) GetUserIDs ¶
func (repo *GroupRepository) GetUserIDs(ctx context.Context, group uuid.UUID) (ids []uuid.UUID, err error)
GetUserIDs ...
func (*GroupRepository) TaskExists ¶
TaskExists return existence of relation between task and group.
func (*GroupRepository) UserExists ¶
UserExists ...
type InviteRepository ¶
type InviteRepository struct {
// contains filtered or unexported fields
}
func NewInviteRepository ¶
func NewInviteRepository(cli Client) *InviteRepository
NewInviteRepository create new invite repository that encapsulates logic to store invites.
func (*InviteRepository) Create ¶
func (repo *InviteRepository) Create(ctx context.Context, invite uuid.UUID, role int32, group uuid.UUID, uses int) error
Create stores invite with provided data.
type RoleRepository ¶
type RoleRepository struct {
// contains filtered or unexported fields
}
func NewRoleRepository ¶
func NewRoleRepository(cli Client) *RoleRepository
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is implementation of storage Interface.
func New ¶
func New( client Client, user *UserRepository, group *GroupRepository, token *TokenRepository, task *TaskRepository, invite *InviteRepository, role *RoleRepository, ) *Store
New ...
func (*Store) Group ¶
func (store *Store) Group() store.GroupRepository
Group return group repository.
func (*Store) Invite ¶
func (store *Store) Invite() store.InviteRepository
Invite return invite repository.
func (*Store) Role ¶
func (store *Store) Role() store.RoleRepository
func (*Store) Token ¶
func (store *Store) Token() store.TokenRepository
Token return token repository.
type TaskRepository ¶
type TaskRepository struct {
// contains filtered or unexported fields
}
func NewTaskRepository ¶
func NewTaskRepository(cli Client) *TaskRepository
NewTaskRepository return newly initialized object of task repository
func (*TaskRepository) AddToGroup ¶
AddToGroup add relation task-group.
func (*TaskRepository) AddToUser ¶
AddToUser add task to user.
Arguments summary info: from - is id of user who is doing addition; task - is task id; to - is id of user who will receive task.
func (*TaskRepository) AllByGroupAndUser ¶
func (repo *TaskRepository) AllByGroupAndUser(ctx context.Context, group uuid.UUID, user uuid.UUID) ([]*model.Task, error)
AllByGroupAndUser return all related to user tasks.
func (*TaskRepository) AllByUser ¶
AllByUser return all tasks related to user.
Task will be returned to user if this cases: * User is admin of group to which task is related; * user is related to group; * user has permission to read tasks in group where task is created.
func (*TaskRepository) ForceAddToUser ¶
ForceAddToUser add task to user without any permission checks in it.
func (*TaskRepository) GetByUserAndID ¶
func (repo *TaskRepository) GetByUserAndID(ctx context.Context, user, task uuid.UUID) (*model.Task, error)
GetByUserAndID return tasks if it related to user.
Task will be returned to user if this cases: * User is admin of group to which task is related; * user is related to group; * user has permission to read tasks in group where task is created.
type TokenRepository ¶
type TokenRepository struct {
// contains filtered or unexported fields
}
func NewTokenRepository ¶
func NewTokenRepository(cli Client) *TokenRepository
NewTokenRepository is constructor of token repository.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
UserRepository ...
func (*UserRepository) AddToGroup ¶
func (repo *UserRepository) AddToGroup(ctx context.Context, user, group uuid.UUID, r *model.Role, isAdmin bool) error
AddToGroup ...
func (*UserRepository) Create ¶
Create creates record about user into db.
repo.RegisterUser(context.Background(), &model.User{ID: uuid.New(), Name: "name", Pass: "password"})
func (*UserRepository) Exists ¶
func (repo *UserRepository) Exists(ctx context.Context, id string) bool
Exists checks if user exist with provided id or username. Returns boolean statement that shows existing of user.
func (*UserRepository) GetByEmail ¶
func (repo *UserRepository) GetByEmail( ctx context.Context, email string, ) ( u *model.User, err error, )
GetByEmail return user with provided username. If user does not exist returns store.ErrNotFound error