30 lines
620 B
Go
30 lines
620 B
Go
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
|
|
}
|