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

26 lines
487 B
Go
Raw Normal View History

2024-12-12 20:36:38 +00:00
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,
}
s.app.Db.FirstOrCreate(&taskRepo)
altRepo := models.ALTRepo{
Name: "Sisyphus",
}
s.app.Db.FirstOrCreate(&altRepo)
task := models.Task{
RepoID: taskRepo.ID,
ALTRepo: altRepo,
2024-12-12 20:51:13 +00:00
Type: models.TypeUpsert,
2024-12-12 20:36:38 +00:00
}
result := s.app.Db.Create(&task)
return &task, result.Error
}