SlidesController.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 文件说明:幻灯片
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: wuwu <15093565100@163.com>
  8. // +----------------------------------------------------------------------
  9. // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
  10. // +----------------------------------------------------------------------
  11. // | Date: 2017-5-25
  12. // +----------------------------------------------------------------------
  13. namespace api\home\controller;
  14. use api\home\service\SlideService;
  15. use cmf\controller\RestBaseController;
  16. class SlidesController extends RestBaseController
  17. {
  18. /**
  19. * 获取幻灯片
  20. * @throws \think\db\exception\DataNotFoundException
  21. * @throws \think\db\exception\ModelNotFoundException
  22. * @throws \think\exception\DbException
  23. */
  24. public function read()
  25. {
  26. //slide为空或不存在抛出异常
  27. $id = $this->request->param('id', 0, 'intval');
  28. if (empty($id)) {
  29. $this->error('缺少ID参数');
  30. }
  31. $map['id'] = $id;
  32. $slideService = new SlideService();
  33. $data = $slideService->SlideList($map);
  34. //剔除分类状态隐藏 剔除分类下显示数据为空
  35. if (empty($data) || $data['items']->isEmpty()) {
  36. $this->success('该组幻灯片显示数据为空', []);
  37. }
  38. $this->success("该组幻灯片获取成功!", $data['items']);
  39. }
  40. }