mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-28 19:45:41 +00:00
343290a55a
* cleanup unnecessary mocks * refactor document storage location * remove unused function * move ownership to document types to repo package * move types and mappers to repo package * refactor sets to own package
37 lines
1 KiB
Go
37 lines
1 KiB
Go
package services
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/google/uuid"
|
|
"github.com/hay-kot/homebox/backend/internal/repo"
|
|
)
|
|
|
|
type LabelService struct {
|
|
repos *repo.AllRepos
|
|
}
|
|
|
|
func (svc *LabelService) Create(ctx context.Context, groupId uuid.UUID, data repo.LabelCreate) (repo.LabelOut, error) {
|
|
return svc.repos.Labels.Create(ctx, groupId, data)
|
|
}
|
|
|
|
func (svc *LabelService) Update(ctx context.Context, groupId uuid.UUID, data repo.LabelUpdate) (repo.LabelOut, error) {
|
|
return svc.repos.Labels.Update(ctx, data)
|
|
}
|
|
|
|
func (svc *LabelService) Delete(ctx context.Context, gid uuid.UUID, id uuid.UUID) error {
|
|
_, err := svc.repos.Labels.GetOneByGroup(ctx, gid, id)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return svc.repos.Labels.Delete(ctx, id)
|
|
}
|
|
|
|
func (svc *LabelService) Get(ctx context.Context, gid uuid.UUID, id uuid.UUID) (repo.LabelOut, error) {
|
|
return svc.repos.Labels.GetOneByGroup(ctx, gid, id)
|
|
|
|
}
|
|
|
|
func (svc *LabelService) GetAll(ctx context.Context, groupId uuid.UUID) ([]repo.LabelSummary, error) {
|
|
return svc.repos.Labels.GetAll(ctx, groupId)
|
|
}
|