1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace catchAdmin\alarm\controller;
- use catcher\base\CatchRequest as Request;
- use catcher\CatchResponse;
- use catcher\base\CatchController;
- use catchAdmin\alarm\model\RfidWithBw as rfidWithBwModel;
- class RfidWithBw extends CatchController
- {
- protected $rfidWithBwModel;
-
- public function __construct(RfidWithBwModel $rfidWithBwModel)
- {
- $this->rfidWithBwModel = $rfidWithBwModel;
- }
-
- /**
- * 列表
- * @time 2022年10月26日 13:53
- * @param Request $request
- */
- public function index(Request $request) : \think\Response
- {
- return CatchResponse::paginate($this->rfidWithBwModel->getList());
- }
-
- /**
- * 保存信息
- * @time 2022年10月26日 13:53
- * @param Request $request
- */
- public function save(Request $request) : \think\Response
- {
- //$this->rfidWithBwModel->storeBy($request->post())
- $data=$request->post();
- $creator_id=$data['creator_id'];
- $arr=[];
- foreach($data as $key=>$val){
- if($key==='creator_id'){
- continue;
- }
- $val['creator_id']=$creator_id;
- $val['created_at']=time();
-
- array_push($arr,$val);
- }
- // var_dump($arr);
- array_unique($data, SORT_REGULAR);
- $success = $this->rfidWithBwModel->insertAll($arr);
- return CatchResponse::success($success);
- }
-
- /**
- * 读取
- * @time 2022年10月26日 13:53
- * @param $id
- */
- public function read($id) : \think\Response
- {
- return CatchResponse::success($this->rfidWithBwModel->findBy($id));
- }
-
- /**
- * 更新
- * @time 2022年10月26日 13:53
- * @param Request $request
- * @param $id
- */
- public function update(Request $request, $id) : \think\Response
- {
- return CatchResponse::success($this->rfidWithBwModel->updateBy($id, $request->post()));
- }
-
- /**
- * 删除
- * @time 2022年10月26日 13:53
- * @param $id
- */
- public function delete($id) : \think\Response
- {
- return CatchResponse::success($this->rfidWithBwModel->deleteBy($id));
- }
- }
|