예제 #1
0
func (ps PlayerService) createPlayer(c *gin.Context) {
	var player domain.Player

	c.Bind(&player)

	player.ID = 0
	player.Active = true

	ps.doSavePlayer(player, c)
}
예제 #2
0
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
}