getPk()." desc"); $page_size=input("page_size",10);//分页大小 $list=self::where($where)->order($orderby)->paginate($page_size); return returnFormat(0,'查询成功',$list); } public function add() { $param = input('param.'); $param['update_time'] = $param['create_time'] = getNow(); $res=self::insert($param); if($res===false){ return returnFormat(9999,'服务器错误,新增失败'); } return returnFormat(0,'添加成功'); } public function detail(){ $id=input("id"); if(!$id){ return returnFormat(9999,'缺少参数'); } $where['id']=$id; $model=self::where($where)->find(); if(!$model){ return returnFormat(9999,'未找到记录'); } return returnFormat(0,'',$model->toArray()); } public function del(){ $id=input("id"); $where["id"]=$id; $res=self::where($where)->delete(); if($res===false){ return returnFormat(9999,'服务器错误'); } return returnFormat(0,'删除成功'); } public function edit(){ $id=input("id"); if(!$id){ return returnFormat(9999,'缺少参数'); } $where["id"]=$id; $model=self::where($where)->find(); if(!$model){ return returnFormat(9999,'未找到记录'); } $param=input("param."); $param["id"]=$id; $res=self::update($param); if($res===false){ return returnFormat(9999,'服务器错误'); } return returnFormat(0,'修改成功'); } }