You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.4 KiB
113 lines
4.4 KiB
<?php
|
|
|
|
/**
|
|
* 鼠笼笼位相关接口
|
|
* @author YS
|
|
* @version 1.0
|
|
*/
|
|
class Api_CageController extends Ctrl_Api{
|
|
public $Cagemodel;
|
|
public $POST;
|
|
public $Cagecolormodel;
|
|
public function init() {
|
|
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');}
|
|
$this->Cagemodel = new CageModel();
|
|
$this->POST =json_decode(file_get_contents('php://input'),true);
|
|
$this->Cagecolormodel = new CagecolorModel();
|
|
}
|
|
/**
|
|
* 鼠笼列表接口
|
|
* @param $strains 品系
|
|
* @param $number 笼位号
|
|
* @param $type 笼位属性
|
|
* @return
|
|
* {
|
|
* "errorcode": "200",
|
|
* "message": "登陆成功",
|
|
* "data": {
|
|
* "username": "用户名",
|
|
* "type": "1",用户类型
|
|
* "realname": "真实姓名",
|
|
* "faculties": "1",院系
|
|
* "specialized": "1",专业
|
|
* "group": "1",课题组
|
|
* "teacher": "1",导师
|
|
* "phone": "13566987478",手机号
|
|
* "status": "1",审核状态
|
|
* "is_delete": "0"是否删除
|
|
* }
|
|
* }
|
|
*/
|
|
public function listAction(){
|
|
$params['order'] = empty($this->POST['order'])?'':$this->POST['order'];
|
|
$params['keyword'] = empty($this->POST['keyword'])?'':$this->POST['keyword'];
|
|
$params['page'] = empty($this->POST['page'])?1:$this->POST['page'];
|
|
$data = $this->Cagemodel->getModelList($params);
|
|
Tool_Fnc::apiMsg('笼位获取成功', '200',$data);
|
|
}
|
|
/**
|
|
* 鼠笼添加接口
|
|
* @param $strains 笼位品系
|
|
* @param $number 笼位号
|
|
* @param $type 笼位类型
|
|
* @param $color 笼位颜色
|
|
* @param $group 实验室
|
|
* @param $user_id 负责人
|
|
* @return
|
|
* {
|
|
* "errorcode": "200",
|
|
* "message": "添加成功",
|
|
* "data": []
|
|
* }
|
|
*/
|
|
public function addAction(){
|
|
//查询笼位号
|
|
$CageNum = $this->Cagemodel->field('count(*) as num')->where("user_id={$_SESSION['uid']}")->fRow();
|
|
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
|
|
$data['type'] = $this->POST['type'];
|
|
$data['number'] = "NO.0000".$CageNum;
|
|
if($CageNum>9) $data['number'] = "NO.000".$CageNum;
|
|
if($CageNum>99) $data['number'] = "NO.00".$CageNum;
|
|
if($CageNum>999) $data['number'] = "NO.0".$CageNum;
|
|
$data['strains'] =empty($this->POST['strains'])||!isset($this->POST['strains'])?Tool_Fnc::apiMsg('请选择笼位品系', '500'):Tool_Fnc::safe_string($this->POST['strains']);
|
|
$data['color'] =empty($this->POST['color'])||!isset($this->POST['color'])?Tool_Fnc::apiMsg('请选择笼位颜色', '500'):Tool_Fnc::safe_string($this->POST['color']);
|
|
$data['group'] = empty($this->POST['group'])||!isset($this->POST['group'])?Tool_Fnc::apiMsg('请选择实验室', '500'):Tool_Fnc::safe_string($this->POST['group']);
|
|
$data['user_id'] =empty($this->POST['user_id'])||!isset($this->POST['user_id'])?Tool_Fnc::apiMsg('请选择负责人', '500'):Tool_Fnc::safe_string($this->POST['user_id']);
|
|
$data['created'] = date('Y-m-d H:i:s',time());
|
|
$data['c_user_id'] = $_SESSION['uid'];
|
|
$ret = $this->Cagemodel->insert($data);
|
|
if(!$ret) Tool_Fnc::apiMsg('笼位建设失败', '500');
|
|
Tool_Fnc::apiMsg('笼位建设成功', '200');
|
|
}
|
|
public function edidAction(){
|
|
|
|
}
|
|
/**
|
|
* 获取笼位号
|
|
*/
|
|
public function getCagenumAction(){
|
|
$CageNum = $this->Cagemodel->field('count(*) as num')->where("user_id={$_SESSION['uid']}")->fRow();
|
|
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
|
|
$data['number'] = "NO.0000".$CageNum;
|
|
if($CageNum>9) $data['number'] = "NO.000".$CageNum;
|
|
if($CageNum>99) $data['number'] = "NO.00".$CageNum;
|
|
if($CageNum>999) $data['number'] = "NO.0".$CageNum;
|
|
Tool_Fnc::apiMsg('获取笼位号成功', '200',$data);
|
|
}
|
|
/**
|
|
* 获取笼位类型接口
|
|
*/
|
|
public function getCagetypeAction(){
|
|
$data = [1=>'库存笼',2=>'繁殖笼'];
|
|
Tool_Fnc::apiMsg('获取笼位类型成功', '200',$data);
|
|
}
|
|
/**
|
|
* 获取笼位颜色接口
|
|
*/
|
|
public function getCagecolorAction(){
|
|
$params['field'] = 'color';
|
|
$data = $this->Cagecolormodel->getModelList($params);
|
|
Tool_Fnc::apiMsg('获取成功', '200',$data);
|
|
}
|
|
}
|
|
|
|
|