This commit is contained in:
wong
2025-12-23 11:38:25 +08:00
parent 988d7fcdd3
commit 7a4f40de54

View File

@@ -787,16 +787,24 @@ class ContentLibraryController extends Controller
return json(['code' => 400, 'msg' => '参数错误']); 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') $item = ContentItem::alias('i')
->join('content_library l', 'i.libraryId = l.id') ->join('content_library l', 'i.libraryId = l.id')
->where([ ->where($where)
['i.id', '=', $id],
['l.companyId', '=', $this->request->userInfo['companyId']]
])
->find(); ->find();
if (!$item) {
if(empty($item)) {
return json(['code' => 500, 'msg' => '内容项目不存在或无权限操作']); return json(['code' => 500, 'msg' => '内容项目不存在或无权限操作']);
} }