新版数智员工
This commit is contained in:
49
application/store/model/DeviceModel.php
Normal file
49
application/store/model/DeviceModel.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace app\store\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* 设备模型
|
||||
* Class DeviceModel
|
||||
* @package app\store\model
|
||||
*/
|
||||
class DeviceModel extends Model
|
||||
{
|
||||
// 设置表名
|
||||
protected $name = 'device';
|
||||
|
||||
// 设置主键
|
||||
protected $pk = 'id';
|
||||
|
||||
// 自动时间戳
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
/**
|
||||
* 根据设备IMEI获取设备信息
|
||||
* @param string $deviceImei 设备IMEI
|
||||
* @return array|null
|
||||
*/
|
||||
public static function getByDeviceImei($deviceImei)
|
||||
{
|
||||
return self::where('deviceImei', $deviceImei)
|
||||
->where('deleteTime', 0)
|
||||
->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查设备是否在线
|
||||
* @param int $deviceId 设备ID
|
||||
* @return bool
|
||||
*/
|
||||
public static function isOnline($deviceId)
|
||||
{
|
||||
$device = self::where('id', $deviceId)
|
||||
->where('deleteTime', 0)
|
||||
->find();
|
||||
|
||||
return $device && $device['alive'] == 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user