| | |
| | | |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | vo.setId(item.getId()); |
| | | vo.setJumpType(item.getJumpType()); |
| | | vo.setJumpUrl(item.getJumpUrl()); |
| | | JSONObject jsonObject = JSON.parseArray(item.getBannerPictures()).getJSONObject(0); |
| | | String downloadUrl = null; |
| | | try { |
| | | // 1 |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | JSONArray jsonArray = JSONArray.parseArray(item.getBannerPictures()); |
| | | for (Object o : jsonArray) { |
| | | JSONObject jsonObject = (JSONObject) o; |
| | | String downloadUrl = null; |
| | | try { |
| | | // 1 |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | vo.setImageUrl(jsonObject.toJSONString()); |
| | | |
| | | vo.setImageUrl(JSONArray.toJSONString(jsonArray)); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | } |
| | |
| | | PageInfo<XpBanner> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<XpBanner> list = this.baseMapper.pageList(pageInfo, query); |
| | | for (XpBanner xpBanner : list) { |
| | | JSONObject jsonObject = JSON.parseArray(xpBanner.getBannerPictures()).getJSONObject(0); |
| | | String downloadUrl = null; |
| | | try { |
| | | // 1 |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | |
| | | JSONArray jsonArray = JSONArray.parse(xpBanner.getBannerPictures()); |
| | | for (Object o : jsonArray) { |
| | | JSONObject jsonObject = (JSONObject) o; |
| | | String downloadUrl = null; |
| | | try { |
| | | // 1 |
| | | downloadUrl = aliOssService.getDownloadUrl(jsonObject.getString("id"), jsonObject.getString("name"), true); |
| | | } catch (UnsupportedEncodingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | } |
| | | jsonObject.put("url", downloadUrl); |
| | | xpBanner.setBannerPictures(jsonObject.toJSONString()); |
| | | |
| | | xpBanner.setBannerPictures(JSONArray.toJSONString(jsonArray)); |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |