2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-20 14:50:47 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
package console
|
2018-11-20 14:50:47 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/skyrings/skyring-common/tools/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ProjectMembers exposes methods to manage ProjectMembers table in database.
|
|
|
|
type ProjectMembers interface {
|
2018-12-27 15:30:15 +00:00
|
|
|
// GetByMemberID is a method for querying project members from the database by memberID.
|
|
|
|
GetByMemberID(ctx context.Context, memberID uuid.UUID) ([]ProjectMember, error)
|
2018-12-19 13:03:12 +00:00
|
|
|
// GetByProjectID is a method for querying project members from the database by projectID, offset and limit.
|
2018-12-28 12:07:35 +00:00
|
|
|
GetByProjectID(ctx context.Context, projectID uuid.UUID, pagination Pagination) ([]ProjectMember, error)
|
2018-11-20 14:50:47 +00:00
|
|
|
// Insert is a method for inserting project member into the database.
|
|
|
|
Insert(ctx context.Context, memberID, projectID uuid.UUID) (*ProjectMember, error)
|
2018-12-10 12:29:01 +00:00
|
|
|
// Delete is a method for deleting project member by memberID and projectID from the database.
|
|
|
|
Delete(ctx context.Context, memberID, projectID uuid.UUID) error
|
2018-11-20 14:50:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ProjectMember is a database object that describes ProjectMember entity.
|
|
|
|
type ProjectMember struct {
|
|
|
|
// FK on Users table.
|
|
|
|
MemberID uuid.UUID
|
|
|
|
// FK on Projects table.
|
|
|
|
ProjectID uuid.UUID
|
|
|
|
|
|
|
|
CreatedAt time.Time
|
|
|
|
}
|
2018-12-28 12:07:35 +00:00
|
|
|
|
|
|
|
// Pagination defines pagination, filtering and sorting rules
|
|
|
|
type Pagination struct {
|
|
|
|
Limit int
|
|
|
|
Offset int64
|
|
|
|
Search string
|
|
|
|
Order ProjectMemberOrder
|
|
|
|
}
|
|
|
|
|
|
|
|
// ProjectMemberOrder is used for querying project members in specified order
|
|
|
|
type ProjectMemberOrder int8
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Name indicates that we should order by first name
|
|
|
|
Name ProjectMemberOrder = 1
|
|
|
|
// Email indicates that we should order by email
|
|
|
|
Email ProjectMemberOrder = 2
|
|
|
|
// Created indicates that we should order by created date
|
|
|
|
Created ProjectMemberOrder = 3
|
|
|
|
)
|