labels service impl
This commit is contained in:
parent
229e438367
commit
c1e8922968
1 changed files with 44 additions and 8 deletions
|
|
@ -1,31 +1,67 @@
|
|||
package merch
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
"github.com/gofrs/uuid"
|
||||
)
|
||||
|
||||
func (s *service) createLabel(ctx context.Context, userId int64, label *LabelDTO) error {
|
||||
if label == nil {
|
||||
logWarn(serviceLogHeader, "label payload is empty")
|
||||
return nil
|
||||
}
|
||||
|
||||
now := s.utils.TimeNowUTC()
|
||||
|
||||
lUuid, err := uuid.NewV7()
|
||||
if err != nil {
|
||||
logErr(serviceLogHeader, err)
|
||||
return err
|
||||
}
|
||||
|
||||
newLabel := Label{
|
||||
CreatedAt: now,
|
||||
UpdatedAt: s.utils.NullTimeFromNow(now),
|
||||
DeletedAt: s.utils.DeletedNullTime(),
|
||||
UserId: userId,
|
||||
Uuid: lUuid.String(),
|
||||
Name: label.Name,
|
||||
Color: label.Color,
|
||||
BgColor: label.BgColor,
|
||||
}
|
||||
|
||||
return s.repo.createLabel(ctx, userId, &newLabel)
|
||||
}
|
||||
|
||||
func (s *service) getLabels(ctx context.Context, userId int64) ([]LabelsList, error) {
|
||||
return nil, nil
|
||||
return s.repo.getLabels(ctx, userId)
|
||||
}
|
||||
|
||||
func (s *service) updateLabel(ctx context.Context, userId int64, labelUuid string, payload *LabelDTO) error {
|
||||
return nil
|
||||
|
||||
l := Label{
|
||||
UpdatedAt: s.utils.NullTimeNowUTC(),
|
||||
Uuid: labelUuid,
|
||||
Name: payload.Name,
|
||||
Color: payload.Color,
|
||||
BgColor: payload.BgColor,
|
||||
}
|
||||
|
||||
return s.repo.updateLabel(ctx, userId, &l)
|
||||
}
|
||||
|
||||
func (s *service) deleteLabel(ctx context.Context, userId int64, labelUuid string) error {
|
||||
return nil
|
||||
return s.repo.deleteLabel(ctx, userId, labelUuid, s.utils.NullTimeNowUTC())
|
||||
}
|
||||
|
||||
func (s *service) attachLabel(ctx context.Context, userId int64, payload *LabelLink) error {
|
||||
return nil
|
||||
return s.repo.attachLabel(ctx, userId, payload)
|
||||
}
|
||||
|
||||
func (s *service) detachLabel(ctx context.Context, userId int64, payload *LabelLink) error {
|
||||
return nil
|
||||
return s.repo.detachLabel(ctx, userId, payload)
|
||||
}
|
||||
|
||||
func (s *service) getMerchLabels(ctx context.Context, userId int64, merchUuid string) ([]string, error) {
|
||||
return nil, nil
|
||||
return s.repo.getAttachedLabelsByUuid(ctx, userId, merchUuid)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue