From 73ddecc4dc6649280ba66ae817e9383a485ff75c Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Fri, 30 May 2025 17:15:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(customer-resources):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=85=A8=E9=83=A8=E5=AE=A2=E6=88=B7=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 getAll 方法,用于获取全部客户资源数据- 在路由中添加 getAll 接口 - 实现 CustomerResourcesService 中的 getAll 方法 - 接口支持根据客户姓名查询,返回客户资源列表 --- .../apiController/CustomerResources.php | 19 +++++++++++ niucloud/app/api/route/route.php | 2 ++ .../apiService/CustomerResourcesService.php | 33 +++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/niucloud/app/api/controller/apiController/CustomerResources.php b/niucloud/app/api/controller/apiController/CustomerResources.php index 844f7611..3112f01c 100644 --- a/niucloud/app/api/controller/apiController/CustomerResources.php +++ b/niucloud/app/api/controller/apiController/CustomerResources.php @@ -23,6 +23,25 @@ use core\base\BaseApiService; class CustomerResources extends BaseApiService { + + //获取全部客户资源 + public function getAll(Request $request){ + + $name = $request->param('name', '');//客户姓名 + if(empty($name)){ + return fail("缺少客户姓名"); + } + + $where = [ + 'name'=>$name + ]; + $res = (new CustomerResourcesService())->getAll($where); + if(!$res['code']){ + return fail($res['msg']); + } + return success($res['data']); + } + //客户资源添加 public function add(Request $request){ diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index 55ac4def..23d89641 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -221,6 +221,8 @@ Route::group(function () { Route::post('customerResources/edit', 'apiController.CustomerResources/edit'); //客户资源-修改记录列表 Route::get('customerResources/getEditLogList', 'apiController.CustomerResources/getEditLogList'); + //客户资源-获取全部客户资源列表 + Route::get('customerResources/getAll', 'apiController.CustomerResources/getAll'); //资源共享-列表 diff --git a/niucloud/app/service/api/apiService/CustomerResourcesService.php b/niucloud/app/service/api/apiService/CustomerResourcesService.php index d8e99818..fa33da12 100644 --- a/niucloud/app/service/api/apiService/CustomerResourcesService.php +++ b/niucloud/app/service/api/apiService/CustomerResourcesService.php @@ -35,6 +35,39 @@ class CustomerResourcesService extends BaseApiService parent::__construct(); } + //获取全部客户资源数据 + public function getAll(array $where,string $field = '*') + { + $res = [ + 'code' => 0, + 'msg' => '操作失败', + 'data' => [] + ]; + if(!$where){ + $res['msg'] = '查询条件不能为空'; + return $res; + } + $model = new CustomerResources(); + if(!empty($where['name'])){ + $model = $model->where('name', 'like', "%{$where['name']}%"); + } + $data = $model->field($field) + ->append([ + 'initial_intent_name' + ]) + ->select()->toArray(); + if (!$data) { + $res['msg'] = '暂无数据'; + return $res; + } + $res['code'] = 1; + $res['msg'] = '操作成功'; + $res['data'] = $data; + return $res; + + + } + //添加数据 public function addData(array $customer_resources_data, array $six_speed_data) {