yangsai@163.com 6 months ago
parent 5789d2b5f9
commit c01a0fc9ef
  1. 12
      application/controllers/Api/Cage.php
  2. 2
      application/models/Cage.php

@ -70,10 +70,7 @@ class Api_CageController extends Ctrl_Api{
$CageNum = $this->Cagemodel->field('count(*) as num')->where("c_user_id={$data['c_user_id']}")->fRow(); $CageNum = $this->Cagemodel->field('count(*) as num')->where("c_user_id={$data['c_user_id']}")->fRow();
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1; $CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
$data['type'] = $this->POST['type']; $data['type'] = $this->POST['type'];
$data['number'] = "NO.0000".$CageNum; $data['number'] = $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['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['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['group'] = empty($this->POST['group'])||!isset($this->POST['group'])?Tool_Fnc::apiMsg('请选择实验室', '500'):Tool_Fnc::safe_string($this->POST['group']);
@ -90,17 +87,14 @@ class Api_CageController extends Ctrl_Api{
$uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; $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 = $this->Cagemodel->field('count(*) as num')->where("user_id={$uid}")->fRow();
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1; $CageNum = empty($CageNum)?1:(int) $CageNum['num']+1;
$data['number'] = "NO.0000".$CageNum; $data['number'] = $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); Tool_Fnc::apiMsg('获取笼位号成功', '200',$data);
} }
/** /**
* 获取笼位类型接口 * 获取笼位类型接口
*/ */
public function getCagetypeAction(){ public function getCagetypeAction(){
$data = array(['id'=>1,'title'=>'库存笼'],['id'=>2,'title'=>'繁殖笼']); $data = array(['id'=>1,'title'=>'库存笼'],['id'=>2,'title'=>'繁殖笼'],['id'=>3,'title'=>'其他']);
Tool_Fnc::apiMsg('获取笼位类型成功', '200',$data); Tool_Fnc::apiMsg('获取笼位类型成功', '200',$data);
} }
/** /**

@ -22,7 +22,7 @@ class CageModel extends Orm_Base{
$limmit = empty($shownum['line_num'])?20:$shownum['line_num']*4; $limmit = empty($shownum['line_num'])?20:$shownum['line_num']*4;
$sql = "select id,number,color,strains,type from cage where c_user_id={$params['uid']}"; $sql = "select id,number,color,strains,type from cage where c_user_id={$params['uid']}";
if(!empty($params['keyword'])){ if(!empty($params['keyword'])){
$sql .=" and number like '%{$params['keyword']}%'"; $sql .=" and (number like '%{$params['keyword']}%' or strains_id like '%{$params['keyword']}%')";
} }
if(!empty($params['order'])){ if(!empty($params['order'])){
$sql .=" order by {$params['order']} desc"; $sql .=" order by {$params['order']} desc";

Loading…
Cancel
Save