123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\admin\controller\system;
-
- use app\common\basics\AdminBase;
- use app\admin\logic\system\CrontabLogic;
- use app\common\model\system\DevCrontab;
- use app\common\server\JsonServer;
- use app\common\server\system\CrontabServer;
- use think\exception\ValidateException;
- use app\admin\validate\system\CrontabValidate;
- use Cron\CronExpression;
-
-
- class Crontab extends AdminBase
- {
- public function lists()
- {
- if ($this->request->isAjax()) {
- $data = CrontabLogic::lists();
- return JsonServer::success('', $data);
- }
- return view();
- }
-
- public function add()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['status'] = isset($post['status']) && $post['status'] == 'on' ? 1 : 2;
- try{
- validate(CrontabValidate::class)->scene('add')->check($post);
- }catch(ValidateException $e) {
- return JsonServer::error($e->getError());
- }
- $result = CrontabLogic::add($post);
- if($result === true) {
- return JsonServer::success('添加成功');
- }
- return JsonServer::error(CrontabLogic::getError());
- }
- return view();
- }
-
-
-
- public function expression()
- {
- $get = $this->request->get();
- return JsonServer::success('', CrontabLogic::expression($get));
- }
-
-
-
- public function edit()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['status'] = isset($post['status']) && $post['status'] == 'on' ? 1 : 2;
- try{
- validate(CrontabValidate::class)->check($post);
- }catch(ValidateException $e) {
- return JsonServer::error($e->getError());
- }
- $result = CrontabLogic::edit($post);
- if($result === true) {
- return JsonServer::success('编辑成功');
- }
- return JsonServer::error(CrontabLogic::getError());
- }
-
- $id = $this->request->get('id');
- return view('', [
- 'info' => CrontabLogic::info($id)
- ]);
- }
-
- public function del()
- {
- if ($this->request->isAjax()) {
- $id = $this->request->post('id');
- $result = CrontabLogic::del($id);
- if($result === true) {
- return JsonServer::success('删除成功');
- }
- return JsonServer::error(CrontabLogic::getError());
- }
- }
- }
|