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.
97 lines
3.9 KiB
97 lines
3.9 KiB
7 months ago
|
<?php
|
||
|
|
||
|
/**
|
||
|
* 鼠笼笼位相关接口
|
||
|
* @author YS
|
||
|
* @version 1.0
|
||
|
*/
|
||
|
class Api_SquirrelController extends Ctrl_Api{
|
||
|
public $Squirrelmodel;
|
||
|
public function init() {
|
||
|
$this->Squirrelmodel = new SquirrelModel();
|
||
|
}
|
||
|
/**
|
||
|
* 鼠笼列表接口
|
||
|
* @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(){
|
||
|
|
||
|
}
|
||
|
/**
|
||
|
* 小鼠添加接口
|
||
|
* @param $sex 性别
|
||
|
* @param $birthday 生日
|
||
|
* @param $father 父亲id
|
||
|
* @param $mather 母亲id
|
||
|
* @param $strains_id 品系id
|
||
|
* @param $gene 基因id
|
||
|
* @param $hair_color 毛色
|
||
|
* @param $remark 备注
|
||
|
* @param $cage 笼位号
|
||
|
* @return
|
||
|
* {
|
||
|
* "errorcode": "200",
|
||
|
* "message": "添加成功",
|
||
|
* "data": {
|
||
|
* "sex": "用户名",性别
|
||
|
* "birthday": "1",生日
|
||
|
* "father": "1",母亲id
|
||
|
* "mather": "2",母亲id
|
||
|
* "strains_id": "1",品系id
|
||
|
* "gene": "1",基因id
|
||
|
* "hair_color": "1",毛色
|
||
|
* "remark": "备注",备注
|
||
|
* "cage": "1",笼位号id
|
||
|
* }
|
||
|
* }
|
||
|
*/
|
||
|
public function addAction(){
|
||
|
//查询笼位号
|
||
|
$CageNum = $this->Squirrelmodel->field('count(*) as num')->fRow();
|
||
|
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
|
||
|
$data['type'] = $_POST['type'];
|
||
|
$data['number'] = "SN00000".$CageNum;
|
||
|
if($CageNum>9) $data['number'] = "SN0000".$CageNum;
|
||
|
if($CageNum>99) $data['number'] = "SN000".$CageNum;
|
||
|
if($CageNum>999) $data['number'] = "SN00".$CageNum;
|
||
|
if($CageNum>9999) $data['number'] = "SN0".$CageNum;
|
||
|
$data['sex'] =empty($_POST['sex'])||!isset($_POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):Tool_Fnc::safe_string($_POST['sex']);
|
||
|
$data['birthday'] =empty($_POST['birthday'])||!isset($_POST['birthday'])?Tool_Fnc::apiMsg('请填写生日', '500'):Tool_Fnc::safe_string($_POST['birthday']);
|
||
|
$data['father'] = empty($_POST['father'])||!isset($_POST['father'])?0:Tool_Fnc::safe_string($_POST['father']);
|
||
|
$data['mother'] = empty($_POST['mother'])||!isset($_POST['father'])?0:Tool_Fnc::safe_string($_POST['mother']);
|
||
|
$data['strains_id'] =empty($_POST['strains_id'])||!isset($_POST['strains_id'])?Tool_Fnc::apiMsg('请选择品系', '500'):Tool_Fnc::safe_string($_POST['strains_id']);
|
||
|
$data['gene'] =empty($_POST['gene'])||!isset($_POST['gene'])?Tool_Fnc::apiMsg('请填写基因', '500'):Tool_Fnc::safe_string($_POST['gene']);
|
||
|
$data['hair_color'] =empty($_POST['hair_color'])||!isset($_POST['hair_color'])?Tool_Fnc::apiMsg('请选择毛色', '500'):Tool_Fnc::safe_string($_POST['hair_color']);
|
||
|
$data['remark'] = empty($_POST['remark'])||!isset($_POST['remark'])?Tool_Fnc::apiMsg('请填写备注', '500'):Tool_Fnc::safe_string($_POST['remark']);
|
||
|
$data['cage'] =empty($_POST['cage'])||!isset($_POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($_POST['cage']);
|
||
|
$data['created'] = date('Y-m-d H:i:s',time());
|
||
|
$data['c_user_id'] = $_SESSION['uid'];
|
||
|
$ret = $this->Squirrelmodel->insert($data);
|
||
|
if(!$ret) Tool_Fnc::apiMsg('小鼠建档失败', '500');
|
||
|
Tool_Fnc::apiMsg('小鼠建档成功', '200');
|
||
|
}
|
||
|
public function edidAction(){
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|