| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 | 
							- <?php
 
- /**
 
-  * HomepageModel.php UTF-8
 
-  * 玩家主页模型
 
-  *
 
-  * @date    : 2018/8/15 21:43
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : luowei <lw@huosdk.com>
 
-  * @version : HuoMP 1.0
 
-  */
 
- namespace huomp\model\homepage;
 
- use huolib\constant\CacheConst;
 
- use huomp\model\common\CommonModel;
 
- use think\Cache;
 
- class HomepageModel extends CommonModel {
 
-     protected $table = 'mp_homepage';
 
-     // 开启自动写入时间戳字段
 
-     protected $autoWriteTimestamp = true;
 
-     protected $cache_key_prefix   = CacheConst::CACHE_GAME_MP_PREFIX;
 
-     /**
 
-      * 添加数据
 
-      *
 
-      * @param $data
 
-      *
 
-      * @return bool
 
-      */
 
-     public function addData($data) {
 
-         if (empty($data)) {
 
-             return false;
 
-         }
 
-         $_data = $data;
 
-         $_obj = self::create($_data, true);
 
-         if ($_obj) {
 
-             return true;
 
-         }
 
-         return false;
 
-     }
 
-     /**
 
-      * 更新数据
 
-      *
 
-      * @param array $data   数据
 
-      * @param int   $mem_id 玩家ID
 
-      *
 
-      * @return bool
 
-      */
 
-     public function updateData($data, $mem_id) {
 
-         $_map['mem_id'] = $mem_id;
 
-         $_data = $data;
 
-         $_rs = self::update($_data, $_map, true);
 
-         if (false == $_rs) {
 
-             return false;
 
-         }
 
-         $_cache_key = $this->cache_key_prefix.$_data['mem_id'];
 
-         Cache::rm($_cache_key);
 
-         return true;
 
-     }
 
-     /**
 
-      * 获取Banner图
 
-      *
 
-      * @param $mem_id
 
-      *
 
-      * @return array|bool|false
 
-      */
 
-     public function getInfoByMemId($mem_id) {
 
-         $_cache_key = $this->cache_key_prefix.$mem_id;
 
-         $_data = Cache::get($_cache_key);
 
-         if (!empty($_data)) {
 
-             return $_data;
 
-         }
 
-         $_map['mem_id'] = $mem_id;
 
-         $_info = $this->where($_map)->find();
 
-         if (false === $_info) {
 
-             return false;
 
-         }
 
-         if (is_object($_info)) {
 
-             $_info = $_info->toArray();
 
-         }
 
-         Cache::set($_cache_key, $_info);
 
-         return $_info;
 
-     }
 
- }
 
 
  |