YS:增加uid

master
yangsai@163.com 6 months ago
parent 698f5759e4
commit 046b738ac7
  1. 1
      application/controllers/Api/Basicinfo.php
  2. 9
      application/controllers/Api/Cage.php
  3. 3
      application/controllers/Api/Login.php
  4. 15
      application/controllers/Api/Squirrel.php
  5. 3
      application/controllers/Api/Sysset.php
  6. 2
      application/models/Cage.php
  7. 4
      application/models/Squirrel.php

@ -11,7 +11,6 @@ class Api_BasicinfoController extends Ctrl_Api{
public $POST;
public $GroupModel;
public function init(){
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');}
$this->StrainsModel=new StrainsModel();
$this->GeneModel=new GeneModel();
$this->POST =json_decode(file_get_contents('php://input'),true);

@ -10,7 +10,6 @@ class Api_CageController extends Ctrl_Api{
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();
@ -40,6 +39,7 @@ class Api_CageController extends Ctrl_Api{
*/
public function listAction(){
$params['order'] = empty($this->POST['order'])?'':$this->POST['order'];
$params['uid'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$params['keyword'] = empty($this->POST['keyword'])?'':$this->POST['keyword'];
$params['page'] = empty($this->POST['page'])?1:$this->POST['page'];
$data = $this->Cagemodel->getModelList($params);
@ -62,7 +62,8 @@ class Api_CageController extends Ctrl_Api{
*/
public function addAction(){
//查询笼位号
$CageNum = $this->Cagemodel->field('count(*) as num')->where("user_id={$_SESSION['uid']}")->fRow();
$data['c_user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$CageNum = $this->Cagemodel->field('count(*) as num')->where("user_id={$data['c_user_id']}")->fRow();
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
$data['type'] = $this->POST['type'];
$data['number'] = "NO.0000".$CageNum;
@ -74,7 +75,6 @@ class Api_CageController extends Ctrl_Api{
$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');
@ -86,7 +86,8 @@ class Api_CageController extends Ctrl_Api{
* 获取笼位号
*/
public function getCagenumAction(){
$CageNum = $this->Cagemodel->field('count(*) as num')->where("user_id={$_SESSION['uid']}")->fRow();
$uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$CageNum = $this->Cagemodel->field('count(*) as num')->where("user_id={$uid}")->fRow();
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
$data['number'] = "NO.0000".$CageNum;
if($CageNum>9) $data['number'] = "NO.000".$CageNum;

@ -45,9 +45,6 @@
empty($Userinfo)?Tool_Fnc::apiMsg('账号密码错误', '500'):$Userinfo;
$Userinfo['password']!=md5($Password.Yaf_Registry::get("config")->psd->default->appsecret)?Tool_Fnc::apiMsg('账号密码错误', '500'):$Userinfo['password'];
unset($Userinfo['password']);
$_SESSION['uid'] = $Userinfo['id'];
$_SESSION['username'] = $Userinfo['username'];
$_SESSION['type'] = $Userinfo['type'];
unset($Userinfo['id']);
if($Userinfo['status']!=1) Tool_Fnc::apiMsg('等待管理审核', '500');

@ -13,7 +13,6 @@ class Api_SquirrelController extends Ctrl_Api{
public $POST;
public $ExcelSetModel;
public function init() {
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');}
$this->Squirrelmodel = new SquirrelModel();
$this->CageModel = new CageModel();
$this->CageSetModel=new CageSetModel();
@ -84,7 +83,7 @@ class Api_SquirrelController extends Ctrl_Api{
//查询笼位号
$CageNum = $this->Squirrelmodel->field('count(*) as num')->fRow();
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
$data['c_user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$data['type'] = $this->POST['type'];
$data['number'] = "SN00000".$CageNum;
if($CageNum>9) $data['number'] = "SN0000".$CageNum;
@ -101,11 +100,10 @@ class Api_SquirrelController extends Ctrl_Api{
$data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?Tool_Fnc::apiMsg('请填写备注', '500'):Tool_Fnc::safe_string($this->POST['remark']);
$data['cage'] =empty($this->POST['cage'])||!isset($this->POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($this->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');
if(!$this->Squirrelmodel->isFull($data['cage'],$this->POST['uid'])) Tool_Fnc::apiMsg('当前笼位已满,请重新选择笼位添加', '500');
//获取当前用户仓鼠的配置
$params['user_id'] = $_SESSION['uid'];
$params['user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params);
//根据生日获取各个提醒时间
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday'])));
@ -146,6 +144,7 @@ class Api_SquirrelController extends Ctrl_Api{
* }
*/
public function editAction(){
$data['uid'] = empty($this->POST['uid'])||!isset($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):Tool_Fnc::safe_string($this->POST['id']);
$data['id'] = empty($this->POST['id'])||!isset($this->POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($this->POST['id']);
$data['sex'] =empty($this->POST['sex'])||!isset($this->POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):Tool_Fnc::safe_string($this->POST['sex']);
$data['birthday'] =empty($this->POST['birthday'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('请填写生日', '500'):Tool_Fnc::safe_string($this->POST['birthday']);
@ -155,13 +154,9 @@ class Api_SquirrelController extends Ctrl_Api{
$data['gene'] =empty($this->POST['gene'])||!isset($this->POST['gene'])?Tool_Fnc::apiMsg('请填写基因', '500'):Tool_Fnc::safe_string($this->POST['gene']);
$data['hair_color'] =empty($this->POST['hair_color'])||!isset($this->POST['hair_color'])?Tool_Fnc::apiMsg('请选择毛色', '500'):Tool_Fnc::safe_string($this->POST['hair_color']);
$data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?'':Tool_Fnc::safe_string($this->POST['remark']);
// $data['cage'] =empty($this->POST['cage'])||!isset($this->POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($this->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'];
$params['user_id'] = $data['uid'];
$squirrelSet = $this->SquirrelSetModel->getsetinfo($params);
//根据生日获取各个提醒时间
$data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday'])));

@ -11,7 +11,6 @@ class Api_SyssetController extends Ctrl_Api{
public $SquirrelSetModel;
public $ExcelSetModel;
public function init(){
if(empty($_SESSION['uid'])) {Tool_Fnc::apiMsg('非法调用', '500');}
$this->CageSetModel=new CageSetModel();
$this->SquirrelSetModel=new SquirrelSetModel();
$this->POST =json_decode(file_get_contents('php://input'),true);
@ -21,7 +20,7 @@ class Api_SyssetController extends Ctrl_Api{
* 获取设置接口
*/
public function getSetInfoAction(){
$params['user_id'] = $_SESSION['uid'];
$params['user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
//笼位设置
$data['cageSet'] = $this->CageSetModel->getsetinfo($params);
//鼠设置

@ -18,7 +18,7 @@ class CageModel extends Orm_Base{
public function getModelList($params){
//查询当前笼位一行显示几个
$cagemodel = new CageSetModel();
$shownum = $cagemodel->field('line_num')->where("c_user_id='{$_SESSION['id']}'")->fRow();
$shownum = $cagemodel->field('line_num')->where("c_user_id='{$params['uid']}'")->fRow();
$limmit = empty($shownum['line_num'])?20:$shownum['line_num']*5;
$sql = "select cage.id,cage.number,cage.color,strains.title strains,cage.type from cage left join strains on cage.strains=strains.id";
if(!empty($params['keywords'])){

@ -46,8 +46,8 @@ class SquirrelModel extends Orm_Base{
$data['youzailishi'] = $params['type']==2?:[];
return $data;
}
public function isFull($cage){
$params['user_id'] = $_SESSION['uid'];
public function isFull($cage,$uid){
$params['user_id'] = $uid;
$CageSetModel = new CageSetModel();
$time = date('Y-m-d',time());
//获取鼠笼配置

Loading…
Cancel
Save