34327c62
xu
1. F 完成所有接口的逻辑
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
namespace domain\device;
use Yii;
use domain\device\models\DeviceStats as DeviceStatsModel;
class DeviceStats
{
/**
* @param $item
* @return null
*/
static function create($item)
{
$createModel = Yii::createObject([
'class' => DeviceStatsModel::className(),
'barcode' => $item['barcode'],
'device_id' => $item['device_id'],
'manufacture_id' => $item['manufacture_id'],
'project_id' => $item['project_id'],
'model_id' => $item['model_id'],
'software_version' => $item['software_version'],
'hardware_version' => $item['hardware_version'],
'timestamp' => $item['timestamp'],
'city' => $item['city'],
'ip' => $item['ip']
]);
if ($createModel->save()) {
return $createModel;
} else {
return null;
}
}
|
f0fc6bb3
xu
app-ht
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/**
* @param $id
* @return bool|false|int
* @throws \Exception
* @throws \Throwable
*/
static function delete($id)
{
$deviceStats = DeviceStatsModel::findOne($id);
if (empty($deviceStats)) {
return false;
}
return $deviceStats->delete();
}
/**
* @return bool|int
*/
static function deleteAll($condition)
{
if (empty($condition)) {
return false;
}
return DeviceStatsModel::deleteAll($condition);
}
|