implemented team create method
This commit is contained in:
19
models/teams_create.go
Normal file
19
models/teams_create.go
Normal file
@ -0,0 +1,19 @@
|
||||
package models
|
||||
|
||||
func (t *Team) Create(doer *User, _ int64) (err error) {
|
||||
// Check if we have a name
|
||||
if t.Name == "" {
|
||||
return ErrTeamNameCannotBeEmpty{}
|
||||
}
|
||||
|
||||
// Set the id to 0, otherwise the creation fails because of double keys
|
||||
t.CreatedByID = doer.ID
|
||||
t.CreatedBy = doer
|
||||
|
||||
_, err = x.Insert(t)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
Reference in New Issue
Block a user