|
|
@@ -254,5 +254,80 @@ public class BathFacilityServiceServiceImpl extends ServiceImpl<BathFacilityServ
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public IPage<BathFacilityServiceVo> getStorePageList(Integer pageNum, Integer pageSize, Integer storeId, Integer facilityCategory) {
|
|
|
+ Page<BathFacilityService> page = new Page<>(pageNum, pageSize);
|
|
|
+ LambdaQueryWrapper<BathFacilityService> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(BathFacilityService::getStoreId, storeId);
|
|
|
+ if (facilityCategory != null) {
|
|
|
+ queryWrapper.eq(BathFacilityService::getFacilityCategory, facilityCategory);
|
|
|
+ }
|
|
|
+ queryWrapper.orderByDesc(BathFacilityService::getCreatedTime);
|
|
|
+ IPage<BathFacilityService> facilityServicePage = facilityServiceMapper.selectPage(page, queryWrapper);
|
|
|
+ return facilityServicePage.convert(this::convertToVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public BathFacilityServiceVo getStoreDetail(Integer id) {
|
|
|
+ BathFacilityService facilityService = facilityServiceMapper.selectById(id);
|
|
|
+ if (facilityService == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return convertToVo(facilityService);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BathFacilityServiceCategoryVo> getStoreCategorySummary(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;
|
|
|
+ }
|
|
|
}
|
|
|
|