Split team.go into multiple files
This commit is contained in:
parent
f0621fa191
commit
c57b612205
4 changed files with 249 additions and 222 deletions
36
libfic/team_export.go
Normal file
36
libfic/team_export.go
Normal file
|
@ -0,0 +1,36 @@
|
|||
package fic
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type exportedTeam struct {
|
||||
Name string `json:"name"`
|
||||
Color string `json:"color"`
|
||||
Rank int `json:"rank"`
|
||||
Points int64 `json:"score"`
|
||||
}
|
||||
|
||||
func ExportTeams() (interface{}, error) {
|
||||
if teams, err := GetTeams(); err != nil {
|
||||
return nil, err
|
||||
} else if rank, err := GetRank(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
ret := map[string]exportedTeam{}
|
||||
for _, team := range teams {
|
||||
if points, err := team.GetPoints(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
ret[fmt.Sprintf("%d", team.Id)] = exportedTeam{
|
||||
team.Name,
|
||||
fmt.Sprintf("#%x", team.Color),
|
||||
rank[team.Id],
|
||||
points,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
}
|
Reference in a new issue