aides-repo-api/internal/services/taskservice/create.go

32 lines
525 B
Go
Raw Normal View History

package taskservice
import (
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/models"
)
func (s *Service) Create(repo string) (*models.Task, error) {
taskRepo := models.GitRepo{
Name: repo,
}
2024-12-15 09:03:11 +00:00
s.db.
Where(&taskRepo).
FirstOrCreate(&taskRepo)
altRepo := models.ALTRepo{
Name: "Sisyphus",
}
2024-12-15 06:16:51 +00:00
s.db.
Where(&altRepo).
FirstOrCreate(&altRepo)
task := models.Task{
RepoID: taskRepo.ID,
ALTRepo: altRepo,
Type: models.TypeUpsert,
}
2024-12-15 06:16:51 +00:00
result := s.db.Create(&task)
return &task, result.Error
}