|
@@ -13,7 +13,31 @@ class Friend extends Api
|
|
|
protected $noNeedRight = ['*'];
|
|
|
|
|
|
//好友列表
|
|
|
- public function lists(){
|
|
|
+ public function friend_lists(){
|
|
|
+
|
|
|
+ $ids = Db::name('friend')->where('user_id',$this->auth->id)->column('to_user_id');
|
|
|
+ $ids2 = Db::name('friend')->where('to_user_id',$this->auth->id)->column('user_id');
|
|
|
+
|
|
|
+ $ids3 = array_merge($ids,$ids2);
|
|
|
+ $ids4 = array_unique($ids3);
|
|
|
+ /*dump($ids);
|
|
|
+ dump($ids2);
|
|
|
+ dump($ids3);
|
|
|
+ dump($ids4);*/
|
|
|
+
|
|
|
+ $list = [];
|
|
|
+ if(!empty($ids4)){
|
|
|
+ $order = 'field(id,'.implode(',',$ids4).')';
|
|
|
+ $list = Db::name('user')->field('id,nickname,avatar,mobile')->where('id','IN',$ids4)->orderRaw($order)->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['avatar']);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success(1,$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //没做防重复的好友列表,废弃
|
|
|
+ public function aaa(){
|
|
|
+
|
|
|
$field = '
|
|
|
friend.id,friend.user_id,friend.to_user_id,
|
|
|
u.avatar as u_avatar,u.nickname as u_nickname,u.mobile as u_mobile,
|
|
@@ -34,14 +58,14 @@ class Friend extends Api
|
|
|
$newval = [
|
|
|
'id' => $val['to_user_id'],
|
|
|
'nickname' => $val['tu_nickname'],
|
|
|
- 'avatar' => $val['tu_avatar'],
|
|
|
+ 'avatar' => localpath_to_netpath($val['tu_avatar']),
|
|
|
'mobile' => $val['tu_mobile'],
|
|
|
];
|
|
|
}else{
|
|
|
$newval = [
|
|
|
'id' => $val['user_id'],
|
|
|
'nickname' => $val['u_nickname'],
|
|
|
- 'avatar' => $val['u_avatar'],
|
|
|
+ 'avatar' => localpath_to_netpath($val['u_avatar']),
|
|
|
'mobile' => $val['u_mobile'],
|
|
|
];
|
|
|
}
|