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) {