frontend: team registration

This commit is contained in:
nemunaire 2017-12-21 22:18:18 +01:00
commit 184714aeeb
10 changed files with 208 additions and 28 deletions

View file

@ -62,6 +62,10 @@ func GetTeamByInitialName(initialName string) (Team, error) {
func CreateTeam(name string, color uint32) (Team, error) {
re := regexp.MustCompile("[^a-zA-Z0-9]+")
initialName := re.ReplaceAllLiteralString(name, "_")
return RegisterTeam(initialName, name, color)
}
func RegisterTeam(initialName string, name string, color uint32) (Team, error) {
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 {