where('v_alias', $viewAlias)->first(); if (empty($infoObj)) { return $this->responseMessage(2001, '视图不存在,请重试!'); } $info = get_object_vars($infoObj); $groupData = json_decode($info['v_data'], true); if ($groupData) { //获取所有的属性id $attrIdArr = []; foreach ($groupData as $key => $item) { if (isset($item['attributes']) && $item['attributes']) { foreach ($item['attributes'] as $akey => $aItem) { $attrIdArr[] = $aItem['vd_attr_id']; } } } //获取数据 $attrCodeArr = []; if ($attrIdArr) { $attrListObj = DB::table('sys_set_attribute')->where('set_id', $info['v_set_id'])->whereIn('sa_id', $attrIdArr)->get(); $attrList = array_map('get_object_vars', $attrListObj->toArray()); $attrKeyIds = array_column($attrList, 'sa_id'); $attrValueCodes = array_column($attrList, 'sa_code'); $attrCodeArr = array_combine($attrKeyIds, $attrValueCodes); } //重新赋值数据 foreach ($groupData as $key => $item) { if (isset($item['attributes']) && $item['attributes']) { foreach ($item['attributes'] as $aKey => $aItem) { $item['attributes'][$aKey]['sa_code'] = $attrCodeArr[$aItem['vd_attr_id']] ?? ''; } $groupData[$key]['attributes'] = $item['attributes']; } } } $info['v_data'] = $groupData; if (in_array($info['v_type'], [1, 2, 3, 4, 5])) { $info['v_type_data'] = json_decode($info['v_type_data']); } //获取接口信息 if ($info['v_interface_id']) { $interInfoObj = DB::table('sys_interface') ->select(['i_alias', 'i_func', 'i_func_type', 'i_is_category', 'i_category_level'])->where('i_id', $info['v_interface_id'])->first(); if ($interInfoObj) { $info['interfaceInfo'] = get_object_vars($interInfoObj); } } Cache::forever($cacheKey, $info); } return $this->responseMessage(1001, 'success', $info); } }