|
|
@@ -13,11 +13,13 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import shop.alien.entity.store.BathFacilityService;
|
|
|
import shop.alien.entity.store.StoreImg;
|
|
|
+import shop.alien.entity.store.vo.BathFacilityServiceCategoryVo;
|
|
|
import shop.alien.entity.store.vo.BathFacilityServiceVo;
|
|
|
import shop.alien.mapper.BathFacilityServiceMapper;
|
|
|
import shop.alien.mapper.StoreImgMapper;
|
|
|
import shop.alien.store.service.BathFacilityServiceService;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -197,5 +199,58 @@ public class BathFacilityServiceServiceImpl extends ServiceImpl<BathFacilityServ
|
|
|
}
|
|
|
return vo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BathFacilityServiceCategoryVo> getCategorySummary(Integer storeId) {
|
|
|
+ List<BathFacilityServiceCategoryVo> result = new ArrayList<>();
|
|
|
+
|
|
|
+ // 遍历所有分类(1:洗浴区, 2:汗蒸区, 3:休闲区, 4:餐饮区)
|
|
|
+ for (int category = 1; category < FACILITY_CATEGORY_NAMES.length; category++) {
|
|
|
+ BathFacilityServiceCategoryVo categoryVo = new BathFacilityServiceCategoryVo();
|
|
|
+ categoryVo.setFacilityCategory(category);
|
|
|
+ categoryVo.setFacilityCategoryName(FACILITY_CATEGORY_NAMES[category]);
|
|
|
+
|
|
|
+ // 查询该分类下的设备列表(不分页)
|
|
|
+ LambdaQueryWrapper<BathFacilityService> facilityWrapper = new LambdaQueryWrapper<>();
|
|
|
+ facilityWrapper.eq(BathFacilityService::getStoreId, storeId)
|
|
|
+ .eq(BathFacilityService::getFacilityCategory, category);
|
|
|
+ facilityWrapper.orderByDesc(BathFacilityService::getCreatedTime);
|
|
|
+ List<BathFacilityService> facilityServiceList = facilityServiceMapper.selectList(facilityWrapper);
|
|
|
+
|
|
|
+ // 设置设备数量
|
|
|
+ categoryVo.setFacilityCount(facilityServiceList != null ? facilityServiceList.size() : 0);
|
|
|
+
|
|
|
+ // 查询该分类的代表图片(从第一个设备的第一张图片获取)
|
|
|
+ if (!CollectionUtils.isEmpty(facilityServiceList)) {
|
|
|
+ BathFacilityService firstFacility = facilityServiceList.get(0);
|
|
|
+ // 查询该设备的第一张图片
|
|
|
+ LambdaQueryWrapper<StoreImg> imageWrapper = new LambdaQueryWrapper<>();
|
|
|
+ imageWrapper.eq(StoreImg::getStoreId, storeId)
|
|
|
+ .eq(StoreImg::getBusinessId, firstFacility.getId())
|
|
|
+ .eq(StoreImg::getImgType, IMG_TYPE_BATH_FACILITY);
|
|
|
+ imageWrapper.orderByAsc(StoreImg::getImgSort);
|
|
|
+ imageWrapper.last("LIMIT 1");
|
|
|
+ StoreImg firstImage = storeImgMapper.selectOne(imageWrapper);
|
|
|
+ if (firstImage != null) {
|
|
|
+ categoryVo.setCategoryImage(firstImage.getImgUrl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转换为VO列表(包含设备信息和图片)
|
|
|
+ List<BathFacilityServiceVo> facilityVoList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(facilityServiceList)) {
|
|
|
+ for (BathFacilityService facilityService : facilityServiceList) {
|
|
|
+ // 使用现有的convertToVo方法,它会自动查询图片
|
|
|
+ BathFacilityServiceVo vo = convertToVo(facilityService);
|
|
|
+ facilityVoList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ categoryVo.setFacilityList(facilityVoList);
|
|
|
+
|
|
|
+ result.add(categoryVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
|