改为查询所有@PostMapping("/queryLicenseReminder") public ApiResult queryLicenseReminder() { Long retailShopId = AccessContext.get().getRetailShopId(); Map<String, List> map = new HashMap<>(3); if (retailShopId != null) { List<GspCompanyLicenseVO> gspCompanyLicenseList = gspCompanyLicenseService.queryLicenseReminder(retailShopId); List<GspUserLicenseVO> gspUserLicenseList = gspUserLicenseService.queryLicenseReminder(retailShopId); List<RetailShopLicenseVO> retailShopLicenseVOList = retailShopLicenseService.queryLicenseReminder(retailShopId); map.put("gspCompanyLicenseList", gspCompanyLicenseList); map.put("gspUserLicenseList", gspUserLicenseList); map.put("retailLicenseList", retailShopLicenseVOList); } return ApiResult.success(map); }
时间: 2024-04-06 15:29:10 浏览: 23
这段代码是在查询某个零售店的证照提醒信息,其中使用了三个服务类:GspCompanyLicenseService、GspUserLicenseService和RetailShopLicenseService。在方法中,首先获取当前访问上下文中的零售店ID,如果不为空,则分别调用这三个服务类中的方法获取对应的证照提醒信息,并将这些信息放入一个名为map的HashMap中,然后将map作为响应结果返回。其中,map中的三个key分别为"gspCompanyLicenseList"、"gspUserLicenseList"和"retailLicenseList",对应的value为对应的证照提醒信息列表。该方法使用了@PostMapping注解,且映射路径为"/queryLicenseReminder"。
相关问题
@PostMapping("/queryLicenseReminder") public ApiResult queryLicenseReminder() { Long retailShopId = AccessContext.get().getRetailShopId(); Map<String, List> map = new HashMap<>(3); if (retailShopId != null) { List<GspCompanyLicenseVO> gspCompanyLicenseList = gspCompanyLicenseService.queryLicenseReminder(retailShopId); List<GspUserLicenseVO> gspUserLicenseList = gspUserLicenseService.queryLicenseReminder(retailShopId); List<RetailShopLicenseVO> retailShopLicenseVOList = retailShopLicenseService.queryLicenseReminder(retailShopId); map.put("gspCompanyLicenseList", gspCompanyLicenseList); map.put("gspUserLicenseList", gspUserLicenseList); map.put("retailLicenseList", retailShopLicenseVOList); } return ApiResult.success(map); }改为查询所有门店不按照门店ID查询
可以将原先的 `Long retailShopId = AccessContext.get().getRetailShopId();` 改为获取所有门店的 ID 列表,然后遍历这些门店 ID,逐个查询每个门店的 License Reminder,将每个门店的查询结果存储到一个 List 中,最后将这个 List 作为整个 API 的返回值即可。具体实现可以参考下面的代码:
```
@GetMapping("/queryLicenseReminder")
public ApiResult queryLicenseReminder() {
List<Long> retailShopIdList = retailShopService.getAllRetailShopIds(); // 获取所有门店的 ID 列表
List<Map<String, List>> resultList = new ArrayList<>(); // 存储所有门店的查询结果
for (Long retailShopId : retailShopIdList) {
Map<String, List> map = new HashMap<>(3);
List<GspCompanyLicenseVO> gspCompanyLicenseList = gspCompanyLicenseService.queryLicenseReminder(retailShopId);
List<GspUserLicenseVO> gspUserLicenseList = gspUserLicenseService.queryLicenseReminder(retailShopId);
List<RetailShopLicenseVO> retailShopLicenseVOList = retailShopLicenseService.queryLicenseReminder(retailShopId);
map.put("gspCompanyLicenseList", gspCompanyLicenseList);
map.put("gspUserLicenseList", gspUserLicenseList);
map.put("retailLicenseList", retailShopLicenseVOList);
resultList.add(map);
}
return ApiResult.success(resultList);
}
```
这是我存图片的方法 请写一个查询图片的方法 因为一个商品有多张图片 查询时需要将商品id goodsId的图片全查出来返回 @Transactional(rollbackFor = Exception.class) @PostMapping("/saveGoodsImg") public ApiResult saveGoodsImg(@RequestBody GlbGoodsImageDTO glbGoodsImageDTO){ Long goodsId = glbGoodsImageDTO.getGoodsId(); if (goodsId == null) { return ApiResult.failure(ApiCode.PARAM_LACK); } // 存储图片 FileInfo fileInfo = new FileInfo(); fileInfo.setFileBytes(Base64.decodeBase64(glbGoodsImageDTO.getGoodsImg())); fileInfo.setFileType(glbGoodsImageDTO.getGoodsImgType()); FileInfo saveFileInfo = fileInfoService.save(fileInfo); GlbGoodsImage glbGoodsImage =new GlbGoodsImage(glbGoodsImageDTO); glbGoodsImage.setGoodsId(goodsId); glbGoodsImage.setGoodsImg(saveFileInfo.getFileInfoId()); glbGoodsImageService.save(glbGoodsImage); return ApiResult.success(); }
根据你提供的代码,我可以为你编写一个查询商品图片的方法。你可以将以下代码添加到你的控制器类中:
```java
@GetMapping("/getGoodsImages/{goodsId}")
public ApiResult getGoodsImages(@PathVariable Long goodsId) {
if (goodsId == null) {
return ApiResult.failure(ApiCode.PARAM_LACK);
}
List<GlbGoodsImage> goodsImages = glbGoodsImageService.findByGoodsId(goodsId);
List<FileInfo> imageFiles = new ArrayList<>();
for (GlbGoodsImage goodsImage : goodsImages) {
FileInfo fileInfo = fileInfoService.findById(goodsImage.getGoodsImg());
imageFiles.add(fileInfo);
}
return ApiResult.success(imageFiles);
}
```
上述代码中,我们定义了一个GET请求的方法`getGoodsImages`,接收`goodsId`作为路径参数。首先,我们检查`goodsId`是否为空,若为空则返回参数缺失的错误信息。然后,我们通过`glbGoodsImageService.findByGoodsId`方法查询指定`goodsId`的所有商品图片信息。接着,我们通过循环遍历每个商品图片记录,使用`fileInfoService.findById`方法查询对应的图片文件信息,并将其添加到一个列表中。最后,将包含所有图片文件信息的列表作为成功的响应返回。
请注意,上述代码中的方法名和参数类型可能需要根据你的具体业务逻辑进行调整。另外,确保你的服务类中有相应的方法来查询商品图片和文件信息。
希望这可以帮助到你!如果有任何进一步的问题,请随时提问。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)