Explorar el Código

接口登录去除

zhangxiaobin hace 1 año
padre
commit
0d8bb08d9d

+ 1 - 1
application/api/controller/Companys.php

@@ -7,7 +7,7 @@ use think\Db;
 
 class Companys extends Api
 {
-    protected $noNeedLogin = [];
+    protected $noNeedLogin = ['getList','getInfo'];
     protected $noNeedRight = '*';
     protected $model = null;
 

+ 58 - 0
application/api/controller/Package.php

@@ -0,0 +1,58 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+
+class Package extends Api
+{
+    protected $noNeedLogin = '*';
+    protected $noNeedRight = '*';
+    protected $model = null;
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->model = Db::name('package');
+    }
+
+    //列表
+    public function getList()
+    {
+        $servicetypeId = input('servicetype_id',0);
+        $companyId = input('company_id',$this->auth->company_id);
+        $keyword = input('keyword','');
+        $where = [
+            'p.company_id' => $companyId,
+            'p.status'     => 1,
+        ];
+        if (!empty($servicetypeId)) {
+            $where['servicetype_id'] = $servicetypeId;
+        }
+        if(!empty($keyword)){
+            $where['p.title|p.info'] = ['LIKE','%'.$keyword.'%'];
+        }
+
+        $list = Db::name('package')->alias('p')
+            ->field('p.*,type.title as servicetype_title')
+            ->join('servicetype type','p.servicetype_id = type.id','LEFT')
+            ->where($where)->order('p.id desc')->autopage()->select();
+
+        $list = list_domain_image($list,['images','content_images']);
+        $this->success('获取成功',$list);
+
+    }
+
+    //详情
+    public function info()
+    {
+        $id = input('id',0);
+        $info = Db::name('package')->alias('p')
+            ->field('p.*,type.title as servicetype_title')
+            ->join('servicetype type','p.servicetype_id = type.id','LEFT')
+            ->where('p.id',$id)->find();
+        $info = info_domain_image($info,['images','content_images']);
+        $this->success(1,$info);
+    }
+}