homebox/backend/internal/services/service_labels.go

38 lines
1 KiB
Go
Raw Permalink Normal View History

2022-09-02 01:52:40 +00:00
package services
import (
"context"
"github.com/google/uuid"
"github.com/hay-kot/homebox/backend/internal/repo"
2022-09-02 01:52:40 +00:00
)
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)
2022-09-02 01:52:40 +00:00
}
func (svc *LabelService) Update(ctx context.Context, groupId uuid.UUID, data repo.LabelUpdate) (repo.LabelOut, error) {
return svc.repos.Labels.Update(ctx, data)
2022-09-02 01:52:40 +00:00
}
func (svc *LabelService) Delete(ctx context.Context, gid uuid.UUID, id uuid.UUID) error {
_, err := svc.repos.Labels.GetOneByGroup(ctx, gid, id)
2022-09-02 01:52:40 +00:00
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)
2022-09-02 01:52:40 +00:00
}
func (svc *LabelService) GetAll(ctx context.Context, groupId uuid.UUID) ([]repo.LabelSummary, error) {
return svc.repos.Labels.GetAll(ctx, groupId)
2022-09-02 01:52:40 +00:00
}