Clear.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\admin\v1\system\log;
  12. use app\controller\admin\AuthController;
  13. use app\services\system\log\ClearServices;
  14. use think\exception\ValidateException;
  15. use think\facade\App;
  16. use function env;
  17. /**
  18. * 清除数据控制器
  19. * Class Clear
  20. * @package app\controller\admin\v1\system
  21. */
  22. class Clear extends AuthController
  23. {
  24. /**
  25. * Clear constructor.
  26. * @param App $app
  27. * @param ClearServices $services
  28. */
  29. public function __construct(App $app, ClearServices $services)
  30. {
  31. parent::__construct($app);
  32. $this->services = $services;
  33. //生产模式下不允许清除数据
  34. if (!env('APP_DEBUG', false)) {
  35. throw new ValidateException('生产模式下,禁止操作');
  36. }
  37. }
  38. /**
  39. * 刷新数据缓存
  40. */
  41. public function refresh_cache()
  42. {
  43. $this->services->refresCache();
  44. return $this->success('数据缓存刷新成功!');
  45. }
  46. /**
  47. * 删除日志
  48. */
  49. public function delete_log()
  50. {
  51. $this->services->deleteLog();
  52. return $this->success('数据缓存刷新成功!');
  53. }
  54. }