mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-12-03 14:51:05 +01:00
79a05b389f
- [wip] ws support
31 lines
541 B
Go
31 lines
541 B
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/ansible-semaphore/semaphore/database"
|
|
)
|
|
|
|
type Project struct {
|
|
ID int `json:"id"`
|
|
Name string `json:"name" binding:"required"`
|
|
Created time.Time `json:"created"`
|
|
}
|
|
|
|
func (project *Project) CreateProject() error {
|
|
res, err := database.Mysql.Exec("insert into project set name=?", project.Name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
projectID, err := res.LastInsertId()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
project.ID = int(projectID)
|
|
project.Created = time.Now()
|
|
|
|
return nil
|
|
}
|