Documentation ¶
Overview ¶
Package repo provides the data access layer for the application.
Index ¶
- Variables
- type AllRepos
- type AssetID
- type AttachmentRepo
- func (r *AttachmentRepo) Create(ctx context.Context, itemID, docID uuid.UUID, typ attachment.Type) (*ent.Attachment, error)
- func (r *AttachmentRepo) Delete(ctx context.Context, id uuid.UUID) error
- func (r *AttachmentRepo) Get(ctx context.Context, id uuid.UUID) (*ent.Attachment, error)
- func (r *AttachmentRepo) Update(ctx context.Context, itemID uuid.UUID, data *ItemAttachmentUpdate) (*ent.Attachment, error)
- type DocumentCreate
- type DocumentOut
- type DocumentRepository
- func (r *DocumentRepository) Create(ctx context.Context, gid uuid.UUID, doc DocumentCreate) (DocumentOut, error)
- func (r *DocumentRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *DocumentRepository) Get(ctx context.Context, id uuid.UUID) (DocumentOut, error)
- func (r *DocumentRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]DocumentOut, error)
- func (r *DocumentRepository) Rename(ctx context.Context, id uuid.UUID, title string) (DocumentOut, error)
- type FieldQuery
- type FlatTreeItem
- type Group
- type GroupInvitation
- type GroupInvitationCreate
- type GroupRepository
- func (r *GroupRepository) GetAllGroups(ctx context.Context) ([]Group, error)
- func (r *GroupRepository) GroupByID(ctx context.Context, id uuid.UUID) (Group, error)
- func (r *GroupRepository) GroupCreate(ctx context.Context, name string) (Group, error)
- func (r *GroupRepository) GroupUpdate(ctx context.Context, ID uuid.UUID, data GroupUpdate) (Group, error)
- func (r *GroupRepository) InvitationCreate(ctx context.Context, groupID uuid.UUID, invite GroupInvitationCreate) (GroupInvitation, error)
- func (r *GroupRepository) InvitationGet(ctx context.Context, token []byte) (GroupInvitation, error)
- func (r *GroupRepository) InvitationPurge(ctx context.Context) (amount int, err error)
- func (r *GroupRepository) InvitationUpdate(ctx context.Context, id uuid.UUID, uses int) error
- func (r *GroupRepository) StatsGroup(ctx context.Context, GID uuid.UUID) (GroupStatistics, error)
- func (r *GroupRepository) StatsLabelsByPurchasePrice(ctx context.Context, GID uuid.UUID) ([]TotalsByOrganizer, error)
- func (r *GroupRepository) StatsLocationsByPurchasePrice(ctx context.Context, GID uuid.UUID) ([]TotalsByOrganizer, error)
- func (r *GroupRepository) StatsPurchasePrice(ctx context.Context, GID uuid.UUID, start, end time.Time) (*ValueOverTime, error)
- type GroupStatistics
- type GroupUpdate
- type HasID
- type ItemAttachment
- type ItemAttachmentUpdate
- type ItemCreate
- type ItemField
- type ItemOut
- type ItemPatch
- type ItemPath
- type ItemQuery
- type ItemSummary
- type ItemType
- type ItemUpdate
- type ItemsRepository
- func (e *ItemsRepository) CheckRef(ctx context.Context, GID uuid.UUID, ref string) (bool, error)
- func (e *ItemsRepository) Create(ctx context.Context, gid uuid.UUID, data ItemCreate) (ItemOut, error)
- func (e *ItemsRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (e *ItemsRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID) error
- func (e *ItemsRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]ItemOut, error)
- func (e *ItemsRepository) GetAllCustomFieldNames(ctx context.Context, GID uuid.UUID) ([]string, error)
- func (e *ItemsRepository) GetAllCustomFieldValues(ctx context.Context, GID uuid.UUID, name string) ([]string, error)
- func (e *ItemsRepository) GetAllZeroAssetID(ctx context.Context, GID uuid.UUID) ([]ItemSummary, error)
- func (e *ItemsRepository) GetAllZeroImportRef(ctx context.Context, GID uuid.UUID) ([]uuid.UUID, error)
- func (e *ItemsRepository) GetByRef(ctx context.Context, GID uuid.UUID, ref string) (ItemOut, error)
- func (e *ItemsRepository) GetHighestAssetID(ctx context.Context, GID uuid.UUID) (AssetID, error)
- func (e *ItemsRepository) GetOne(ctx context.Context, id uuid.UUID) (ItemOut, error)
- func (e *ItemsRepository) GetOneByGroup(ctx context.Context, gid, id uuid.UUID) (ItemOut, error)
- func (e *ItemsRepository) Patch(ctx context.Context, GID, ID uuid.UUID, data ItemPatch) error
- func (e *ItemsRepository) QueryByAssetID(ctx context.Context, gid uuid.UUID, assetID AssetID, page int, pageSize int) (PaginationResult[ItemSummary], error)
- func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q ItemQuery) (PaginationResult[ItemSummary], error)
- func (e *ItemsRepository) SetAssetID(ctx context.Context, GID uuid.UUID, ID uuid.UUID, assetID AssetID) error
- func (e *ItemsRepository) SetPrimaryPhotos(ctx context.Context, GID uuid.UUID) (int, error)
- func (e *ItemsRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data ItemUpdate) (ItemOut, error)
- func (e *ItemsRepository) ZeroOutTimeFields(ctx context.Context, GID uuid.UUID) (int, error)
- type LabelCreate
- type LabelOut
- type LabelRepository
- func (r *LabelRepository) Create(ctx context.Context, groupID uuid.UUID, data LabelCreate) (LabelOut, error)
- func (r *LabelRepository) DeleteByGroup(ctx context.Context, gid, id uuid.UUID) error
- func (r *LabelRepository) GetAll(ctx context.Context, groupID uuid.UUID) ([]LabelSummary, error)
- func (r *LabelRepository) GetOne(ctx context.Context, ID uuid.UUID) (LabelOut, error)
- func (r *LabelRepository) GetOneByGroup(ctx context.Context, gid, ld uuid.UUID) (LabelOut, error)
- func (r *LabelRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data LabelUpdate) (LabelOut, error)
- type LabelSummary
- type LabelUpdate
- type LocationCreate
- type LocationOut
- type LocationOutCount
- type LocationQuery
- type LocationRepository
- func (r *LocationRepository) Create(ctx context.Context, GID uuid.UUID, data LocationCreate) (LocationOut, error)
- func (r *LocationRepository) DeleteByGroup(ctx context.Context, GID, ID uuid.UUID) error
- func (r *LocationRepository) Get(ctx context.Context, ID uuid.UUID) (LocationOut, error)
- func (r *LocationRepository) GetAll(ctx context.Context, GID uuid.UUID, filter LocationQuery) ([]LocationOutCount, error)
- func (r *LocationRepository) GetOneByGroup(ctx context.Context, GID, ID uuid.UUID) (LocationOut, error)
- func (r *LocationRepository) PathForLoc(ctx context.Context, GID, locID uuid.UUID) ([]ItemPath, error)
- func (r *LocationRepository) Tree(ctx context.Context, GID uuid.UUID, tq TreeQuery) ([]TreeItem, error)
- func (r *LocationRepository) UpdateByGroup(ctx context.Context, GID, ID uuid.UUID, data LocationUpdate) (LocationOut, error)
- type LocationSummary
- type LocationUpdate
- type MaintenanceEntry
- type MaintenanceEntryCreate
- type MaintenanceEntryRepository
- func (r *MaintenanceEntryRepository) Create(ctx context.Context, itemID uuid.UUID, input MaintenanceEntryCreate) (MaintenanceEntry, error)
- func (r *MaintenanceEntryRepository) Delete(ctx context.Context, ID uuid.UUID) error
- func (r *MaintenanceEntryRepository) GetLog(ctx context.Context, groupID, itemID uuid.UUID, query MaintenanceLogQuery) (MaintenanceLog, error)
- func (r *MaintenanceEntryRepository) GetScheduled(ctx context.Context, GID uuid.UUID, dt types.Date) ([]MaintenanceEntry, error)
- func (r *MaintenanceEntryRepository) Update(ctx context.Context, ID uuid.UUID, input MaintenanceEntryUpdate) (MaintenanceEntry, error)
- type MaintenanceEntryUpdate
- type MaintenanceLog
- type MaintenanceLogQuery
- type MapFunc
- type NotifierCreate
- type NotifierOut
- type NotifierRepository
- func (r *NotifierRepository) Create(ctx context.Context, groupID, userID uuid.UUID, input NotifierCreate) (NotifierOut, error)
- func (r *NotifierRepository) Delete(ctx context.Context, userID uuid.UUID, ID uuid.UUID) error
- func (r *NotifierRepository) GetActiveByGroup(ctx context.Context, groupID uuid.UUID) ([]NotifierOut, error)
- func (r *NotifierRepository) GetByGroup(ctx context.Context, groupID uuid.UUID) ([]NotifierOut, error)
- func (r *NotifierRepository) GetByUser(ctx context.Context, userID uuid.UUID) ([]NotifierOut, error)
- func (r *NotifierRepository) Update(ctx context.Context, userID uuid.UUID, id uuid.UUID, input NotifierUpdate) (NotifierOut, error)
- type NotifierUpdate
- type PaginationResult
- type TokenRepository
- func (r *TokenRepository) CreateToken(ctx context.Context, createToken UserAuthTokenCreate, roles ...authroles.Role) (UserAuthToken, error)
- func (r *TokenRepository) DeleteAll(ctx context.Context) (int, error)
- func (r *TokenRepository) DeleteToken(ctx context.Context, token []byte) error
- func (r *TokenRepository) GetRoles(ctx context.Context, token string) (*set.Set[string], error)
- func (r *TokenRepository) GetUserFromToken(ctx context.Context, token []byte) (UserOut, error)
- func (r *TokenRepository) PurgeExpiredTokens(ctx context.Context) (int, error)
- type TotalsByOrganizer
- type TreeItem
- type TreeQuery
- type UserAuthToken
- type UserAuthTokenCreate
- type UserCreate
- type UserOut
- type UserRepository
- func (r *UserRepository) ChangePassword(ctx context.Context, UID uuid.UUID, pw string) error
- func (r *UserRepository) Create(ctx context.Context, usr UserCreate) (UserOut, error)
- func (r *UserRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *UserRepository) DeleteAll(ctx context.Context) error
- func (r *UserRepository) GetAll(ctx context.Context) ([]UserOut, error)
- func (r *UserRepository) GetOneEmail(ctx context.Context, email string) (UserOut, error)
- func (r *UserRepository) GetOneID(ctx context.Context, ID uuid.UUID) (UserOut, error)
- func (r *UserRepository) GetSuperusers(ctx context.Context) ([]*ent.User, error)
- func (r *UserRepository) Update(ctx context.Context, ID uuid.UUID, data UserUpdate) error
- type UserUpdate
- type ValueOverTime
- type ValueOverTimeEntry
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidDocExtension = errors.New("invalid document extension")
Functions ¶
This section is empty.
Types ¶
type AllRepos ¶
type AllRepos struct { Users *UserRepository AuthTokens *TokenRepository Groups *GroupRepository Locations *LocationRepository Labels *LabelRepository Items *ItemsRepository Docs *DocumentRepository Attachments *AttachmentRepo MaintEntry *MaintenanceEntryRepository Notifiers *NotifierRepository }
AllRepos is a container for all the repository interfaces
type AssetID ¶
type AssetID int
func ParseAssetID ¶
func ParseAssetIDBytes ¶
func (AssetID) MarshalCSV ¶
func (AssetID) MarshalJSON ¶
func (*AssetID) UnmarshalCSV ¶
func (*AssetID) UnmarshalJSON ¶
type AttachmentRepo ¶
type AttachmentRepo struct {
// contains filtered or unexported fields
}
AttachmentRepo is a repository for Attachments table that links Items to Documents While also specifying the type of the attachment. This _ONLY_ provides basic Create Update And Delete operations. For accessing the actual documents, use the Items repository since it provides the attachments with the documents.
func (*AttachmentRepo) Create ¶
func (r *AttachmentRepo) Create(ctx context.Context, itemID, docID uuid.UUID, typ attachment.Type) (*ent.Attachment, error)
func (*AttachmentRepo) Get ¶
func (r *AttachmentRepo) Get(ctx context.Context, id uuid.UUID) (*ent.Attachment, error)
func (*AttachmentRepo) Update ¶
func (r *AttachmentRepo) Update(ctx context.Context, itemID uuid.UUID, data *ItemAttachmentUpdate) (*ent.Attachment, error)
type DocumentCreate ¶
type DocumentOut ¶
type DocumentRepository ¶
type DocumentRepository struct {
// contains filtered or unexported fields
}
func (*DocumentRepository) Create ¶
func (r *DocumentRepository) Create(ctx context.Context, gid uuid.UUID, doc DocumentCreate) (DocumentOut, error)
func (*DocumentRepository) Get ¶
func (r *DocumentRepository) Get(ctx context.Context, id uuid.UUID) (DocumentOut, error)
func (*DocumentRepository) GetAll ¶
func (r *DocumentRepository) GetAll(ctx context.Context, gid uuid.UUID) ([]DocumentOut, error)
func (*DocumentRepository) Rename ¶
func (r *DocumentRepository) Rename(ctx context.Context, id uuid.UUID, title string) (DocumentOut, error)
type FieldQuery ¶
type FlatTreeItem ¶
type GroupInvitation ¶
type GroupInvitationCreate ¶
type GroupRepository ¶
type GroupRepository struct {
// contains filtered or unexported fields
}
func NewGroupRepository ¶
func NewGroupRepository(db *ent.Client) *GroupRepository
func (*GroupRepository) GetAllGroups ¶
func (r *GroupRepository) GetAllGroups(ctx context.Context) ([]Group, error)
func (*GroupRepository) GroupCreate ¶
func (*GroupRepository) GroupUpdate ¶
func (r *GroupRepository) GroupUpdate(ctx context.Context, ID uuid.UUID, data GroupUpdate) (Group, error)
func (*GroupRepository) InvitationCreate ¶
func (r *GroupRepository) InvitationCreate(ctx context.Context, groupID uuid.UUID, invite GroupInvitationCreate) (GroupInvitation, error)
func (*GroupRepository) InvitationGet ¶
func (r *GroupRepository) InvitationGet(ctx context.Context, token []byte) (GroupInvitation, error)
func (*GroupRepository) InvitationPurge ¶
func (r *GroupRepository) InvitationPurge(ctx context.Context) (amount int, err error)
InvitationPurge removes all expired invitations or those that have been used up. It returns the number of deleted invitations.
func (*GroupRepository) InvitationUpdate ¶
func (*GroupRepository) StatsGroup ¶
func (r *GroupRepository) StatsGroup(ctx context.Context, GID uuid.UUID) (GroupStatistics, error)
func (*GroupRepository) StatsLabelsByPurchasePrice ¶
func (r *GroupRepository) StatsLabelsByPurchasePrice(ctx context.Context, GID uuid.UUID) ([]TotalsByOrganizer, error)
func (*GroupRepository) StatsLocationsByPurchasePrice ¶
func (r *GroupRepository) StatsLocationsByPurchasePrice(ctx context.Context, GID uuid.UUID) ([]TotalsByOrganizer, error)
func (*GroupRepository) StatsPurchasePrice ¶
func (r *GroupRepository) StatsPurchasePrice(ctx context.Context, GID uuid.UUID, start, end time.Time) (*ValueOverTime, error)
type GroupStatistics ¶
type GroupUpdate ¶
type HasID ¶
HasID is an interface to entities that have an ID uuid.UUID field and a GetID() method. This interface is fulfilled by all entities generated by entgo.io/ent via a custom template
type ItemAttachment ¶
type ItemAttachment struct { ID uuid.UUID `json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` Type string `json:"type"` Document DocumentOut `json:"document"` Primary bool `json:"primary"` }
func ToItemAttachment ¶
func ToItemAttachment(attachment *ent.Attachment) ItemAttachment
type ItemAttachmentUpdate ¶
type ItemCreate ¶
type ItemCreate struct { ImportRef string `json:"-"` ParentID uuid.UUID `json:"parentId" extensions:"x-nullable"` Name string `json:"name" validate:"required,min=1,max=255"` Description string `json:"description" validate:"max=1000"` AssetID AssetID `json:"-"` // Edges LocationID uuid.UUID `json:"locationId"` LabelIDs []uuid.UUID `json:"labelIds"` }
type ItemOut ¶
type ItemOut struct { Parent *ItemSummary `json:"parent,omitempty" extensions:"x-nullable,x-omitempty"` ItemSummary AssetID AssetID `json:"assetId,string"` SerialNumber string `json:"serialNumber"` ModelNumber string `json:"modelNumber"` Manufacturer string `json:"manufacturer"` // Warranty LifetimeWarranty bool `json:"lifetimeWarranty"` WarrantyExpires types.Date `json:"warrantyExpires"` WarrantyDetails string `json:"warrantyDetails"` // Purchase PurchaseTime types.Date `json:"purchaseTime"` PurchaseFrom string `json:"purchaseFrom"` // Sold SoldTime types.Date `json:"soldTime"` SoldTo string `json:"soldTo"` SoldPrice float64 `json:"soldPrice,string"` SoldNotes string `json:"soldNotes"` // Extras Notes string `json:"notes"` Attachments []ItemAttachment `json:"attachments"` Fields []ItemField `json:"fields"` }
type ItemQuery ¶
type ItemQuery struct { Page int PageSize int Search string `json:"search"` AssetID AssetID `json:"assetId"` LocationIDs []uuid.UUID `json:"locationIds"` LabelIDs []uuid.UUID `json:"labelIds"` ParentItemIDs []uuid.UUID `json:"parentIds"` SortBy string `json:"sortBy"` IncludeArchived bool `json:"includeArchived"` Fields []FieldQuery `json:"fields"` OrderBy string `json:"orderBy"` }
type ItemSummary ¶
type ItemSummary struct { ImportRef string `json:"-"` ID uuid.UUID `json:"id"` Name string `json:"name"` Description string `json:"description"` Quantity int `json:"quantity"` Insured bool `json:"insured"` Archived bool `json:"archived"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` PurchasePrice float64 `json:"purchasePrice,string"` // Edges Location *LocationSummary `json:"location,omitempty" extensions:"x-nullable,x-omitempty"` Labels []LabelSummary `json:"labels"` ImageID *uuid.UUID `json:"imageId,omitempty"` }
type ItemUpdate ¶
type ItemUpdate struct { ParentID uuid.UUID `json:"parentId" extensions:"x-nullable,x-omitempty"` ID uuid.UUID `json:"id"` AssetID AssetID `json:"assetId" swaggertype:"string"` Name string `json:"name"` Description string `json:"description"` Quantity int `json:"quantity"` Insured bool `json:"insured"` Archived bool `json:"archived"` // Edges LocationID uuid.UUID `json:"locationId"` LabelIDs []uuid.UUID `json:"labelIds"` // Identifications SerialNumber string `json:"serialNumber"` ModelNumber string `json:"modelNumber"` Manufacturer string `json:"manufacturer"` // Warranty LifetimeWarranty bool `json:"lifetimeWarranty"` WarrantyExpires types.Date `json:"warrantyExpires"` WarrantyDetails string `json:"warrantyDetails"` // Purchase PurchaseTime types.Date `json:"purchaseTime"` PurchaseFrom string `json:"purchaseFrom"` PurchasePrice float64 `json:"purchasePrice,string"` // Sold SoldTime types.Date `json:"soldTime"` SoldTo string `json:"soldTo"` SoldPrice float64 `json:"soldPrice,string"` SoldNotes string `json:"soldNotes"` // Extras Notes string `json:"notes"` Fields []ItemField `json:"fields"` }
type ItemsRepository ¶
type ItemsRepository struct {
// contains filtered or unexported fields
}
func (*ItemsRepository) Create ¶
func (e *ItemsRepository) Create(ctx context.Context, gid uuid.UUID, data ItemCreate) (ItemOut, error)
func (*ItemsRepository) DeleteByGroup ¶
func (*ItemsRepository) GetAll ¶
GetAll returns all the items in the database with the Labels and Locations eager loaded.
func (*ItemsRepository) GetAllCustomFieldNames ¶
func (*ItemsRepository) GetAllCustomFieldValues ¶
func (*ItemsRepository) GetAllZeroAssetID ¶
func (e *ItemsRepository) GetAllZeroAssetID(ctx context.Context, GID uuid.UUID) ([]ItemSummary, error)
func (*ItemsRepository) GetAllZeroImportRef ¶
func (*ItemsRepository) GetHighestAssetID ¶
func (*ItemsRepository) GetOne ¶
GetOne returns a single item by ID. If the item does not exist, an error is returned. See also: GetOneByGroup to ensure that the item belongs to a specific group.
func (*ItemsRepository) GetOneByGroup ¶
GetOneByGroup returns a single item by ID. If the item does not exist, an error is returned. GetOneByGroup ensures that the item belongs to a specific group.
func (*ItemsRepository) QueryByAssetID ¶
func (e *ItemsRepository) QueryByAssetID(ctx context.Context, gid uuid.UUID, assetID AssetID, page int, pageSize int) (PaginationResult[ItemSummary], error)
QueryByAssetID returns items by asset ID. If the item does not exist, an error is returned.
func (*ItemsRepository) QueryByGroup ¶
func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q ItemQuery) (PaginationResult[ItemSummary], error)
QueryByGroup returns a list of items that belong to a specific group based on the provided query.
func (*ItemsRepository) SetAssetID ¶
func (*ItemsRepository) SetPrimaryPhotos ¶
func (*ItemsRepository) UpdateByGroup ¶
func (e *ItemsRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data ItemUpdate) (ItemOut, error)
func (*ItemsRepository) ZeroOutTimeFields ¶
ZeroOutTimeFields is a helper function that can be invoked via the UI by a group member which will set all date fields to the beginning of the day.
This is designed to resolve a long-time bug that has since been fixed with the time selector on the frontend. This function is intended to be used as a one-time fix for existing databases and may be removed in the future.
type LabelCreate ¶
type LabelOut ¶
type LabelOut struct {
LabelSummary
}
type LabelRepository ¶
type LabelRepository struct {
// contains filtered or unexported fields
}
func (*LabelRepository) Create ¶
func (r *LabelRepository) Create(ctx context.Context, groupID uuid.UUID, data LabelCreate) (LabelOut, error)
func (*LabelRepository) DeleteByGroup ¶
func (*LabelRepository) GetAll ¶
func (r *LabelRepository) GetAll(ctx context.Context, groupID uuid.UUID) ([]LabelSummary, error)
func (*LabelRepository) GetOneByGroup ¶
func (*LabelRepository) UpdateByGroup ¶
func (r *LabelRepository) UpdateByGroup(ctx context.Context, GID uuid.UUID, data LabelUpdate) (LabelOut, error)
type LabelSummary ¶
type LabelUpdate ¶
type LocationCreate ¶
type LocationOut ¶
type LocationOut struct { Parent *LocationSummary `json:"parent,omitempty"` LocationSummary Children []LocationSummary `json:"children"` }
type LocationOutCount ¶
type LocationOutCount struct { LocationSummary ItemCount int `json:"itemCount"` }
type LocationQuery ¶
type LocationQuery struct {
FilterChildren bool `json:"filterChildren" schema:"filterChildren"`
}
type LocationRepository ¶
type LocationRepository struct {
// contains filtered or unexported fields
}
func (*LocationRepository) Create ¶
func (r *LocationRepository) Create(ctx context.Context, GID uuid.UUID, data LocationCreate) (LocationOut, error)
func (*LocationRepository) DeleteByGroup ¶
func (*LocationRepository) Get ¶
func (r *LocationRepository) Get(ctx context.Context, ID uuid.UUID) (LocationOut, error)
func (*LocationRepository) GetAll ¶
func (r *LocationRepository) GetAll(ctx context.Context, GID uuid.UUID, filter LocationQuery) ([]LocationOutCount, error)
GetAll returns all locations with item count field populated
func (*LocationRepository) GetOneByGroup ¶
func (r *LocationRepository) GetOneByGroup(ctx context.Context, GID, ID uuid.UUID) (LocationOut, error)
func (*LocationRepository) PathForLoc ¶
func (*LocationRepository) UpdateByGroup ¶
func (r *LocationRepository) UpdateByGroup(ctx context.Context, GID, ID uuid.UUID, data LocationUpdate) (LocationOut, error)
type LocationSummary ¶
type LocationUpdate ¶
type MaintenanceEntry ¶
type MaintenanceEntryCreate ¶
type MaintenanceEntryCreate struct { CompletedDate types.Date `json:"completedDate"` ScheduledDate types.Date `json:"scheduledDate"` Name string `json:"name" validate:"required"` Description string `json:"description"` Cost float64 `json:"cost,string"` }
func (MaintenanceEntryCreate) Validate ¶
func (mc MaintenanceEntryCreate) Validate() error
type MaintenanceEntryRepository ¶
type MaintenanceEntryRepository struct {
// contains filtered or unexported fields
}
MaintenanceEntryRepository is a repository for maintenance entries that are associated with an item in the database. An entry represents a maintenance event that has been performed on an item.
func (*MaintenanceEntryRepository) Create ¶
func (r *MaintenanceEntryRepository) Create(ctx context.Context, itemID uuid.UUID, input MaintenanceEntryCreate) (MaintenanceEntry, error)
func (*MaintenanceEntryRepository) GetLog ¶
func (r *MaintenanceEntryRepository) GetLog(ctx context.Context, groupID, itemID uuid.UUID, query MaintenanceLogQuery) (MaintenanceLog, error)
func (*MaintenanceEntryRepository) GetScheduled ¶
func (r *MaintenanceEntryRepository) GetScheduled(ctx context.Context, GID uuid.UUID, dt types.Date) ([]MaintenanceEntry, error)
func (*MaintenanceEntryRepository) Update ¶
func (r *MaintenanceEntryRepository) Update(ctx context.Context, ID uuid.UUID, input MaintenanceEntryUpdate) (MaintenanceEntry, error)
type MaintenanceEntryUpdate ¶
type MaintenanceEntryUpdate struct { CompletedDate types.Date `json:"completedDate"` ScheduledDate types.Date `json:"scheduledDate"` Name string `json:"name"` Description string `json:"description"` Cost float64 `json:"cost,string"` }
func (MaintenanceEntryUpdate) Validate ¶
func (mu MaintenanceEntryUpdate) Validate() error
type MaintenanceLog ¶
type MaintenanceLog struct { ItemID uuid.UUID `json:"itemId"` CostAverage float64 `json:"costAverage"` CostTotal float64 `json:"costTotal"` Entries []MaintenanceEntry `json:"entries"` }
type MaintenanceLogQuery ¶
type MapFunc ¶
func (MapFunc[T, U]) MapEachErr ¶
type NotifierCreate ¶
type NotifierOut ¶
type NotifierOut struct { ID uuid.UUID `json:"id"` UserID uuid.UUID `json:"userId"` GroupID uuid.UUID `json:"groupId"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` Name string `json:"name"` IsActive bool `json:"isActive"` URL string `json:"-"` // URL field is not exposed to the client }
type NotifierRepository ¶
type NotifierRepository struct {
// contains filtered or unexported fields
}
func NewNotifierRepository ¶
func NewNotifierRepository(db *ent.Client) *NotifierRepository
func (*NotifierRepository) Create ¶
func (r *NotifierRepository) Create(ctx context.Context, groupID, userID uuid.UUID, input NotifierCreate) (NotifierOut, error)
func (*NotifierRepository) GetActiveByGroup ¶
func (r *NotifierRepository) GetActiveByGroup(ctx context.Context, groupID uuid.UUID) ([]NotifierOut, error)
func (*NotifierRepository) GetByGroup ¶
func (r *NotifierRepository) GetByGroup(ctx context.Context, groupID uuid.UUID) ([]NotifierOut, error)
func (*NotifierRepository) GetByUser ¶
func (r *NotifierRepository) GetByUser(ctx context.Context, userID uuid.UUID) ([]NotifierOut, error)
func (*NotifierRepository) Update ¶
func (r *NotifierRepository) Update(ctx context.Context, userID uuid.UUID, id uuid.UUID, input NotifierUpdate) (NotifierOut, error)
type NotifierUpdate ¶
type PaginationResult ¶
type TokenRepository ¶
type TokenRepository struct {
// contains filtered or unexported fields
}
func (*TokenRepository) CreateToken ¶
func (r *TokenRepository) CreateToken(ctx context.Context, createToken UserAuthTokenCreate, roles ...authroles.Role) (UserAuthToken, error)
CreateToken Creates a token for a user
func (*TokenRepository) DeleteAll ¶
func (r *TokenRepository) DeleteAll(ctx context.Context) (int, error)
func (*TokenRepository) DeleteToken ¶
func (r *TokenRepository) DeleteToken(ctx context.Context, token []byte) error
DeleteToken remove a single token from the database - equivalent to revoke or logout
func (*TokenRepository) GetUserFromToken ¶
GetUserFromToken get's a user from a token
func (*TokenRepository) PurgeExpiredTokens ¶
func (r *TokenRepository) PurgeExpiredTokens(ctx context.Context) (int, error)
PurgeExpiredTokens removes all expired tokens from the database
type TotalsByOrganizer ¶
type TreeItem ¶
type TreeItem struct { ID uuid.UUID `json:"id"` Name string `json:"name"` Type string `json:"type"` Children []*TreeItem `json:"children"` }
func ConvertLocationsToTree ¶
func ConvertLocationsToTree(locations []FlatTreeItem) []TreeItem
type UserAuthToken ¶
type UserAuthToken struct { UserAuthTokenCreate CreatedAt time.Time `json:"createdAt"` }
func (UserAuthToken) IsExpired ¶
func (u UserAuthToken) IsExpired() bool
type UserAuthTokenCreate ¶
type UserCreate ¶
type UserCreate struct { Name string `json:"name"` Email string `json:"email"` Password string `json:"password"` IsSuperuser bool `json:"isSuperuser"` GroupID uuid.UUID `json:"groupID"` IsOwner bool `json:"isOwner"` }
UserCreate is the Data object contain the requirements of creating a user in the database. It should to create users from an API unless the user has rights to create SuperUsers. For regular user in data use the UserIn struct.
type UserRepository ¶
type UserRepository struct {
// contains filtered or unexported fields
}
func (*UserRepository) ChangePassword ¶
func (*UserRepository) Create ¶
func (r *UserRepository) Create(ctx context.Context, usr UserCreate) (UserOut, error)
func (*UserRepository) GetAll ¶
func (r *UserRepository) GetAll(ctx context.Context) ([]UserOut, error)
func (*UserRepository) GetOneEmail ¶
func (*UserRepository) GetSuperusers ¶
func (*UserRepository) Update ¶
func (r *UserRepository) Update(ctx context.Context, ID uuid.UUID, data UserUpdate) error