game2005api/webapp/services/AwardService.php
2021-11-29 10:42:40 +08:00

50 lines
943 B
PHP

<?php
namespace services;
class AwardService extends BaseService {
const ITEM_TYPE = 1;
const HERO_TYPE = 2;
const HEROSKIN_TYPE = 3;
const GUNSKIN_TYPE = 4;
private $items = array();
public function addItem($itemDto)
{
$this->internalAdd(self::ITEM_TYPE, $itemDto);
}
public function addHero($heroDto)
{
$this->internalAdd(self::HERO_TYPE, $heroDto);
}
public function addHeroSkin($heroSkinDto)
{
$this->internalAdd(self::HEROSKIN_TYPE, $heroSkinDto);
}
public function addGunSkin($gunSkinDto)
{
$this->internalAdd(self::GUNSKIN_TYPE, $gunSkinDto);
}
public function toDto()
{
return array(
'items' => $this->items
);
}
private function internalAdd($type, $dto)
{
array_push($items, array(
'type' => $type,
"union_${type}" => $dto
));
}
}