DiyRoute.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\adminapi\controller\diy;
  12. use app\service\admin\diy\DiyRouteService;
  13. use core\base\BaseAdminController;
  14. use think\Response;
  15. /**
  16. * 自定义路由表控制器
  17. * Class DiyRouteController
  18. * @package app\adminapi\controller\diy
  19. */
  20. class DiyRoute extends BaseAdminController
  21. {
  22. /**
  23. * @notes 获取自定义路由表列表
  24. * @return Response
  25. */
  26. public function lists()
  27. {
  28. $data = $this->request->params([
  29. [ 'title', '' ], // 页面名称
  30. [ 'url', '' ], // 路由地址,格式:/app/pages/index/index
  31. [ 'addon_name', '' ] // 插件标识
  32. ]);
  33. return success(( new DiyRouteService() )->getList($data));
  34. }
  35. /**
  36. * 自定义路由表详情
  37. * @param int $id
  38. * @return Response
  39. */
  40. public function info(int $id)
  41. {
  42. return success(( new DiyRouteService() )->getInfo($id));
  43. }
  44. /**
  45. * 自定义路由表详情
  46. * @param string $name
  47. * @return Response
  48. */
  49. public function getInfoByName(string $name)
  50. {
  51. return success(( new DiyRouteService() )->getInfoByName($name));
  52. }
  53. /**
  54. * 添加自定义路由表
  55. * @return Response
  56. */
  57. public function add()
  58. {
  59. $data = $this->request->params([
  60. [ "title", "" ],
  61. [ "name", "" ],
  62. [ "page", "" ],
  63. [ "share", "" ],
  64. [ "is_share", "" ]
  65. ]);
  66. $this->validate($data, 'app\validate\diy\DiyRoute.add');
  67. $id = ( new DiyRouteService() )->add($data);
  68. return success('ADD_SUCCESS', [ 'id' => $id ]);
  69. }
  70. /**
  71. * 自定义路由表编辑
  72. * @param $id
  73. * @return Response
  74. */
  75. public function edit($id)
  76. {
  77. $data = $this->request->params([
  78. [ "title", "" ],
  79. [ "name", "" ],
  80. [ "page", "" ],
  81. [ "share", "" ],
  82. [ "is_share", "" ]
  83. ]);
  84. $this->validate($data, 'app\validate\diy\DiyRoute.edit');
  85. ( new DiyRouteService() )->edit($id, $data);
  86. return success('MODIFY_SUCCESS');
  87. }
  88. /**
  89. * 自定义路由表删除
  90. * @param int $id
  91. * @return Response
  92. */
  93. public function del(int $id)
  94. {
  95. ( new DiyRouteService() )->del($id);
  96. return success('DELETE_SUCCESS');
  97. }
  98. /**
  99. * 修改页面分享内容
  100. */
  101. public function modifyShare()
  102. {
  103. $data = $this->request->params([
  104. [ 'share', '' ],
  105. [ 'title', '' ],
  106. [ 'name', '' ],
  107. [ 'page', '' ],
  108. [ 'is_share', 0 ],
  109. [ 'sort', 0 ]
  110. ]);
  111. ( new DiyRouteService() )->modifyShare($data);
  112. return success('MODIFY_SUCCESS');
  113. }
  114. /**
  115. * 获取模板页面(存在的应用插件列表)
  116. * @return Response
  117. */
  118. public function getApps()
  119. {
  120. return success(( new DiyRouteService() )->getApps());
  121. }
  122. }