System.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\common\AdminController;
  4. /**
  5. * Description of System
  6. *
  7. * @author sgq
  8. */
  9. class System extends AdminController {
  10. /**
  11. * 生成缓存
  12. * @return type
  13. */
  14. public function cache() {
  15. $step = $this->request->param("step");
  16. if ($step) {
  17. $cache_kvs = [
  18. ["func" => "\app\common\model\Company::cache", "stepName" => "部门"],
  19. ["func" => "\app\common\model\IntegralProject::cache", "stepName" => "积分项目"],
  20. ["func" => "\app\common\model\IntegralItem::cache", "stepName" => "积分标准"]
  21. ];
  22. $cache = $cache_kvs[$step - 1];
  23. if ($cache) {
  24. $time1 = microtime(true);
  25. $cache["func"]();
  26. $time2 = microtime(true);
  27. $runtime = round($time2 - $time1, 2);
  28. $step++;
  29. echo '<script>window.parent.setText("<span class=\"highlight\">' . $cache["stepName"] . '</span>缓存成功![用时 ' . $runtime . 's]");</script>';
  30. echo '<script>window.location.href="/admin/system/cache/step/' . $step . '";</script>';
  31. } else {
  32. echo '<script>window.parent.setText("缓存创建结束!");</script>';
  33. }
  34. } else {
  35. return view();
  36. }
  37. }
  38. }