YS:取消跨域

master
yangsai@163.com 6 months ago
parent bbfc767843
commit 8a8ddbdf3b
  1. 80
      application/controllers/Api/Squirrel.php
  2. 6
      index.php

@ -115,8 +115,84 @@ class Api_SquirrelController extends Ctrl_Api{
if(!$ret) Tool_Fnc::apiMsg('小鼠建档失败', '500');
Tool_Fnc::apiMsg('小鼠建档成功', '200');
}
public function edidAction(){
/**
* 小鼠编辑接口
* @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 editAction(){
$data['id'] = empty($_POST['id'])||!isset($_POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($_POST['id']);
$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::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'];
// //判断鼠笼鼠的数量是否可以容纳
// if(!$this->Squirrelmodel->isFull($data['cage'])) Tool_Fnc::apiMsg('当前笼位已满,请重新选择笼位添加', '500');
//获取当前用户仓鼠的配置
$params['user_id'] = $_SESSION['uid'];
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params);
//根据生日获取各个提醒时间
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday'])));
$data['nursing_time'] = date("Y-m-d",strtotime("+{$squirrelSet['nursing_time']} day",strtotime($data['birthday'])));
$data['grow_time'] =$data['sex']==1? date("Y-m-d",strtotime("+{$squirrelSet['male_grow_time']} days",strtotime($data['birthday']))):date("Y-m-d",strtotime("+{$squirrelSet['female_grow_time']} days",strtotime($data['birthday'])));
$data['infertility_time'] = date("Y-m-d",strtotime("+{$squirrelSet['infertility_time']} month",strtotime($data['birthday'])));
$data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday'])));
$ret = $this->Squirrelmodel->update($data);
if(!$ret) Tool_Fnc::apiMsg('信息更新失败', '500');
Tool_Fnc::apiMsg('信息更新成功', '200');
}
/**
* 获取小鼠详情接口
* @param $id 小鼠id
* @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 getInfoAction(){
$id = $_POST['id'];
}
}

@ -1,8 +1,12 @@
<?php
if(empty($_SESSION)){session_start();}
header("Content-type: text/html; charset=utf-8");
header("Access-Control-Allow-Origin:*");
# 全局
define("APPLICATION_PATH", realpath((phpversion() >= "5.3"? __DIR__: dirname(__FILE__)).'/../'));
#windows
define("APPLICATION_PATH", realpath((phpversion() >= "5.3"? __DIR__: dirname(__FILE__)).'/'));
#linux
// define("APPLICATION_PATH", realpath((phpversion() >= "5.3"? __DIR__: dirname(__FILE__)).'/../../'));
date_default_timezone_set("Asia/Shanghai");
# 域名前缀(cdn)
function host(){return '';}

Loading…
Cancel
Save