diff --git a/Server/application/cunkebao/controller/ContentLibraryController.php b/Server/application/cunkebao/controller/ContentLibraryController.php index 418fb6c95..1151a876c 100644 --- a/Server/application/cunkebao/controller/ContentLibraryController.php +++ b/Server/application/cunkebao/controller/ContentLibraryController.php @@ -787,16 +787,24 @@ class ContentLibraryController extends Controller return json(['code' => 400, 'msg' => '参数错误']); } + + $where = [ + ['i.id', '=', $id], + ['l.companyId', '=', $this->request->userInfo['companyId']] + ]; + + if(empty($this->request->userInfo['isAdmin'])){ + $where[] = ['l.userId', '=', $this->request->userInfo['id']]; + } + // 查询内容项目是否存在并检查权限 $item = ContentItem::alias('i') ->join('content_library l', 'i.libraryId = l.id') - ->where([ - ['i.id', '=', $id], - ['l.companyId', '=', $this->request->userInfo['companyId']] - ]) + ->where($where) ->find(); - if (!$item) { + + if(empty($item)) { return json(['code' => 500, 'msg' => '内容项目不存在或无权限操作']); }