鼠笼管理系统
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.
 
 
 
 

63 lines
2.3 KiB

<?php
/**
* 获取设置接口
* @author YS
* @version 1.0
*/
class Api_SyssetController extends Ctrl_Api{
public $CageSetModel;
public $POST;
public $SquirrelSetModel;
public $ExcelSetModel;
public function init(){
$this->CageSetModel=new CageSetModel();
$this->SquirrelSetModel=new SquirrelSetModel();
$this->POST =json_decode(file_get_contents('php://input'),true);
$this->ExcelSetModel=new ExcelSetModel();
}
/**
* 获取设置接口
*/
public function getSetInfoAction(){
$params['user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
//笼位设置
$data['cageSet'] = $this->CageSetModel->getsetinfo($params);
//鼠设置
$data['squirrelSet'] = $this->SquirrelSetModel->getsetinfo($params);
//excel导出设置
$data['excelSet'] = $this->ExcelSetModel->getsetinfo($params);
Tool_Fnc::apiMsg('获取成功', '200',$data);
}
/**
* 获取设置接口
*/
public function editSetAction(){
$uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$cageSet = $this->POST['cageSet'];
$cageSet['c_user_id']=$uid;
$squirrelSet = $this->POST['squirrelSet'];
$squirrelSet['user_id']=$uid;
$excelSet = $this->POST['excelSet'];
$excelSet['now_squirrel']=json_encode($excelSet['now_squirrel']);
$excelSet['handle_squirrel']=json_encode($excelSet['handle_squirrel']);
$excelSet['user_id']=$uid;
$this->CageSetModel->save($cageSet);
$this->SquirrelSetModel->save($squirrelSet);
$this->ExcelSetModel->save($excelSet);
Tool_Fnc::apiMsg('设置成功', '200');
//写入配置
}
public function getUserinfoAction(){
$uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$UserModel = new UserModel();
$data = $UserModel->field("*")->where("id={$uid}")->fRow();
//获取笼位数量
$Cagemodel = new CageModel();
$CageNum = $Cagemodel->field('count(*) as num')->where("c_user_id={$uid}")->fRow();
$data['cage_num'] = $CageNum['num'];
unset($data['password']);
Tool_Fnc::apiMsg('获取成功', '200',$data);
}
}