admin: restore function to add team and members
This commit is contained in:
parent
9bf91f819b
commit
dd4e207892
2 changed files with 10 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package fic
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -59,7 +60,9 @@ func GetTeamByInitialName(initialName string) (Team, error) {
|
|||
// CRUD method
|
||||
|
||||
func CreateTeam(name string, color uint32) (Team, error) {
|
||||
if res, err := DBExec("INSERT INTO teams (initial_name, name, color) VALUES (?, ?, ?)", name, name, color); err != nil {
|
||||
re := regexp.MustCompile("[^a-zA-Z0-9]+")
|
||||
initialName := re.ReplaceAllLiteralString(name, "_")
|
||||
if res, err := DBExec("INSERT INTO teams (initial_name, name, color) VALUES (?, ?, ?)", initialName, name, color); err != nil {
|
||||
return Team{}, err
|
||||
} else if tid, err := res.LastInsertId(); err != nil {
|
||||
return Team{}, err
|
||||
|
|
|
|||
Reference in a new issue