Selaa lähdekoodia

feat(app): 优化获取分类信息逻辑

- 修改 getAllCategory 方法,增加对场地类型的支持
- 对于普通场地,使用原有逻辑获取分类信息
- 对于特殊场地,根据场地类型和分类 ID 获取分类信息
- 优化代码结构,提高可读性和可维护性
SheepHy 1 viikko sitten
vanhempi
commit
d197e73728

+ 8 - 5
national-motion-module-system/national-motion-system-biz/src/main/java/org/jeecg/modules/app/service/impl/DetailServiceImpl.java

@@ -377,11 +377,14 @@ public class DetailServiceImpl implements IDetailService {
     @Override
     public List<AppCategory> getAllCategory(String id) {
         List<AppCategory> appCategories = new ArrayList<>();
-        List<Object> objects = appSitePlaceMapper.selectObjs(Wrappers.<AppSitePlace>lambdaQuery()
-                .select(AppSitePlace::getCategoryId)
-                .eq(AppSitePlace::getSiteId, id)
-                .groupBy(AppSitePlace::getCategoryId));
-        if(null == objects || objects.isEmpty()) return appCategories;
+        List<AppSitePlace> appSitePlaceList = appSitePlaceMapper.selectList(Wrappers.<AppSitePlace>lambdaQuery()
+                .eq(AppSitePlace::getSiteId, id));
+        List<String> objects = appSitePlaceList.stream().map(AppSitePlace::getCategoryId).collect(Collectors.toList());
+        AppSite appSite = appSiteMapper.selectById(id);
+        if(null != appSite && appSite.getType() == 0){
+            objects = Arrays.asList(appSite.getCategoryId().split(","));
+        }
+        if(objects.isEmpty()) return appCategories;
         appCategories = appCategoryMapper.selectList(Wrappers.<AppCategory>lambdaQuery()
                 .eq(AppCategory::getStatus, 0).in(AppCategory::getId,objects)
                 .eq(AppCategory::getDelFlag, 0));