commit | author | age
|
2207d6
|
1 |
<?php |
W |
2 |
|
|
3 |
namespace app\models; |
|
4 |
|
|
5 |
use Yii; |
|
6 |
|
|
7 |
/** |
|
8 |
* This is the model class for table "{{%core_queue_data}}". |
|
9 |
* |
|
10 |
* @property int $id |
|
11 |
* @property int $queue_id 队列返回值 |
|
12 |
* @property string $token |
|
13 |
*/ |
|
14 |
class CoreQueueData extends \app\models\ModelActiveRecord |
|
15 |
{ |
|
16 |
/** |
|
17 |
* {@inheritdoc} |
|
18 |
*/ |
|
19 |
public static function tableName() |
|
20 |
{ |
|
21 |
return '{{%core_queue_data}}'; |
|
22 |
} |
|
23 |
|
|
24 |
/** |
|
25 |
* {@inheritdoc} |
|
26 |
*/ |
|
27 |
public function rules() |
|
28 |
{ |
|
29 |
return [ |
|
30 |
[['queue_id'], 'integer'], |
|
31 |
[['token'], 'required'], |
|
32 |
[['token'], 'string', 'max' => 32], |
|
33 |
]; |
|
34 |
} |
|
35 |
|
|
36 |
/** |
|
37 |
* {@inheritdoc} |
|
38 |
*/ |
|
39 |
public function attributeLabels() |
|
40 |
{ |
|
41 |
return [ |
|
42 |
'id' => 'ID', |
|
43 |
'queue_id' => '队列返回值', |
|
44 |
'token' => 'Token', |
|
45 |
]; |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* @param $queue_id |
|
50 |
* @param $token |
|
51 |
* 将队列id和token存数据表 |
|
52 |
*/ |
|
53 |
public static function add($queue_id, $token) |
|
54 |
{ |
|
55 |
$model = new self(); |
|
56 |
$model->queue_id = $queue_id; |
|
57 |
$model->token = $token; |
|
58 |
$model->save(); |
|
59 |
} |
|
60 |
|
|
61 |
/** |
|
62 |
* @param $token |
|
63 |
* @return int|null |
|
64 |
* 根据token获取队列的id |
|
65 |
*/ |
|
66 |
public static function select($token) |
|
67 |
{ |
|
68 |
/* @var self $model*/ |
|
69 |
$model = self::find()->where(['token' => $token])->orderBy(['id' => SORT_DESC])->one(); |
|
70 |
if (!$model) { |
|
71 |
return null; |
|
72 |
} |
|
73 |
return $model->queue_id; |
|
74 |
} |
|
75 |
} |