Node.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Think.Admin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2017 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://think.ctolog.com
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/Think.Admin
  12. // +----------------------------------------------------------------------
  13. namespace app\admin\controller;
  14. use controller\BasicAdmin;
  15. use service\DataService;
  16. use service\NodeService;
  17. use service\ToolsService;
  18. /**
  19. * 系统功能节点管理
  20. * Class Node
  21. * @package app\admin\controller
  22. * @author Anyon <zoujingli@qq.com>
  23. * @date 2017/02/15 18:13
  24. */
  25. class Node extends BasicAdmin
  26. {
  27. /**
  28. * 指定当前默认模型
  29. * @var string
  30. */
  31. public $table = 'SystemNode';
  32. /**
  33. * 显示节点列表
  34. */
  35. public function index()
  36. {
  37. $nodes = ToolsService::arr2table(NodeService::get(), 'node', 'pnode');
  38. $alert = ['type' => 'danger', 'title' => '安全警告', 'content' => '结构为系统自动生成, 状态数据请勿随意修改!'];
  39. return view('', ['title' => '系统节点管理', 'nodes' => $nodes, 'alert' => $alert]);
  40. }
  41. /**
  42. * 保存节点变更
  43. */
  44. public function save()
  45. {
  46. if ($this->request->isPost()) {
  47. $post = $this->request->post();
  48. if (isset($post['list'])) {
  49. $data = [];
  50. foreach ($post['list'] as $vo) {
  51. $data['node'] = $vo['node'];
  52. $data[$vo['name']] = $vo['value'];
  53. }
  54. !empty($data) && DataService::save($this->table, $data, 'node');
  55. $this->success('参数保存成功!', '');
  56. }
  57. } else {
  58. $this->error('访问异常,请重新进入...');
  59. }
  60. }
  61. }