adCategoryRepository = $adCategoryRepository; $this->adRepository = $adRepository; } public function getAds($data) { $where = array(); $theme = 'default'; if (array_key_exists('theme', $data)) { $theme = $data['theme']; } $where['c.theme'] = $theme; $org = 'Home'; if (array_key_exists('org', $data)) { $org = $data['org']; } $where['c.org'] = $org; //错误提示 if (!in_array($org, array('Home','Mobile','Apk'))) { throw new \Exception('参数不正确'); } if (array_key_exists('alias', $data)) { $alias = $data['alias']; $where['c.alias'] = $alias; } $where['is_display'] = 1; $limit = $data['num']; //获取广告信息 $ads = $this->adRepository->getAds($where, $limit); return $ads; } }