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"
|
|
|
|
|
2020-03-30 10:08:50 +01:00
|
|
|
"storj.io/common/uuid"
|
2018-11-20 14:50:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ProjectMembers exposes methods to manage ProjectMembers table in database.
|
2019-09-10 14:24:16 +01:00
|
|
|
//
|
|
|
|
// architecture: Database
|
2018-11-20 14:50:47 +00:00
|
|
|
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)
|
2023-06-08 00:16:53 +01:00
|
|
|
// GetPagedWithInvitationsByProjectID is a method for querying project members and invitations from the database by projectID and cursor.
|
|
|
|
GetPagedWithInvitationsByProjectID(ctx context.Context, projectID uuid.UUID, cursor ProjectMembersCursor) (*ProjectMembersPage, 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
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// ProjectMembersCursor holds info for project members cursor pagination.
|
2019-08-12 11:22:32 +01:00
|
|
|
type ProjectMembersCursor struct {
|
|
|
|
Search string
|
|
|
|
Limit uint
|
|
|
|
Page uint
|
|
|
|
Order ProjectMemberOrder
|
2019-09-12 15:19:30 +01:00
|
|
|
OrderDirection OrderDirection
|
2019-08-12 11:22:32 +01:00
|
|
|
}
|
|
|
|
|
2023-06-08 00:16:53 +01:00
|
|
|
// ProjectMembersPage represents a page of project members and invitations.
|
2019-08-12 11:22:32 +01:00
|
|
|
type ProjectMembersPage struct {
|
2023-06-08 00:16:53 +01:00
|
|
|
ProjectMembers []ProjectMember
|
|
|
|
ProjectInvitations []ProjectInvitation
|
2019-08-12 11:22:32 +01:00
|
|
|
|
|
|
|
Search string
|
|
|
|
Limit uint
|
|
|
|
Order ProjectMemberOrder
|
2019-09-12 15:19:30 +01:00
|
|
|
OrderDirection OrderDirection
|
2019-08-12 11:22:32 +01:00
|
|
|
Offset uint64
|
2023-08-02 16:32:53 +01:00
|
|
|
PageCount uint
|
|
|
|
CurrentPage uint
|
|
|
|
TotalCount uint64
|
2018-12-28 12:07:35 +00:00
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// ProjectMemberOrder is used for querying project members in specified order.
|
2018-12-28 12:07:35 +00:00
|
|
|
type ProjectMemberOrder int8
|
|
|
|
|
|
|
|
const (
|
2020-08-11 15:50:01 +01:00
|
|
|
// Name indicates that we should order by full name.
|
2018-12-28 12:07:35 +00:00
|
|
|
Name ProjectMemberOrder = 1
|
2020-08-11 15:50:01 +01:00
|
|
|
// Email indicates that we should order by email.
|
2018-12-28 12:07:35 +00:00
|
|
|
Email ProjectMemberOrder = 2
|
2020-08-11 15:50:01 +01:00
|
|
|
// Created indicates that we should order by created date.
|
2018-12-28 12:07:35 +00:00
|
|
|
Created ProjectMemberOrder = 3
|
|
|
|
)
|