123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Repositories;
- use App\Exceptions\TencentImException;
- use App\Models\ChatTeam;
- use App\Services\TencentImGroupService;
- use App\Services\TencentImMessage;
- use Dcat\Admin\Grid;
- use Dcat\Admin\Repositories\Repository;
- use GuzzleHttp\Exception\GuzzleException;
- use Illuminate\Pagination\LengthAwarePaginator;
- class ChatTeamLog extends Repository
- {
- public $group_id;
- public $to_user_id;
- public function __construct($group_id)
- {
- $this->group_id = $group_id;
- }
- /**
- * 查询表格数据
- *
- * @param Grid\Model $model
- * @return LengthAwarePaginator
- */
- public function get(Grid\Model $model)
- {
- $currentPage = $model->getCurrentPage();
- $perPage = $model->getPerPage();
- $data =new TencentImGroupService();
- try {
- $req_data['GroupId'] = $this->group_id;
- $req_data['number'] = 20;
- // $req_data['seq'] = 20;
- $res = $data->groupMsgGetSimple($req_data);
- if($res['IsFinished']==1){
- if (!empty($res) && !empty($res['RspMsgList'])) {
- foreach ($res['RspMsgList'] as $k=>$v){
- $res['RspMsgList'][$k]['IsSystemMsg'] = $v['IsSystemMsg']??0;
- if($v['IsPlaceMsg']==1){
- unset($res['RspMsgList'][$k]);
- }
- }
- return $model->makePaginator(count($res['RspMsgList']),$res['RspMsgList']);
- }
- }else{
- return $model->makePaginator(0,[]);
- }
- } catch (TencentImException | GuzzleException $e) {
- return $e->getMessage();
- }
- }
- }
|