|
|
@@ -83,6 +83,15 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public SportsEquipmentFacilityVo getStoreDetail(Integer id) {
|
|
|
+ SportsEquipmentFacility facility = facilityMapper.selectById(id);
|
|
|
+ if (facility == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return convertToVo(facility);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public boolean saveFacility(SportsEquipmentFacility facility, List<String> imageList) {
|
|
|
// 校验图片数量(最多20张)
|
|
|
if (!CollectionUtils.isEmpty(imageList) && imageList.size() > 20) {
|
|
|
@@ -236,5 +245,63 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
|
|
|
}
|
|
|
return vo;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SportsEquipmentFacilityCategoryVo> getstoreCategorySummary(Integer storeId) {
|
|
|
+ List<SportsEquipmentFacilityCategoryVo> result = new ArrayList<>();
|
|
|
+
|
|
|
+ // 遍历所有分类(1:有氧区, 2:力量区, 3:单功能机械区)
|
|
|
+ for (int category = 1; category < FACILITY_CATEGORY_NAMES.length; category++) {
|
|
|
+ SportsEquipmentFacilityCategoryVo categoryVo = new SportsEquipmentFacilityCategoryVo();
|
|
|
+ categoryVo.setFacilityCategory(category);
|
|
|
+ categoryVo.setFacilityCategoryName(FACILITY_CATEGORY_NAMES[category]);
|
|
|
+
|
|
|
+ // 查询该分类下的设备列表(不分页)
|
|
|
+ LambdaQueryWrapper<SportsEquipmentFacility> facilityWrapper = new LambdaQueryWrapper<>();
|
|
|
+ facilityWrapper.eq(SportsEquipmentFacility::getStoreId, storeId)
|
|
|
+ .eq(SportsEquipmentFacility::getFacilityCategory, category);
|
|
|
+ facilityWrapper.orderByDesc(SportsEquipmentFacility::getCreatedTime);
|
|
|
+ List<SportsEquipmentFacility> facilityList = facilityMapper.selectList(facilityWrapper);
|
|
|
+
|
|
|
+ // 设置设备数量
|
|
|
+ categoryVo.setFacilityCount(facilityList != null ? facilityList.size() : 0);
|
|
|
+
|
|
|
+ // 转换为VO列表(不包含图片,避免重复查询)
|
|
|
+ List<SportsEquipmentFacilityVo> facilityVoList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(facilityList)) {
|
|
|
+ for (SportsEquipmentFacility facility : facilityList) {
|
|
|
+ SportsEquipmentFacilityVo vo = new SportsEquipmentFacilityVo();
|
|
|
+ BeanUtils.copyProperties(facility, vo);
|
|
|
+ // 设置分类名称
|
|
|
+ vo.setFacilityCategoryName(FACILITY_CATEGORY_NAMES[category]);
|
|
|
+ // 设置显示状态文本
|
|
|
+ if (facility.getDisplayInStoreDetail() != null) {
|
|
|
+ vo.setDisplayInStoreDetailText(facility.getDisplayInStoreDetail() == 1 ? "显示" : "隐藏");
|
|
|
+ }
|
|
|
+ facilityVoList.add(vo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ categoryVo.setFacilityList(facilityVoList);
|
|
|
+
|
|
|
+ // 查询该分类下的图片列表
|
|
|
+ LambdaQueryWrapper<StoreImg> imageWrapper = new LambdaQueryWrapper<>();
|
|
|
+ imageWrapper.eq(StoreImg::getStoreId, storeId)
|
|
|
+ .eq(StoreImg::getBusinessId, category)
|
|
|
+ .eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT);
|
|
|
+ imageWrapper.orderByAsc(StoreImg::getImgSort);
|
|
|
+ List<StoreImg> imageList = storeImgMapper.selectList(imageWrapper);
|
|
|
+ if (!CollectionUtils.isEmpty(imageList)) {
|
|
|
+ categoryVo.setImageList(imageList.stream().map(StoreImg::getImgUrl)
|
|
|
+ .collect(Collectors.toList()));
|
|
|
+ } else {
|
|
|
+ categoryVo.setImageList(new ArrayList<>());
|
|
|
+ }
|
|
|
+
|
|
|
+ result.add(categoryVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|
|
|
|