From 3dfb75055a0a6030dfe5863af87e90aad78e64ca Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Fri, 17 May 2024 16:41:02 +0800 Subject: [PATCH] YS --- application/controllers/Api/Squirrel.php | 11 ++++++++--- application/models/Squirrel.php | 13 +++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/application/controllers/Api/Squirrel.php b/application/controllers/Api/Squirrel.php index fc47190..5facbea 100644 --- a/application/controllers/Api/Squirrel.php +++ b/application/controllers/Api/Squirrel.php @@ -260,12 +260,17 @@ class Api_SquirrelController extends Ctrl_Api{ Tool_Fnc::apiMsg('获取成功', '200',$data); } public function operateAction(){ - $data['jianwei_time'] = $this->POST['jianwei_time']; + $data['id'] = empty($this->POST['id'])?Tool_Fnc::apiMsg('小鼠ID缺失', '500'):$this->POST['id']; $data['test_time'] = $this->POST['test_time']; + $data['jianwei_time'] = $this->POST['jianwei_time']; $data['kill_time'] = $this->POST['kill_time']; $data['del_time'] = $this->POST['del_time']; - - + $data['jianwei_show'] = $this->POST['jianwei_show']; + $data['test_show'] = $this->POST['test_show']; + $data['del_show'] = $this->POST['del_show']; + $data['kill_show'] = $this->POST['kill_show']; + $this->Squirrelmodel->operate($data); + Tool_Fnc::apiMsg('操作已更新', '200'); } } diff --git a/application/models/Squirrel.php b/application/models/Squirrel.php index 54e8c94..a4901e2 100644 --- a/application/models/Squirrel.php +++ b/application/models/Squirrel.php @@ -27,6 +27,10 @@ class SquirrelModel extends Orm_Base{ 'test_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), 'kill_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), 'del_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), + 'jianwei_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), + 'test_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), + 'kill_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), + 'del_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'), ); public $pk = 'id'; public function getModelList($params){ @@ -87,5 +91,14 @@ class SquirrelModel extends Orm_Base{ } return $data; } + public function operate($params){ + foreach($params as $key => $val){ + if(empty($val)){ + unset($params[$key]); + } + } + if(!$this->update($params)) return false; + return true; + } }