物联网后台管理
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.
 
 
 
 
 

67 lines
1.6 KiB

<?php
namespace app\index\controller;
use think\Db;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\exception\DbException;
use think\Request;
use think\response\Json;
class Device extends Base
{
public function _initialize()
{
// parent::_initialize(); // TODO: Change the autogenerated stub
if (!session('root')) {
$this->error('亲,您还没有登录呢!', '/');
}
}
public function index()
{
return $this->fetch();
}
/**
* 获取产品列表
* @return Json
* @throws DataNotFoundException
* @throws DbException
* @throws Exception
* @throws ModelNotFoundException
*/
public function deviceList()
{
$request = Request::instance();
$receive = $request->get();
$page = input("get.page") ? input("get.page") : 1;
$page = intval($page);
$limit = input("get.limit") ? input("get.limit") : 1;
$limit = intval($limit);
$start = $limit * ($page - 1);
$where = [];
if (isset($receive['message']) && !empty($receive['message'])) {
$where['deviceId'] = $receive['message'];
}
$result = Db::table("bs_product_device")->where($where)->order('id desc')->limit($start, $limit)->select();
$num = Db::table("bs_product_device")->where($where)->count();
foreach ($result as &$item) {
}
$list["msg"] = "";
$list["code"] = 0;
$list["count"] = $num;
$list["data"] = $result;
return json($list);
}
}