|
@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import edu.travel.commodity.constant.BaseConstant;
|
|
|
import edu.travel.commodity.constant.RedisKey;
|
|
|
+import edu.travel.commodity.dto.BaseDto;
|
|
|
import edu.travel.commodity.dto.ShopTypeDto;
|
|
|
import edu.travel.commodity.entity.ShopCategory;
|
|
|
import edu.travel.commodity.mapper.ShopCategoryMapper;
|
|
@@ -44,7 +45,7 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryMapper, Sho
|
|
|
}
|
|
|
LambdaQueryWrapper<ShopCategory> query = Wrappers.lambdaQuery();
|
|
|
//条件构建
|
|
|
- query.eq(ShopCategory::getCountry, shopTypeDto.getCountryId());
|
|
|
+ query.eq(ShopCategory::getCountryId, shopTypeDto.getCountryId());
|
|
|
|
|
|
if(shopTypeDto.getIsHeat().equals(BaseConstant.BASIC_STATUS_NO_STR)){
|
|
|
query.orderByDesc(ShopCategory::getHeatValue);
|
|
@@ -74,4 +75,25 @@ public class ShopCategoryServiceImpl extends ServiceImpl<ShopCategoryMapper, Sho
|
|
|
}
|
|
|
return parent;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ShopTypeVo> getLevelToShopType(BaseDto param) {
|
|
|
+ String string = redisUtil.getString(RedisKey.PRODUCT_TO_HOT_TYPE);
|
|
|
+ if(!ObjectUtil.isEmpty(string)){
|
|
|
+ JSONArray objects = JSONUtil.parseArray(string);
|
|
|
+ return JSONUtil.toList(objects, ShopTypeVo.class);
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<ShopCategory> query = Wrappers.lambdaQuery();
|
|
|
+ //条件构建
|
|
|
+ query.eq(ShopCategory::getCountryId, param.getCountryId())
|
|
|
+ .orderByDesc(ShopCategory::getHeatValue).ne(ShopCategory::getParentId,0);
|
|
|
+ List<ShopCategory> list = list(query);
|
|
|
+ if(list.isEmpty()){
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ List<ShopTypeVo> parent = BeanUtil.copyToList(list, ShopTypeVo.class);
|
|
|
+ //24小时热门过期
|
|
|
+ redisUtil.setString(RedisKey.PRODUCT_TO_HOT_TYPE,JSONUtil.toJsonStr(parent),24*60*60*60, TimeUnit.SECONDS);
|
|
|
+ return parent;
|
|
|
+ }
|
|
|
}
|