4 changed files with 158 additions and 3 deletions
@ -0,0 +1,42 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\api\controller\apiController; |
||||
|
|
||||
|
use app\Request; |
||||
|
use app\service\api\apiService\ResourceSharingService; |
||||
|
use core\base\BaseApiService; |
||||
|
|
||||
|
/** |
||||
|
* 资源共享表相关接口 |
||||
|
* Class Personnel |
||||
|
* @package app\api\controller\apiController |
||||
|
*/ |
||||
|
class ResourceSharing extends BaseApiService |
||||
|
{ |
||||
|
|
||||
|
//资源共享列表 |
||||
|
public function index(Request $request) |
||||
|
{ |
||||
|
$user_id = $this->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); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\api\apiService; |
||||
|
|
||||
|
use app\model\campus_person_role\CampusPersonRole; |
||||
|
use app\model\resource_sharing\ResourceSharing; |
||||
|
use core\base\BaseApiService; |
||||
|
|
||||
|
/** |
||||
|
* 资源共享服务层 |
||||
|
* Class MemberService |
||||
|
* @package app\service\api\member |
||||
|
*/ |
||||
|
class ResourceSharingService extends BaseApiService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->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; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue