AdvService.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\service\api\diy;
  12. use app\dict\diy\AdvPositionDict;
  13. use app\model\diy\Adv;
  14. use core\base\BaseApiService;
  15. use core\exception\ApiException;
  16. /**
  17. * 广告服务层
  18. * Class DiyService
  19. * @package app\service\api\diy
  20. */
  21. class AdvService extends BaseApiService
  22. {
  23. public function __construct()
  24. {
  25. parent::__construct();
  26. $this->model = new Adv();
  27. }
  28. /**
  29. * 获取广告信息
  30. * @return array
  31. */
  32. public function getInfo(string $ap_key)
  33. {
  34. $adv_position = AdvPositionDict::getAdvPosition();
  35. $position_list = array_column($adv_position,null,'keywords');
  36. if(!array_key_exists($ap_key, $position_list)) throw new ApiException("DIY_ADV_POSITION_NOT_EXIST");
  37. $info = $position_list[$ap_key];
  38. $info['adv_list'] = $this->model->where([['ap_key', '=', $ap_key]])->order('slide_sort desc')->select()->toArray();
  39. return $info;
  40. }
  41. }