| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace common\services;
- use Yii;
- use common\components\dict;
- use common\models\xhLuckyDrawAward;
- class xhLuckyDrawAwardService {
- public static function add($data)
- {
- $data = xhLuckyDrawAward::add($data, true);
- //存入缓存
- baseService::setCacheByData($data, 'xhLuckyDrawAward', '', Yii::$app->params['oneDayExpireTime']);
- return $data;
- }
- /**
- * 通过ID获取数据
- * @param $id
- * @return bool
- */
- public static function getById($id)
- {
- $preKey = dict::getCacheKey('xhLuckyDrawAward');
- $cacheKey = $preKey.$id;
- $cacheData = baseService::getCache($cacheKey);
- if(empty($cacheData)){
- $data = baseService::setCacheById($id, 'xhLuckyDrawAward', $cacheKey, Yii::$app->params['oneDayExpireTime']);
- if($data === false){
- return false;
- }
- return $data;
- }
- return $cacheData;
- }
- public static function updateById($id, $data)
- {
- $data['id'] = $id;
- $re = xhLuckyDrawAward::updateById($id, $data);
- $reData = $re['data'];
- baseService::setCacheByData($reData, 'xhLuckyDrawAward');
- return $re;
- }
- }
|