Servicetype.php 930 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. class Servicetype 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('servicetype');
  14. }
  15. /**
  16. * 服务类型列表
  17. * @return void
  18. */
  19. public function getList()
  20. {
  21. try {
  22. $isUpkeep = $this->request->param('is_upkeep',-1);
  23. $field = 'id,title';
  24. $where = [];
  25. if ($isUpkeep != -1) {
  26. $where['is_upkeep'] = $isUpkeep;
  27. }
  28. $result = $this->model->field($field)->where($where)->order('weigh asc createtime desc')->select();
  29. $this->success('获取成功',$result);
  30. } catch (Exception $e) {
  31. $this->error($e->getMessage());
  32. }
  33. }
  34. }