75 lines
2.3 KiB
PHP
Executable File
75 lines
2.3 KiB
PHP
Executable File
<?php
|
||
/*
|
||
* description:
|
||
* author:wh
|
||
* email:
|
||
* createTime:{2025/3/22} {17:48}
|
||
*/
|
||
|
||
namespace app\admin\controller;
|
||
|
||
|
||
use app\api\logic\GechatroomLogic;
|
||
use think\Controller;
|
||
|
||
class Gechatroom extends Controller
|
||
{
|
||
|
||
/**
|
||
* 查询系统微信中的群【只有群id列表】[需要手动保存为通讯录]
|
||
*
|
||
* array(3) {
|
||
[0] => string(19) "7037032174@chatroom"
|
||
[1] => string(20) "52468523601@chatroom"
|
||
[2] => string(20) "52984126208@chatroom"
|
||
}
|
||
*
|
||
* /api/Gechatroom/getChatroomList
|
||
*/
|
||
function getChatroomList()
|
||
{
|
||
if(cache('cache_getChatroomList_data'.session_admin_firm_id())){
|
||
$data = cache('cache_getChatroomList_data'.session_admin_firm_id());
|
||
//自带id,name
|
||
return json(['list' => $data, 'total' => count($data)]);
|
||
}
|
||
$ai_config_id = input('ai_config_id');
|
||
if(empty($ai_config_id)){
|
||
throw new \Exception('ai_config_id不能为空');
|
||
}
|
||
$logic = new GechatroomLogic();
|
||
$data = $logic->getChatroomList($ai_config_id);
|
||
//dump($data);die;
|
||
//缓存群成员列表
|
||
cache('cache_getChatroomList_data'.session_admin_firm_id(),$data,86400);
|
||
//自带id,name
|
||
return json(['list' => $data, 'total' => count($data)]);
|
||
}
|
||
|
||
|
||
/**
|
||
* 查询群成员列表
|
||
*/
|
||
function getChatroomMemberList()
|
||
{
|
||
$chatroom_id = input('chatroom_id');
|
||
if(empty($chatroom_id)){
|
||
return json(['list' => [], 'total' => 0]);
|
||
}
|
||
if(cache('cache_getChatroomList_data'.session_admin_firm_id())){
|
||
$cache_data = cache('cache_getChatroomList_data'.session_admin_firm_id());
|
||
$memberList = $cache_data[$chatroom_id]['memberList'];
|
||
return json(['list' => $memberList, 'total' => count($memberList)]);
|
||
}
|
||
$ai_config_id = input('ai_config_id');
|
||
if(empty($ai_config_id)){
|
||
throw new \Exception('ai_config_id不能为空');
|
||
}
|
||
$data = (new GechatroomLogic())->getChatroomList($ai_config_id);
|
||
//缓存群成员列表
|
||
cache('cache_getChatroomList_data'.session_admin_firm_id(),$data['memberList'],86400);
|
||
$memberList = $data[$chatroom_id]['memberList'];
|
||
return json(['list' => $memberList, 'total' => count($memberList)]);
|
||
}
|
||
|
||
} |