webman admin返回数据处理

令狐冲

问题描述

webman-admin返回的查询数据怎么处理?

support\Response::__set_state(array(
   'exception' => NULL,
   '_header' =>
  array (
    'Content-Type' => 'application/json',
  ),
   '_status' => 200,
   '_reason' => NULL,
   '_version' => '1.1',
   '_body' => '{"code":0,"msg":"ok","count":1,"data":[{"id":1,"created_at":"2023-12-26 18:07:04","updated_at":"2024-01-04 16:18:59","uid":null,"black_type":0,"value":"124.1.1.2","note":"禁用該IP下所有用戶","adminid":1,"status":1}]}',
   'file' => NULL,
))

比如这样的返回结果,我想获取 _body 里面的 adminid 并查询他的信息,然后再输出,应该怎么处理?

521 2 0
2个回答

owenzhang

->body() ?

令狐冲

试了半天,最后用这种方式读取和写入数据的

$list = parent::select($request);
$data = json_decode($list->rawBody(),1);
foreach($data['data'] as &$v){
    $admin = getAdminInfo($v['adminid']);
    $v['admin'] = $admin['nickname'].'('.$v['adminid'].')';
}
$list->withBody(json_encode($data));
return $list;
  • 暂无评论
×
🔝