@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 07:33:37 浏览: 25
这是一个使用 Spring MVC 框架编写的 Java 后端接口代码,使用了 @PostMapping 注解将该接口映射到 HTTP POST 请求上。该接口名为 queryLicenseReminder,没有参数,返回类型为 ApiResult。接口中首先通过 AccessContext 获取当前用户所属的零售店 ID,如果该 ID 不为空,则调用三个服务(gspCompanyLicenseService、gspUserLicenseService、retailShopLicenseService)分别查询 GSP 公司许可证、GSP 用户许可证和零售店许可证的提醒信息,将这些信息存入一个名为 map 的 HashMap 中,并将其作为 ApiResult 的 data 属性返回。如果零售店 ID 为空,则返回一个空的 HashMap。
相关问题
@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);
}
```
改为查询所有@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); }
这段代码是在查询某个零售店的证照提醒信息,其中使用了三个服务类:GspCompanyLicenseService、GspUserLicenseService和RetailShopLicenseService。在方法中,首先获取当前访问上下文中的零售店ID,如果不为空,则分别调用这三个服务类中的方法获取对应的证照提醒信息,并将这些信息放入一个名为map的HashMap中,然后将map作为响应结果返回。其中,map中的三个key分别为"gspCompanyLicenseList"、"gspUserLicenseList"和"retailLicenseList",对应的value为对应的证照提醒信息列表。该方法使用了@PostMapping注解,且映射路径为"/queryLicenseReminder"。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![mp4](https://img-home.csdnimg.cn/images/20210720083504.png)