| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * Created by PhpStorm.
- * User: congli
- * Date: 2020/2/28
- * Time: 1:42 PM
- */
- namespace common\helpers\snowflake;
- use yii\base\BaseObject;
- use yii\base\StaticInstanceTrait;
- class PageSnowFake extends BaseObject
- {
- use StaticInstanceTrait;
- public $snowFlakeService;
- public function init()
- {
- parent::init();
- $this->snowFlakeService = new \Godruoyi\Snowflake\Snowflake($expiresIn = \Yii::$app->params['pageSnowFake']['dataCenterId'], $expiresIn = \Yii::$app->params['pageSnowFake']['workerId']);
- }
- /**
- * 获取service
- * @return mixed
- */
- public function getService() {
- return $this->snowFlakeService;
- }
- /**
- * @return mixed
- */
- public function generateId() {
- return $this->snowFlakeService->id();
- }
- }
|