DocsController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Controller;
  4. use App\Module\Base;
  5. use App\Module\Docs;
  6. use App\Module\Users;
  7. use App\Tasks\PushTask;
  8. use Cache;
  9. use DB;
  10. use Hhxsv5\LaravelS\Swoole\Task\Task;
  11. use Request;
  12. /**
  13. * @apiDefine docs
  14. *
  15. * 知识库
  16. */
  17. class DocsController extends Controller
  18. {
  19. public function __invoke($method, $action = '')
  20. {
  21. $app = $method ? $method : 'main';
  22. if ($action) {
  23. $app .= "__" . $action;
  24. }
  25. return (method_exists($this, $app)) ? $this->$app() : Base::ajaxError("404 not found (" . str_replace("__", "/", $app) . ").");
  26. }
  27. /**
  28. * 知识库列表
  29. *
  30. * @apiParam {Number} [page] 当前页,默认:1
  31. * @apiParam {Number} [pagesize] 每页显示数量,默认:20,最大:100
  32. */
  33. public function book__lists()
  34. {
  35. $user = Users::authE();
  36. if (Base::isError($user)) {
  37. return $user;
  38. } else {
  39. $user = $user['data'];
  40. }
  41. //
  42. $lists = DB::table('docs_book')
  43. ->where('username', $user['username'])
  44. ->orWhere('role_edit', 'reg')
  45. ->orWhere('role_look', 'reg')
  46. ->orWhere(function ($query) use ($user) {
  47. $query->where('role_edit', 'private')->where('username', $user['username']);
  48. })
  49. ->orWhere(function ($query) use ($user) {
  50. $query->where('role_edit', 'member')->whereIn('id', function ($query2) use ($user) {
  51. $query2->select('bookid')
  52. ->from('docs_users')
  53. ->where('username', $user['username'])
  54. ->whereRaw(env('DB_PREFIX') . 'docs_book.id = bookid');
  55. });
  56. })
  57. ->orderByDesc('id')
  58. ->paginate(Base::getPaginate(100, 20));
  59. $lists = Base::getPageList($lists);
  60. if ($lists['total'] == 0) {
  61. return Base::retError('暂无知识库', $lists);
  62. }
  63. return Base::retSuccess('success', $lists);
  64. }
  65. /**
  66. * 添加/修改知识库
  67. *
  68. * @apiParam {Number} id 知识库数据ID
  69. * @apiParam {String} title 知识库名称
  70. */
  71. public function book__add()
  72. {
  73. $user = Users::authE();
  74. if (Base::isError($user)) {
  75. return $user;
  76. } else {
  77. $user = $user['data'];
  78. }
  79. //
  80. $id = intval(Request::input('id'));
  81. $title = trim(Request::input('title'));
  82. if ($id > 0) {
  83. $role = Docs::checkRole($id, 'edit');
  84. if (Base::isError($role)) {
  85. return $role;
  86. }
  87. }
  88. if (mb_strlen($title) < 2 || mb_strlen($title) > 100) {
  89. return Base::retError('标题限制2-100个字!');
  90. }
  91. if ($id > 0) {
  92. // 修改
  93. $row = Base::DBC2A(DB::table('docs_book')->where('id', $id)->first());
  94. if (empty($row)) {
  95. return Base::retError('知识库不存在或已被删除!');
  96. }
  97. $data = [
  98. 'title' => $title,
  99. ];
  100. DB::table('docs_book')->where('id', $id)->update($data);
  101. return Base::retSuccess('修改成功!', $data);
  102. } else {
  103. // 添加
  104. $data = [
  105. 'username' => $user['username'],
  106. 'title' => $title,
  107. 'indate' => Base::time(),
  108. ];
  109. $id = DB::table('docs_book')->insertGetId($data);
  110. if (empty($id)) {
  111. return Base::retError('系统繁忙,请稍后再试!');
  112. }
  113. $data['id'] = $id;
  114. return Base::retSuccess('添加成功!', $data);
  115. }
  116. }
  117. /**
  118. * 设置知识库
  119. *
  120. * @apiParam {Number} id 知识库数据ID
  121. * @apiParam {String} role_edit
  122. * @apiParam {String} role_view
  123. */
  124. public function book__setting()
  125. {
  126. $user = Users::authE();
  127. if (Base::isError($user)) {
  128. return $user;
  129. } else {
  130. $user = $user['data'];
  131. }
  132. //
  133. $id = intval(Request::input('id'));
  134. $type = trim(Request::input('type'));
  135. $role = Docs::checkRole($id, 'edit');
  136. if (Base::isError($role) && $role['ret'] < 0) {
  137. return $role;
  138. }
  139. $row = Base::DBC2A(DB::table('docs_book')->where('id', $id)->first());
  140. if (empty($row)) {
  141. return Base::retError('知识库不存在或已被删除!');
  142. }
  143. $setting = Base::string2array($row['setting']);
  144. if ($type == 'save') {
  145. if (Base::isError($role)) {
  146. return $role;
  147. }
  148. foreach (Request::input() AS $key => $value) {
  149. if (in_array($key, ['role_edit', 'role_look', 'role_view'])) {
  150. $setting[$key] = $value;
  151. }
  152. }
  153. DB::table('docs_book')->where('id', $id)->update([
  154. 'role_edit' => $setting['role_edit'],
  155. 'role_look' => $setting['role_look'],
  156. 'role_view' => $setting['role_view'],
  157. 'setting' => Base::array2string($setting),
  158. ]);
  159. }
  160. return Base::retSuccess($type == 'save' ? '修改成功!' : 'success', $setting ?: json_decode('{}'));
  161. }
  162. /**
  163. * 删除知识库
  164. *
  165. * @apiParam {Number} id 知识库数据ID
  166. */
  167. public function book__delete()
  168. {
  169. $user = Users::authE();
  170. if (Base::isError($user)) {
  171. return $user;
  172. } else {
  173. $user = $user['data'];
  174. }
  175. //
  176. $id = intval(Request::input('id'));
  177. $row = Base::DBC2A(DB::table('docs_book')->where('id', $id)->first());
  178. if (empty($row)) {
  179. return Base::retError('知识库不存在或已被删除!');
  180. }
  181. if ($row['username'] != $user['username']) {
  182. return Base::retError('此操作仅限知识库负责人!');
  183. }
  184. DB::table('docs_book')->where('id', $id)->delete();
  185. DB::table('docs_section')->where('bookid', $id)->delete();
  186. DB::table('docs_content')->where('bookid', $id)->delete();
  187. return Base::retSuccess('删除成功!');
  188. }
  189. /**
  190. * 成员-列表
  191. *
  192. * @apiParam {Number} id 知识库数据ID
  193. * @apiParam {Number} [page] 当前页,默认:1
  194. * @apiParam {Number} [pagesize] 每页显示数量,默认:20,最大:100
  195. */
  196. public function users__lists()
  197. {
  198. $user = Users::authE();
  199. if (Base::isError($user)) {
  200. return $user;
  201. } else {
  202. $user = $user['data'];
  203. }
  204. //
  205. $id = intval(Request::input('id'));
  206. $role = Docs::checkRole($id, 'edit');
  207. if (Base::isError($role)) {
  208. return $role;
  209. }
  210. $row = Base::DBC2A(DB::table('docs_book')->where('id', $id)->first());
  211. if (empty($row)) {
  212. return Base::retError('知识库不存在或已被删除!');
  213. }
  214. //
  215. $lists = DB::table('docs_book')
  216. ->join('docs_users', 'docs_book.id', '=', 'docs_users.bookid')
  217. ->select(['docs_book.title', 'docs_users.*'])
  218. ->where([
  219. ['docs_book.id', $id],
  220. ])
  221. ->orderByDesc('docs_users.id')->paginate(Base::getPaginate(100, 20));
  222. $lists = Base::getPageList($lists);
  223. if ($lists['total'] == 0) {
  224. return Base::retError('未找到任何相关的成员');
  225. }
  226. foreach ($lists['lists'] AS $key => $item) {
  227. $userInfo = Users::username2basic($item['username']);
  228. $lists['lists'][$key]['userimg'] = $userInfo['userimg'];
  229. $lists['lists'][$key]['nickname'] = $userInfo['nickname'];
  230. $lists['lists'][$key]['profession'] = $userInfo['profession'];
  231. }
  232. return Base::retSuccess('success', $lists);
  233. }
  234. /**
  235. * 成员-添加、删除
  236. *
  237. * @apiParam {String} act
  238. * - delete: 删除成员
  239. * - else: 添加成员
  240. * @apiParam {Number} id 知识库数据ID
  241. * @apiParam {Array|String} username 用户名(或用户名组)
  242. */
  243. public function users__join()
  244. {
  245. $user = Users::authE();
  246. if (Base::isError($user)) {
  247. return $user;
  248. } else {
  249. $user = $user['data'];
  250. }
  251. //
  252. $id = intval(Request::input('id'));
  253. $role = Docs::checkRole($id, 'edit');
  254. if (Base::isError($role)) {
  255. return $role;
  256. }
  257. $row = Base::DBC2A(DB::table('docs_book')->where('id', $id)->first());
  258. if (empty($row)) {
  259. return Base::retError('知识库不存在或已被删除!');
  260. }
  261. //
  262. $usernames = Request::input('username');
  263. if (empty($usernames)) {
  264. return Base::retError('参数错误!');
  265. }
  266. if (!is_array($usernames)) {
  267. if (Base::strExists($usernames, ',')) {
  268. $usernames = explode(',', $usernames);
  269. } else {
  270. $usernames = [$usernames];
  271. }
  272. }
  273. //
  274. foreach ($usernames AS $username) {
  275. $inRow = Base::DBC2A(DB::table('docs_users')->where(['bookid' => $id, 'username' => $username])->first());
  276. switch (Request::input('act')) {
  277. case 'delete': {
  278. if ($inRow) {
  279. DB::table('docs_users')->where([
  280. 'bookid' => $id,
  281. 'username' => $username
  282. ])->delete();
  283. }
  284. break;
  285. }
  286. default: {
  287. if (!$inRow && $username != $user['username']) {
  288. DB::table('docs_users')->insert([
  289. 'bookid' => $id,
  290. 'username' => $username,
  291. 'indate' => Base::time()
  292. ]);
  293. }
  294. break;
  295. }
  296. }
  297. }
  298. return Base::retSuccess('操作完成!');
  299. }
  300. /**
  301. * 章节列表
  302. *
  303. * @apiParam {String} act 请求方式,用于判断权限
  304. * - edit: 管理页请求
  305. * - view: 阅读页请求
  306. * @apiParam {Number} bookid 知识库数据ID
  307. */
  308. public function section__lists()
  309. {
  310. $bookid = intval(Request::input('bookid'));
  311. $role = Docs::checkRole($bookid, Request::input('act'));
  312. if (Base::isError($role) && $role['ret'] < 0) {
  313. return $role;
  314. }
  315. $lists = Base::DBC2A(DB::table('docs_section')
  316. ->where('bookid', $bookid)
  317. ->orderByDesc('inorder')
  318. ->orderByDesc('id')
  319. ->take(500)
  320. ->get());
  321. if (empty($lists)) {
  322. return Base::retError('暂无章节');
  323. }
  324. foreach ($lists AS $key => $item) {
  325. $lists[$key]['icon'] = Base::fillUrl('images/files/' . $item['type'] . '.png');
  326. }
  327. $bookDetail = Base::DBC2A(DB::table('docs_book')->select(['title'])->where('id', $bookid)->first());
  328. return Base::retSuccess('success', [
  329. 'book' => $bookDetail ?: json_decode('{}'),
  330. 'tree' => Base::list2Tree($lists, 'id', 'parentid')
  331. ]);
  332. }
  333. /**
  334. * 添加/修改章节
  335. *
  336. * @apiParam {Number} bookid 知识库数据ID
  337. * @apiParam {String} title 章节名称
  338. * @apiParam {String} type 章节类型
  339. */
  340. public function section__add()
  341. {
  342. $user = Users::authE();
  343. if (Base::isError($user)) {
  344. return $user;
  345. } else {
  346. $user = $user['data'];
  347. }
  348. //
  349. $bookid = intval(Request::input('bookid'));
  350. $role = Docs::checkRole($bookid, 'edit');
  351. if (Base::isError($role)) {
  352. return $role;
  353. }
  354. $bookRow = Base::DBC2A(DB::table('docs_book')->where('id', $bookid)->first());
  355. if (empty($bookRow)) {
  356. return Base::retError('知识库不存在或已被删除!');
  357. }
  358. $count = DB::table('docs_section')->where('bookid', $bookid)->count();
  359. if ($count >= 500) {
  360. return Base::retError(['知识库章节已经超过最大限制(%)!', 500]);
  361. }
  362. //
  363. $id = intval(Request::input('id'));
  364. $title = trim(Request::input('title'));
  365. $type = trim(Request::input('type'));
  366. if (mb_strlen($title) < 2 || mb_strlen($title) > 100) {
  367. return Base::retError('标题限制2-100个字!');
  368. }
  369. if ($id > 0) {
  370. // 修改
  371. $row = Base::DBC2A(DB::table('docs_section')->where('id', $id)->first());
  372. if (empty($row)) {
  373. return Base::retError('知识库不存在或已被删除!');
  374. }
  375. $data = [
  376. 'title' => $title,
  377. ];
  378. DB::table('docs_section')->where('id', $id)->update($data);
  379. return Base::retSuccess('修改成功!', $data);
  380. } else {
  381. // 添加
  382. if (!in_array($type, ['document', 'mind', 'sheet', 'flow', 'folder'])) {
  383. return Base::retError('参数错误!');
  384. }
  385. $parentid = 0;
  386. if ($id < 0) {
  387. $count = Base::DBC2A(DB::table('docs_section')->where('id', abs($id))->where('bookid', $bookid)->count());
  388. if ($count > 0) {
  389. $parentid = abs($id);
  390. }
  391. }
  392. $data = [
  393. 'bookid' => $bookid,
  394. 'parentid' => $parentid,
  395. 'username' => $user['username'],
  396. 'title' => $title,
  397. 'type' => $type,
  398. 'inorder' => intval(DB::table('docs_section')->select(['inorder'])->where('bookid', $bookid)->orderByDesc('inorder')->value('inorder')) + 1,
  399. 'indate' => Base::time(),
  400. ];
  401. $id = DB::table('docs_section')->insertGetId($data);
  402. if (empty($id)) {
  403. return Base::retError('系统繁忙,请稍后再试!');
  404. }
  405. $data['id'] = $id;
  406. return Base::retSuccess('添加成功!', $data);
  407. }
  408. }
  409. /**
  410. * 排序章节
  411. *
  412. * @apiParam {Number} bookid 知识库数据ID
  413. * @apiParam {String} oldsort 旧排序数据
  414. * @apiParam {String} newsort 新排序数据
  415. */
  416. public function section__sort()
  417. {
  418. $user = Users::authE();
  419. if (Base::isError($user)) {
  420. return $user;
  421. } else {
  422. $user = $user['data'];
  423. }
  424. //
  425. $bookid = intval(Request::input('bookid'));
  426. $role = Docs::checkRole($bookid, 'edit');
  427. if (Base::isError($role)) {
  428. return $role;
  429. }
  430. $bookRow = Base::DBC2A(DB::table('docs_book')->where('id', $bookid)->first());
  431. if (empty($bookRow)) {
  432. return Base::retError('知识库不存在或已被删除!');
  433. }
  434. //
  435. $newSort = explode(";", Request::input('newsort'));
  436. if (count($newSort) == 0) {
  437. return Base::retError('参数错误!');
  438. }
  439. //
  440. $count = count($newSort);
  441. foreach ($newSort AS $sort => $item) {
  442. list($newId, $newParentid) = explode(':', $item);
  443. DB::table('docs_section')->where([
  444. 'id' => $newId,
  445. 'bookid' => $bookid
  446. ])->update([
  447. 'inorder' => $count - intval($sort),
  448. 'parentid' => $newParentid
  449. ]);
  450. }
  451. return Base::retSuccess('保存成功!');
  452. }
  453. /**
  454. * 删除章节
  455. *
  456. * @apiParam {Number} id 章节数据ID
  457. */
  458. public function section__delete()
  459. {
  460. $user = Users::authE();
  461. if (Base::isError($user)) {
  462. return $user;
  463. } else {
  464. $user = $user['data'];
  465. }
  466. //
  467. $id = intval(Request::input('id'));
  468. $row = Base::DBC2A(DB::table('docs_section')->where('id', $id)->first());
  469. if (empty($row)) {
  470. return Base::retError('文档不存在或已被删除!');
  471. }
  472. $role = Docs::checkRole($row['bookid'], 'edit');
  473. if (Base::isError($role)) {
  474. return $role;
  475. }
  476. DB::table('docs_section')->where('parentid', $id)->update([ 'parentid' => $row['parentid'] ]);
  477. DB::table('docs_section')->where('id', $id)->delete();
  478. DB::table('docs_content')->where('sid', $id)->delete();
  479. return Base::retSuccess('删除成功!');
  480. }
  481. /**
  482. * 获取章节内容
  483. *
  484. * @apiParam {String} act 请求方式,用于判断权限
  485. * - edit: 管理页请求
  486. * - view: 阅读页请求
  487. * @apiParam {Number|String} id 章节数据ID(或:章节数据ID-历史数据ID)
  488. */
  489. public function section__content()
  490. {
  491. $id = Request::input('id');
  492. $hid = 0;
  493. if (Base::strExists($id, '-')) {
  494. list($id, $hid) = explode("-", $id);
  495. }
  496. $id = intval($id);
  497. $hid = intval($hid);
  498. $row = Base::DBC2A(DB::table('docs_section')->where('id', $id)->first());
  499. if (empty($row)) {
  500. return Base::retError('文档不存在或已被删除!');
  501. }
  502. $role = Docs::checkRole($row['bookid'], Request::input('act'));
  503. if (Base::isError($role) && $role['ret'] < 0) {
  504. return $role;
  505. }
  506. $whereArray = [];
  507. if ($hid > 0) {
  508. $whereArray[] = ['id', '=', $hid];
  509. }
  510. $whereArray[] = ['sid', '=', $id];
  511. $cRow = Base::DBC2A(DB::table('docs_content')->select(['id AS hid', 'content'])->where($whereArray)->orderByDesc('id')->first());
  512. if (empty($cRow)) {
  513. $cRow = [ 'hid' => 0, 'content' => '' ];
  514. }
  515. return Base::retSuccess('success', array_merge($row, $cRow));
  516. }
  517. /**
  518. * 获取章节历史内容
  519. *
  520. * @apiParam {Number} id 章节数据ID
  521. */
  522. public function section__history()
  523. {
  524. $user = Users::authE();
  525. if (Base::isError($user)) {
  526. return $user;
  527. } else {
  528. $user = $user['data'];
  529. }
  530. //
  531. $id = intval(Request::input('id'));
  532. $row = Base::DBC2A(DB::table('docs_section')->where('id', $id)->first());
  533. if (empty($row)) {
  534. return Base::retError('文档不存在或已被删除!');
  535. }
  536. $role = Docs::checkRole($row['bookid'], 'edit');
  537. if (Base::isError($role) && $role['ret'] < 0) {
  538. return $role;
  539. }
  540. //
  541. $lists = Base::DBC2A(DB::table('docs_content')
  542. ->where('sid', $id)
  543. ->orderByDesc('id')
  544. ->take(50)
  545. ->get());
  546. if (count($lists) <= 1) {
  547. return Base::retError('暂无历史数据');
  548. }
  549. return Base::retSuccess('success', $lists);
  550. }
  551. /**
  552. * {post} 保存章节内容
  553. *
  554. * @apiParam {Number} id 章节数据ID
  555. * @apiParam {Object} [D] Request Payload 提交
  556. * - content: 内容
  557. */
  558. public function section__save()
  559. {
  560. $user = Users::authE();
  561. if (Base::isError($user)) {
  562. return $user;
  563. } else {
  564. $user = $user['data'];
  565. }
  566. //
  567. $id = intval(Base::getPostValue('id'));
  568. $row = Base::DBC2A(DB::table('docs_section')->where('id', $id)->first());
  569. if (empty($row)) {
  570. return Base::retError('文档不存在或已被删除!');
  571. }
  572. $role = Docs::checkRole($row['bookid'], 'edit');
  573. if (Base::isError($role)) {
  574. return $role;
  575. }
  576. if ($row['lockdate'] + 60 > Base::time() && $row['lockname'] != $user['username']) {
  577. return Base::retError(['已被会员【%】锁定!', Users::nickname($row['lockname'])]);
  578. }
  579. $content = Base::getPostValue('content');
  580. $text = '';
  581. if ($row['type'] == 'document') {
  582. $data = Base::json2array($content);
  583. $isRep = false;
  584. preg_match_all("/<img\s*src=\"data:image\/(png|jpg|jpeg);base64,(.*?)\"/s", $data['content'], $matchs);
  585. foreach ($matchs[2] as $key => $text) {
  586. $p = "uploads/docs/document/" . $id . "/";
  587. Base::makeDir(public_path($p));
  588. $p.= md5($text) . "." . $matchs[1][$key];
  589. $r = file_put_contents(public_path($p), base64_decode($text));
  590. if ($r) {
  591. $data['content'] = str_replace($matchs[0][$key], '<img src="' . Base::fillUrl($p) . '"', $data['content']);
  592. $isRep = true;
  593. }
  594. }
  595. $text = strip_tags($data['content']);
  596. if ($isRep == true) {
  597. $content = Base::array2json($data);
  598. }
  599. }
  600. DB::table('docs_content')->where('sid', $id)->update(['text' => '']);
  601. DB::table('docs_content')->insert([
  602. 'bookid' => $row['bookid'],
  603. 'sid' => $id,
  604. 'content' => $content,
  605. 'text' => $text,
  606. 'username' => $user['username'],
  607. 'indate' => Base::time()
  608. ]);
  609. Docs::notice($id, [ 'type' => 'update' ]);
  610. //
  611. return Base::retSuccess('保存成功!', [
  612. 'sid' => $id,
  613. 'content' => Base::json2array($content),
  614. ]);
  615. }
  616. /**
  617. * 锁定章节内容
  618. *
  619. * @apiParam {String} act
  620. * - lock: 锁定
  621. * - unlock: 解锁
  622. * @apiParam {Number} id 章节数据ID
  623. */
  624. public function section__lock()
  625. {
  626. $user = Users::authE();
  627. if (Base::isError($user)) {
  628. return $user;
  629. } else {
  630. $user = $user['data'];
  631. }
  632. //
  633. $id = intval(Request::input('id'));
  634. $act = trim(Request::input('act'));
  635. $row = Base::DBC2A(DB::table('docs_section')->where('id', $id)->first());
  636. if (empty($row)) {
  637. return Base::retError('文档不存在或已被删除!');
  638. }
  639. $role = Docs::checkRole($row['bookid'], 'edit');
  640. if (Base::isError($role)) {
  641. return $role;
  642. }
  643. if ($row['lockdate'] + 60 > Base::time() && $row['lockname'] != $user['username']) {
  644. return Base::retError(['已被会员【%】锁定!', Users::nickname($row['lockname'])]);
  645. }
  646. if ($act == 'lock') {
  647. $upArray = [
  648. 'lockname' => $user['username'],
  649. 'lockdate' => Base::time(),
  650. ];
  651. } else {
  652. $upArray = [
  653. 'lockname' => '',
  654. 'lockdate' => 0,
  655. ];
  656. }
  657. DB::table('docs_section')->where('id', $id)->update($upArray);
  658. $upArray['type'] = $act;
  659. Docs::notice($id, $upArray);
  660. //
  661. return Base::retSuccess($act == 'lock' ? '锁定成功' : '已解除锁定', $upArray);
  662. }
  663. }