12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace catchAdmin\alarm\controller;
- use catcher\base\CatchRequest as Request;
- use catcher\CatchResponse;
- use catcher\base\CatchController;
- use catchAdmin\alarm\model\ControlManage as controlManageModel;
- class ControlManage extends CatchController
- {
- protected $controlManageModel;
-
- public function __construct(ControlManageModel $controlManageModel)
- {
- $this->controlManageModel = $controlManageModel;
- }
-
- /**
- * 列表
- * @time 2022年10月26日 10:23
- * @param Request $request
- */
- public function index(Request $request) : \think\Response
- {
- return CatchResponse::paginate($this->controlManageModel->getList());
- }
-
- /**
- * 保存信息
- * @time 2022年10月26日 10:23
- * @param Request $request
- */
- public function save(Request $request) : \think\Response
- {
- $params=$request->post();
- $params['start_time']=strtotime($params['timeRange'][0]);
- $params['end_time']=strtotime($params['timeRange'][1]);
- $params['state']=1;
- if($params['type']=='2'){
- $params['control_obj']=$params['stations'];
- }
- // var_dump($params);
- return CatchResponse::success($this->controlManageModel->storeBy($params));
- }
-
- /**
- * 读取
- * @time 2022年10月26日 10:23
- * @param $id
- */
- public function read($id) : \think\Response
- {
- return CatchResponse::success($this->controlManageModel->findBy($id));
- }
-
- /**
- * 更新
- * @time 2022年10月26日 10:23
- * @param Request $request
- * @param $id
- */
- public function update(Request $request, $id) : \think\Response
- {
- $params=$request->post();
- $params['start_time']=strtotime($params['timeRange'][0]);
- $params['end_time']=strtotime($params['timeRange'][1]);
- $params['state']=1;
- if($params['type']=='2'){
- $params['control_obj']=$params['stations'];
- }
- return CatchResponse::success($this->controlManageModel->updateBy($id, $params));
- }
-
- /**
- * 删除
- * @time 2022年10月26日 10:23
- * @param $id
- */
- public function delete($id) : \think\Response
- {
- return CatchResponse::success($this->controlManageModel->deleteBy($id,true));
- }
- }
|