yangsai@163.com 6 months ago
parent dcfb4c1926
commit c5ee173037
  1. 11
      application/controllers/Api/Squirrel.php
  2. 17
      application/models/NewSquirrel.php

@ -291,6 +291,7 @@ class Api_SquirrelController extends Ctrl_Api{
Tool_Fnc::apiMsg('获取成功', '200',$data);
}
public function operateAction(){
$type = empty($this->POST['type'])?Tool_Fnc::apiMsg('操作类型缺失', '500'):$this->POST['type'];
$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'];
@ -300,12 +301,18 @@ class Api_SquirrelController extends Ctrl_Api{
$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);
$excemodel = $type==1?$this->Squirrelmodel:$this->NewSquirrelmodel;
$excemodel->operate($data);
Tool_Fnc::apiMsg('操作已更新', '200');
}
public function getoperateAction(){
$type = empty($this->POST['type'])?Tool_Fnc::apiMsg('操作类型缺失', '500'):$this->POST['type'];
$id = empty($this->POST['id'])?Tool_Fnc::apiMsg('小鼠ID缺失', '500'):$this->POST['id'];
$data = $this->Squirrelmodel->field('id,jianwei_time,jianwei_show,kill_time,kill_show,test_time,test_show,del_time,del_show')->where("id={$id}")->fRow();
$excemodel = $type==1?$this->Squirrelmodel:$this->NewSquirrelmodel;
$data = $excemodel->field('id,jianwei_time,jianwei_show,kill_time,kill_show,test_time,test_show,del_time,del_show')->where("id={$id}")->fRow();
foreach($data as $key => &$val){
$val = empty($val)?'':$val;
}
Tool_Fnc::apiMsg('获取成功', '200',$data);
}
}

@ -20,6 +20,14 @@ class NewSquirrelModel extends Orm_Base{
'grow_time' => array('type' => "varchar(255)",'comment' => '成长时间'),
'infertility_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'dose_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'kill_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'del_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'jianwei_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'test_time' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'kill_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'del_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'jianwei_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
'test_show' => array('type' => "varchar(255)",'comment' => '是否为新生小鼠'),
);
public $pk = 'id';
@ -40,5 +48,14 @@ class NewSquirrelModel extends Orm_Base{
$data['icon'] = Yaf_Registry::get("config")->web->url->img."/public/icon/small.png";
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;
}
}

Loading…
Cancel
Save