| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 | 
							- <?php
 
- namespace app\common\model;
 
- use think\Model;
 
- /**
 
-  * 模型
 
-  */
 
- class UserLike extends Model
 
- {
 
-     // 开启自动写入时间戳字段
 
-     protected $autoWriteTimestamp = 'int';
 
-     // 定义时间戳字段名
 
-     protected $createTime = 'createtime';
 
-     /**
 
-      * 获取喜欢列表
 
-      */
 
-     public function getUserList($user_id,$pageStart=1,$pageNum=10) {
 
-         $where = [];
 
-         $where["a.fans_id"] = $user_id;
 
-         $list = $this->alias("a")
 
-             ->field("a.id,a.user_id,a.fans_id,u.nickname,u.avatar,u.age,u.constellation,u.wechat,hobby_ids,profession,u.copy_mobile,u.mobile")
 
-             ->join("hx_user u","u.id = a.user_id","left")
 
-             ->where($where)
 
-             ->limit($pageStart,$pageNum)
 
-             ->select();
 
-         if($list) foreach($list as $k => $v) {
 
-             if($v['hobby_ids']) {
 
-                 $list[$k]['hobby_ids'] = \app\common\model\Hobby::getHobbyNames($v['hobby_ids']);
 
-             } else {
 
-                 $list[$k]['hobby_ids'] = [];
 
-             }
 
-         }
 
-         return $list;
 
-     }
 
-     /**
 
-      * 获取喜欢列表
 
-      */
 
-     public function getFansList($user_id,$pageStart=1,$pageNum=10) {
 
-         $where = [];
 
-         $where["a.user_id"] = $user_id;
 
-         $list = $this->alias("a")
 
-             ->field("a.id,a.fans_id as user_id,u.nickname,u.avatar,u.age,u.constellation,hobby_ids,profession,u.copy_mobile,u.mobile")
 
-             ->join("hx_user u","u.id = a.fans_id","left")
 
-             ->where($where)
 
-             ->limit($pageStart,$pageNum)
 
-             ->select();
 
-         if($list) foreach($list as $k => $v) {
 
-             if($v['hobby_ids']) {
 
-                 $list[$k]['hobby_ids'] = \app\common\model\Hobby::getHobbyNames($v['hobby_ids']);
 
-             } else {
 
-                 $list[$k]['hobby_ids'] = [];
 
-             }
 
-         }
 
-         return $list;
 
-     }
 
- }
 
 
  |