Model.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace app\bug\controller;
  3. use app\bug\model\Moudel;use think\App;
  4. class Model extends Base
  5. {
  6. public function __construct(App $app)
  7. {
  8. parent::__construct($app);
  9. $this->model=new Moudel();
  10. }
  11. public function list(){
  12. $param = $this->request->param(["name"=>"","pid"=>"","level"=>"","status"=>"","company_type"=>""],"post","trim");
  13. $where=[["is_del","=",0],["status","=",1]];
  14. if($param['name']!==""){
  15. $where[]=["name","like","%{$param['name']}%"];
  16. }
  17. if($param['pid']!==""){
  18. $where[]=["pid","=",$param['pid']];
  19. }
  20. if($param['level']!==""){
  21. $where[]=["level","=",$param['level']];
  22. }
  23. if ($param['status']!==""){
  24. $where[]=["status","=",$param['status']];
  25. }
  26. if ($param['company_type']!==""){
  27. $where[]=["company_type","=",$param['company_type']];
  28. }
  29. $list = $this->model->where($where)->order("weight desc")->select();
  30. $data=[];
  31. foreach ($list as $value){
  32. $temp = $this->model->where(['pid'=>$value['id'],'is_del'=>0,"status"=>1])->order("weight desc")
  33. ->select();
  34. $value['child']=$temp;
  35. $data[]=$value;
  36. }
  37. return success("获取成功",$data);
  38. }
  39. }