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; + + } + +}