serverctl/services/entry/pkg/application/applications/service.go

30 lines
620 B
Go
Raw Normal View History

2022-02-16 15:30:38 +01:00
package applications
import (
"context"
"errors"
"go.uber.org/zap"
)
type Service struct {
repository Repository
logger *zap.Logger
}
func NewService(logger *zap.Logger, repository Repository) *Service {
return &Service{
logger: logger,
repository: repository,
}
}
func (s Service) CreateApplication(ctx context.Context, applicationName string, userId int, projectId int) (int, error) {
if applicationName == "" {
return -1, errors.New("application name is empty")
}
applicationId, err := s.repository.CreateApplication(ctx, applicationName, userId, projectId)
return applicationId, err
}