智慧教务系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

90 lines
2.9 KiB

<?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
$shared_at_str = $request->param('shared_at_str','');//共享时间|[开始时间(Y-m-d),结束时间(Y-m-d)]
$shared_at_arr = [];
if(!empty($shared_at_str)){
$shared_at_arr = explode(' ~ ',$shared_at_str);
$shared_at_arr[0] = "{$shared_at_arr[0]} 00:00:00";
$shared_at_arr[1] = "{$shared_at_arr[1]} 23:59:59";
}
$where = [
'shared_by'=>$shared_by,
'shared_at_arr'=>$shared_at_arr,
];
$res= (new ResourceSharingService())->getList($where);
return success($res);
}
//把资源分配给指定员工
public function assign(Request $request)
{
$id = $request->param('resource_sharing_id', '');//资源共享表
$shared_by = $request->param('shared_by', '');//共享人ID
if (empty($id) || empty($shared_by)) {
return fail('缺少必要参数');
}
$where = [
'id' => $id,
];
$data = [
'shared_by' => $shared_by
];
$info = (new ResourceSharingService())->info($where);//获取详情
if (!$info['code']) {
return fail($info['msg']);
} else {
if ($info['data']['shared_by'] > 0) {
if ($info['data']['shared_by'] == $shared_by) {
return success('当前资源已分享给该用户');
} else {
return fail('该资源已被分享给其他用户');
}
}
}
$res = (new ResourceSharingService())->editData($where, $data);//更新
if (!$res['code']) {
return fail('操作失败');
}
return success('操作成功');
}
}