diff --git a/Cunkebao/components/WechatFriendSelector.tsx b/Cunkebao/components/WechatFriendSelector.tsx index a9aa5c58..0eb8f1b4 100644 --- a/Cunkebao/components/WechatFriendSelector.tsx +++ b/Cunkebao/components/WechatFriendSelector.tsx @@ -39,9 +39,10 @@ interface WechatFriendSelectorProps { onOpenChange: (open: boolean) => void selectedFriends: WechatFriend[] onSelect: (friends: WechatFriend[]) => void + devices?: number[] } -export function WechatFriendSelector({ open, onOpenChange, selectedFriends, onSelect }: WechatFriendSelectorProps) { +export function WechatFriendSelector({ open, onOpenChange, selectedFriends, onSelect, devices = [] }: WechatFriendSelectorProps) { const [searchQuery, setSearchQuery] = useState("") const [friends, setFriends] = useState([]) const [loading, setLoading] = useState(false) @@ -67,6 +68,10 @@ export function WechatFriendSelector({ open, onOpenChange, selectedFriends, onSe ...(searchQuery ? { keyword: searchQuery } : {}) }) + if (devices && devices.length > 0) { + queryParams.append('deviceIds', devices.join(',')) + } + const response = await api.get>(`/v1/friend?${queryParams.toString()}`) if (response.code === 200 && response.data) { diff --git a/Server/application/cunkebao/controller/friend/GetFriendListV1Controller.php b/Server/application/cunkebao/controller/friend/GetFriendListV1Controller.php index a7e6de38..cf523a1c 100644 --- a/Server/application/cunkebao/controller/friend/GetFriendListV1Controller.php +++ b/Server/application/cunkebao/controller/friend/GetFriendListV1Controller.php @@ -23,6 +23,12 @@ class GetFriendListV1Controller extends BaseController $page = $this->request->param('page',1); $limit = $this->request->param('limit',20); $keyword = $this->request->param('keyword',''); + $deviceIds = $this->request->param('deviceIds',''); + + if(!empty($deviceIds)){ + $deviceIds = explode(',',$deviceIds); + } + try { $where = []; @@ -35,17 +41,22 @@ class GetFriendListV1Controller extends BaseController //$where[] = ['wf.userId','=',$this->getUserInfo('id')]; } - if(!empty($keyword)){ $where[] = ['wa1.nickname','like','%'.$keyword.'%']; } + if(!empty($deviceIds) && is_array($deviceIds)){ + $where[] = ['dw.deviceId','in',$deviceIds]; + } + + $data = WechatFriendShipModel::alias('wf') ->field(['wa1.nickname','wa1.avatar','wa1.alias','wf.id','wf.wechatId','wa2.nickname as ownerNickname','wa2.alias as ownerAlias','wa2.wechatId as ownerWechatId','wf.createTime']) ->Join('wechat_account wa1','wf.wechatId = wa1.wechatId') ->Join('wechat_account wa2','wf.ownerWechatId = wa2.wechatId') + ->join('device_wechat_login dw','wa2.wechatId = dw.wechatId') ->where($where); $total = $data->count();