12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace catchAdmin\wind\controller;
- use catcher\base\CatchRequest as Request;
- use catcher\CatchResponse;
- use catcher\base\CatchController;
- use catchAdmin\wind\model\Fan as fanModel;
- use think\facade\Db;
- class Fan extends CatchController
- {
- protected $fanModel;
-
- public function __construct(FanModel $fanModel)
- {
-
- $this->fanModel = $fanModel;
- }
-
- /**
- * 列表
- * @time 2022年04月28日 19:53
- * @param Request $request
- */
- public function index(Request $request) : \think\Response
- {
- return CatchResponse::paginate($this->fanModel->getList());
- }
-
- /**
- * 保存信息
- * @time 2022年04月28日 19:53
- * @param Request $request
- */
- public function save(Request $request) : \think\Response
- {
- $data = $request->post();
-
- if($data['production_date']){
- $data['production_date'] = date('Y-m-d',$data['production_date']);
- }
- if($data['install_date']){
- $data['install_date'] = date('Y-m-d',$data['install_date']);
- }
- return CatchResponse::success($this->fanModel->storeBy($data));
- }
-
- /**
- * 读取
- * @time 2022年04月28日 19:53
- * @param $id
- */
- public function read($id) : \think\Response
- {
- return CatchResponse::success($this->fanModel->findBy($id));
- }
-
- /**
- * 更新
- * @time 2022年04月28日 19:53
- * @param Request $request
- * @param $id
- */
- public function update(Request $request, $id) : \think\Response
- { $data = $request->post();
-
- if(!strstr($data['production_date'],'-'))
- {
- $data['production_date'] = date('Y-m-d',$data['production_date']);
- }
- if(!strstr($data['install_date'],'-'))
- {
- $data['install_date'] = date('Y-m-d',$data['install_date']);
- }
- return CatchResponse::success($this->fanModel->updateBy($id, $data));
- }
-
- /**
- * 删除
- * @time 2022年04月28日 19:53
- * @param $id
- */
- public function delete($id) : \think\Response
- {
- return CatchResponse::success($this->fanModel->deleteBy($id));
- }
- //获取机位号
- // public function getNumber()
- // {
- // }
- }
|