func addPlayerLinks(player *domain.Player, c *gin.Context) { selfURL := fmt.Sprintf("/api/players/%d", player.ID) player.AddLink(domain.RelSelf, selfURL) if isAuthenticated(c) { player.AddLink(domain.RelUpdate, selfURL) } }
func (ps PlayerService) createPlayer(c *gin.Context) { var player domain.Player c.Bind(&player) player.ID = 0 player.Active = true ps.doSavePlayer(player, c) }
func (dao *PlayerDao) SavePlayer(player domain.Player) (*domain.Player, error) { if player.ID == 0 { playerID, _, _ := datastore.AllocateIDs(dao.Context, EntityPlayer, nil, 1) player.ID = playerID } key := datastore.NewKey(dao.Context, EntityPlayer, "", player.ID, nil) p, err := dao.save(key, &player) if err != nil { return nil, err } savedPlayer := p.(*domain.Player) return savedPlayer, err }