PlatformArticle.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. class PlatformArticle extends Api
  6. {
  7. protected $noNeedLogin = [];
  8. protected $noNeedRight = '*';
  9. protected $model = null;
  10. public function _initialize()
  11. {
  12. parent::_initialize();
  13. $this->model = Db::name('platform_article');
  14. }
  15. /**
  16. * 分类列表
  17. * @return void
  18. */
  19. public function getTypeList()
  20. {
  21. try {
  22. $companyId = $this->request->param('company_id',0);
  23. $position = $this->request->param('position',0);//位置:0=首页,1=门店印象
  24. $field = 'id,title,image,url';
  25. $where['status'] = 1;
  26. $where['position'] = $position;
  27. $where['company_id'] = $companyId;
  28. $result = $this->model->field($field)->where($where)->order('weigh asc')->select();
  29. if (!empty($result)) {
  30. foreach ($result as $key => &$value) {
  31. !empty($value['image']) && $value['image'] = cdnurl($value['image']);
  32. }
  33. }
  34. $this->success('获取成功',$result);
  35. } catch (Exception $e) {
  36. $this->error($e->getMessage());
  37. }
  38. }
  39. }