Crud.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. +-----------------------------------------------------------------------------------------------
  4. * GouGuOPEN [ 左手研发,右手开源,未来可期!]
  5. +-----------------------------------------------------------------------------------------------
  6. * @Copyright (c) 2021~2024 http://www.gouguoa.com All rights reserved.
  7. +-----------------------------------------------------------------------------------------------
  8. * @Licensed 勾股OA,开源且可免费使用,但并不是自由软件,未经授权许可不能去除勾股OA的相关版权信息
  9. +-----------------------------------------------------------------------------------------------
  10. * @Author 勾股工作室 <hdm58@qq.com>
  11. +-----------------------------------------------------------------------------------------------
  12. */
  13. declare (strict_types = 1);
  14. namespace app\crud\controller;
  15. use app\api\BaseController;
  16. use think\facade\Console;
  17. use think\exception\ValidateException;
  18. use think\facade\Db;
  19. use think\facade\View;
  20. class Crud extends BaseController
  21. {
  22. public function index()
  23. {
  24. return view();
  25. }
  26. //一键crud
  27. public function crud()
  28. {
  29. $uid = $this->uid;
  30. if($uid!=1){
  31. return to_assign(1,'只有系统超级管理员才有权限使用一键crud功能!');
  32. }
  33. $param = get_params();
  34. $a = '-a'.$param['name'];
  35. $m = '-m'.$param['module'];
  36. $t = '-t'.$param['table'];
  37. $c = '-c'.$param['controller'];
  38. $y = '-y'.$param['types'];
  39. try {
  40. $output = Console::call('crud', [$a,$m,$t,$c,$y]);
  41. //return $output->fetch();
  42. } catch(\Exception $e) {
  43. return to_assign(1, $e->getMessage());
  44. }
  45. }
  46. }