| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\Service\SupplierService;
 
- /**
 
-  * 供应商/工厂接口
 
-  */
 
- class Supplier extends Base
 
- {
 
-     // 无需登录的接口
 
-     protected $noNeedLogin = ['getFactoryList', 'getFactoryOptions', 'searchFactory', 'getActiveFactoryList'];
 
-     // 无需鉴权的接口
 
-     protected $noNeedRight = ['getFactoryList', 'getFactoryOptions', 'searchFactory', 'getActiveFactoryList'];
 
-     /**
 
-      * 获取工厂/供应商列表
 
-      *
 
-      * @ApiTitle    (获取工厂/供应商列表)
 
-      * @ApiSummary  (获取工厂/供应商列表信息,支持分页和搜索)
 
-      * @ApiMethod   (POST)
 
-      * @ApiRoute    (/api/inspection/supplier/getFactoryList)
 
-      * @ApiParams   (name="page", type="integer", required=false, description="页码,默认1")
 
-      * @ApiParams   (name="limit", type="integer", required=false, description="每页数量,默认10")
 
-      * @ApiParams   (name="name", type="string", required=false, description="供应商名称")
 
-      * @ApiParams   (name="category_id", type="integer", required=false, description="分类ID")
 
-      * @ApiParams   (name="status", type="string", required=false, description="状态:normal正常,hidden隐藏")
 
-      * @ApiReturnParams   (name="code", type="integer", required=true, sample="1")
 
-      * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
 
-      * @ApiReturnParams   (name="data", type="object", description="返回数据")
 
-      * @ApiReturn   ({
 
-          'code':'1',
 
-          'msg':'返回成功',
 
-          'data': {
 
-              'list': [],
 
-              'total': 0,
 
-              'page': 1,
 
-              'limit': 10
 
-          }
 
-         })
 
-      */
 
-     public function getFactoryList()
 
-     {
 
-         $params = $this->request->param();
 
-         $page = $params['page'] ?? 1;
 
-         $limit = $params['limit'] ?? 10;
 
-         $name = $params['name'] ?? '';
 
-         $categoryId = $params['category_id'] ?? '';
 
-         $status = $params['status'] ?? '';
 
-         
 
-         $searchParams = [
 
-             'page' => $page,
 
-             'limit' => $limit
 
-         ];
 
-         
 
-         if ($name) {
 
-             $searchParams['name'] = $name;
 
-         }
 
-         
 
-         if ($categoryId) {
 
-             $searchParams['category_id'] = $categoryId;
 
-         }
 
-         
 
-         if ($status) {
 
-             $searchParams['status'] = $status;
 
-         }
 
-         
 
-         $supplierService = new SupplierService();
 
-         $result = $supplierService->getFactoryList($searchParams);
 
-         
 
-         $this->success('获取成功', $result);
 
-     }
 
-     /**
 
-      * 获取工厂/供应商选项列表
 
-      *
 
-      * @ApiTitle    (获取工厂/供应商选项列表)
 
-      * @ApiSummary  (获取工厂/供应商选项列表,用于下拉选择)
 
-      * @ApiMethod   (POST)
 
-      * @ApiRoute    (/api/inspection/supplier/getFactoryOptions)
 
-      * @ApiReturnParams   (name="code", type="integer", required=true, sample="1")
 
-      * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
 
-      * @ApiReturnParams   (name="data", type="object", description="返回数据")
 
-      * @ApiReturn   ({
 
-          'code':'1',
 
-          'msg':'返回成功',
 
-          'data': {
 
-              '1': '供应商名称1',
 
-              '2': '供应商名称2'
 
-          }
 
-         })
 
-      */
 
-     public function getFactoryOptions()
 
-     {
 
-         $supplierService = new SupplierService();
 
-         $options = $supplierService->getFactoryOptions();
 
-         $this->success('获取成功', $options);
 
-     }
 
-     /**
 
-      * 搜索工厂/供应商
 
-      *
 
-      * @ApiTitle    (搜索工厂/供应商)
 
-      * @ApiSummary  (根据关键词搜索工厂/供应商)
 
-      * @ApiMethod   (POST)
 
-      * @ApiRoute    (/api/inspection/supplier/searchFactory)
 
-      * @ApiParams   (name="keyword", type="string", required=true, description="搜索关键词")
 
-      * @ApiParams   (name="limit", type="integer", required=false, description="限制数量,默认10")
 
-      * @ApiReturnParams   (name="code", type="integer", required=true, sample="1")
 
-      * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
 
-      * @ApiReturnParams   (name="data", type="array", description="返回数据")
 
-      * @ApiReturn   ({
 
-          'code':'1',
 
-          'msg':'返回成功',
 
-          'data': []
 
-         })
 
-      */
 
-     public function searchFactory()
 
-     {
 
-         $params = $this->request->param();
 
-         $keyword = $params['keyword'] ?? '';
 
-         $limit = $params['limit'] ?? 10;
 
-         
 
-         if (empty($keyword)) {
 
-             $this->error('请输入搜索关键词');
 
-         }
 
-         
 
-         $supplierService = new SupplierService();
 
-         $result = $supplierService->searchFactory($keyword, $limit);
 
-         
 
-         $this->success('搜索成功', $result);
 
-     }
 
-     /**
 
-      * 获取工厂/供应商详情
 
-      *
 
-      * @ApiTitle    (获取工厂/供应商详情)
 
-      * @ApiSummary  (根据ID获取工厂/供应商详情)
 
-      * @ApiMethod   (POST)
 
-      * @ApiRoute    (/api/inspection/supplier/getFactoryDetail)
 
-      * @ApiParams   (name="id", type="integer", required=true, description="供应商ID")
 
-      * @ApiReturnParams   (name="code", type="integer", required=true, sample="1")
 
-      * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
 
-      * @ApiReturnParams   (name="data", type="object", description="返回数据")
 
-      * @ApiReturn   ({
 
-          'code':'1',
 
-          'msg':'返回成功',
 
-          'data': {}
 
-         })
 
-      */
 
-     public function getFactoryDetail()
 
-     {
 
-         $params = $this->request->param();
 
-         $id = $params['id'] ?? 0;
 
-         
 
-         if (empty($id)) {
 
-             $this->error('请提供供应商ID');
 
-         }
 
-         
 
-         $supplierService = new SupplierService();
 
-         $result = $supplierService->getFactoryById($id);
 
-         
 
-         if (!$result) {
 
-             $this->error('供应商不存在');
 
-         }
 
-         
 
-         $this->success('获取成功', $result);
 
-     }
 
-     /**
 
-      * 获取启用状态的工厂/供应商列表
 
-      *
 
-      * @ApiTitle    (获取启用状态的工厂/供应商列表)
 
-      * @ApiSummary  (获取启用状态的工厂/供应商列表,带缓存)
 
-      * @ApiMethod   (POST)
 
-      * @ApiRoute    (/api/inspection/supplier/getActiveFactoryList)
 
-      * @ApiReturnParams   (name="code", type="integer", required=true, sample="1")
 
-      * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
 
-      * @ApiReturnParams   (name="data", type="array", description="返回数据")
 
-      * @ApiReturn   ({
 
-          'code':'1',
 
-          'msg':'返回成功',
 
-          'data': []
 
-         })
 
-      */
 
-     public function getActiveFactoryList()
 
-     {
 
-         $supplierService = new SupplierService();
 
-         $result = $supplierService->getActiveFactoryListWithCache();
 
-         
 
-         $this->success('获取成功', $result);
 
-     }
 
- }
 
 
  |