package merch 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 s.repo.getLabels(ctx, userId) } func (s *service) updateLabel(ctx context.Context, userId int64, labelUuid string, payload *LabelDTO) error { 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 s.repo.deleteLabel(ctx, userId, labelUuid, s.utils.NullTimeNowUTC()) } func (s *service) attachLabel(ctx context.Context, userId int64, payload *LabelLink) error { return s.repo.attachLabel(ctx, userId, payload) } func (s *service) detachLabel(ctx context.Context, userId int64, payload *LabelLink) error { return s.repo.detachLabel(ctx, userId, payload) } func (s *service) getMerchLabels(ctx context.Context, userId int64, merchUuid string) ([]string, error) { return s.repo.getAttachedLabelsByUuid(ctx, userId, merchUuid) }