Эх сурвалжийг харах

feat 1.餐馆信息管理餐馆接口

classic_blue 5 сар өмнө
parent
commit
610e90b9a3

+ 91 - 0
application-webadmin/src/main/java/com/tourism/webadmin/back/controller/RestaurantInfoController.java

@@ -212,10 +212,101 @@ public class RestaurantInfoController {
                 }
             });
         }
+        System.out.println();
         return ResponseResult.success(restaurantInfoVoMyPageData);
     }
 
     /**
+     * 列出符合过滤条件的餐馆信息列表。
+     *
+     * @param restaurantInfoDtoFilter 过滤对象。
+     * @param orderParam 排序参数。
+     * @param pageParam 分页参数。
+     * @return 应答结果对象,包含查询结果集。
+     */
+    @SaCheckPermission("restaurantInfo.view")
+    @PostMapping("/listA")
+    public ResponseResult<MyPageData<RestaurantInfoVo>> listA(
+            @MyRequestBody RestaurantInfoDto restaurantInfoDtoFilter,
+            @MyRequestBody MyOrderParam orderParam,
+            @MyRequestBody MyPageParam pageParam) {
+
+        if (pageParam != null) {
+            PageMethod.startPage(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getCount());
+        }
+
+        RestaurantInfo restaurantInfoFilter = MyModelUtil.copyTo(restaurantInfoDtoFilter, RestaurantInfo.class);
+
+        String orderBy = MyOrderParam.buildOrderBy(orderParam, RestaurantInfo.class);
+
+        List<RestaurantInfo> restaurantInfoList =
+                restaurantInfoService.getRestaurantInfoListWithRelation(restaurantInfoFilter, orderBy);
+
+        MyPageData<RestaurantInfoVo> restaurantInfoVoMyPageData = MyPageUtil.makeResponseData(restaurantInfoList, RestaurantInfoVo.class);
+        List<RestaurantInfoVo> dataList = restaurantInfoVoMyPageData.getDataList();
+
+        Set<Long> restaurantTypeIdSet = new HashSet<>();
+        for (RestaurantInfoVo i : dataList) {
+            if (StringUtils.isNotEmpty(i.getTypeId())) {
+                String[] split = i.getTypeId().split(",");
+                for (String j : split) {
+                    restaurantTypeIdSet.add(Long.parseLong(j));
+                }
+            }
+        }
+
+        List<RestaurantType> inList = restaurantTypeService.getInList("id", restaurantTypeIdSet);
+        if (!CollectionUtils.isEmpty(inList)) {
+            Map<Long, String> collect = inList.stream()
+                    .collect(Collectors.toMap(RestaurantType::getId, RestaurantType::getName));
+
+            dataList.stream().forEach(i -> {
+                if (StringUtils.isNotEmpty(i.getTypeId())) {
+                    String[] split = i.getTypeId().split(",");
+
+                    i.setTypeIdList(Arrays.asList(split));
+
+                    Map<String, Object> typeIdDict = new HashMap<>();
+                    for (String id : split) {
+                        Long typeId = Long.parseLong(id);
+                        String typeName = collect.get(typeId);
+                        if (typeName != null) {
+                            typeIdDict.put(id, typeName);
+                        }
+                    }
+                    i.setTypeIdDictMap(typeIdDict);
+
+                    List<Map<String, Object>> typeIdDictList = new ArrayList<>();
+                    for (String id : split) {
+                        Map<String, Object> map = new HashMap<>();
+                        Long typeId = Long.parseLong(id);
+                        map.put("id", typeId);
+                        map.put("name", collect.get(typeId));
+                        typeIdDictList.add(map);
+                    }
+                    i.setTypeIdDictMapList(typeIdDictList);
+
+                    StringBuilder typeNameBuilder = new StringBuilder();
+                    for (int j = 0; j < split.length; j++) {
+                        String typeName = collect.get(Long.parseLong(split[j]));
+                        if (typeName != null) {
+                            if (j == 0) {
+                                typeNameBuilder.append(typeName);
+                            } else {
+                                typeNameBuilder.append(",").append(typeName);
+                            }
+                        }
+                    }
+                    i.setTypeName(typeNameBuilder.toString());
+                }
+            });
+        }
+
+        return ResponseResult.success(restaurantInfoVoMyPageData);
+    }
+
+
+    /**
      * 导入主表数据列表。
      *
      * @param importFile 上传的文件,目前仅仅支持xlsx和xls两种格式。