25 lines
457 B
Go
25 lines
457 B
Go
|
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,
|
||
|
}
|
||
|
|
||
|
result := s.app.Db.Create(&task)
|
||
|
|
||
|
return &task, result.Error
|
||
|
}
|