From 1423ccdd2f7fdb1d37d9c0bf00156f111a39a420 Mon Sep 17 00:00:00 2001 From: liutong <836164388@qq.com> Date: Mon, 19 May 2025 15:09:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=B7=BB=E5=8A=A0=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=85=B1=E4=BA=AB=E5=8A=9F=E8=83=BD=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?-=20=E6=96=B0=E5=A2=9E=E8=B5=84=E6=BA=90=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=A5=E5=8F=A3=20-=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=85=B1=E4=BA=AB=E6=9C=8D=E5=8A=A1=E5=B1=82?= =?UTF-8?q?=E9=80=BB=E8=BE=91=20-=20=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=A1=A8=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=20-=20=E6=9B=B4=E6=96=B0=20API=20=E8=B7=AF=E7=94=B1=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiController/ResourceSharing.php | 42 ++++++++++++ niucloud/app/api/route/route.php | 41 ++++++++++++ .../resource_sharing/ResourceSharing.php | 14 +++- .../api/apiService/ResourceSharingService.php | 64 +++++++++++++++++++ 4 files changed, 158 insertions(+), 3 deletions(-) create mode 100644 niucloud/app/api/controller/apiController/ResourceSharing.php create mode 100644 niucloud/app/service/api/apiService/ResourceSharingService.php diff --git a/niucloud/app/api/controller/apiController/ResourceSharing.php b/niucloud/app/api/controller/apiController/ResourceSharing.php new file mode 100644 index 00000000..a46719c4 --- /dev/null +++ b/niucloud/app/api/controller/apiController/ResourceSharing.php @@ -0,0 +1,42 @@ +member_id;//当前登陆的用户id + + $page = $request->param('page','1');// + $limit = $request->param('limit','10');// + $shared_by = $request->param('shared_by','');//共享人ID + + $where = [ + 'shared_by'=>$shared_by, + ]; + $res= (new ResourceSharingService())->getList($where); + return success($res); + } + +} diff --git a/niucloud/app/api/route/route.php b/niucloud/app/api/route/route.php index a097ebb1..ae0c7af3 100644 --- a/niucloud/app/api/route/route.php +++ b/niucloud/app/api/route/route.php @@ -175,6 +175,20 @@ Route::group(function () { Route::get('common/getDictionary', 'apiController.Common/getDictionary'); + + + + + + + + + + + + + + })->middleware(ApiChannel::class) ->middleware(ApiPersonnelCheckToken::class) ->middleware(ApiLog::class); @@ -191,6 +205,33 @@ Route::group(function () { //客户资源-添加 Route::post('customerResources/add', 'apiController.CustomerResources/add'); + + //资源共享-列表 + Route::get('resourceSharing/index', 'apiController.ResourceSharing/index'); + + + + + + + + + + + + + + + + + + + + + + + + //教研管理文章列表 diff --git a/niucloud/app/model/resource_sharing/ResourceSharing.php b/niucloud/app/model/resource_sharing/ResourceSharing.php index ec34326d..75e69f17 100644 --- a/niucloud/app/model/resource_sharing/ResourceSharing.php +++ b/niucloud/app/model/resource_sharing/ResourceSharing.php @@ -11,6 +11,7 @@ namespace app\model\resource_sharing; +use app\model\customer_resources\CustomerResources; use core\base\BaseModel; use think\model\concern\SoftDelete; use think\model\relation\HasMany; @@ -113,10 +114,17 @@ class ResourceSharing extends BaseModel $query->where("shared_at", $value); } } - - - + + + /** + * 关联客户资源表(一对一) + * @return HasOne + */ + public function customerResource(): HasOne + { + return $this->hasOne(CustomerResources::class, 'id', 'resource_id'); + } } diff --git a/niucloud/app/service/api/apiService/ResourceSharingService.php b/niucloud/app/service/api/apiService/ResourceSharingService.php new file mode 100644 index 00000000..b9e63881 --- /dev/null +++ b/niucloud/app/service/api/apiService/ResourceSharingService.php @@ -0,0 +1,64 @@ +model = (new ResourceSharing()); + } + + //获取列表 + public function getList(array $where) + { + $page_params = $this->getPageParam();//获取请求参数中的页码+分页数 + $page = $page_params['page']; + $limit = $page_params['limit']; + + $person_id = $this->member_id;//当前登录的员工id + + //查当前用户的归属校区 + $campus_id = CampusPersonRole::where('person_id',$person_id)->value('campus_id'); + //查当前用户校区下的全部员工id + $person_id_arr = CampusPersonRole::where('campus_id',$campus_id) ->distinct(true) + ->column('person_id'); + + $model = $this->model; + + if (!isset($where['shared_by']) && $where['shared_by'] !== '') { + $model = $model->where('shared_by', $where['shared_by']); + } + $model = $model->whereIn('user_id', $person_id_arr); + //分页查询 + $res = $model->with([ + 'customerResource'=>function($query){} + ])->paginate([ + 'list_rows' => $limit, + 'page' => $page, + ])->toArray(); + + return $res; + + } + +}