| | |
| | | package cc.mrbird.febs.mall.service.impl; |
| | | |
| | | import cc.mrbird.febs.mall.entity.MallAddressWorld; |
| | | import cc.mrbird.febs.mall.entity.MallGoods; |
| | | import cc.mrbird.febs.mall.entity.MallGoodsCategory; |
| | | import cc.mrbird.febs.mall.mapper.MallAddressWorldMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsCategoryMapper; |
| | | import cc.mrbird.febs.mall.mapper.MallGoodsMapper; |
| | | import cc.mrbird.febs.mall.service.IApiMallGoodsCategoryService; |
| | | import cc.mrbird.febs.mall.vo.AdminWorldAddressVo; |
| | | import cc.mrbird.febs.mall.vo.MallGoodsCategoryVo; |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @RequiredArgsConstructor |
| | | public class ApiMallGoodsCategoryServiceImpl extends ServiceImpl<MallGoodsCategoryMapper, MallGoodsCategory> implements IApiMallGoodsCategoryService { |
| | | |
| | | private final MallAddressWorldMapper mallAddressWorldMapper; |
| | | private final MallGoodsMapper mallGoodsMapper; |
| | | |
| | | @Override |
| | | public List<MallGoodsCategoryVo> findAllCategoryList() { |
| | | return this.baseMapper.selectAllCategoryList(); |
| | | List<MallGoodsCategoryVo> mallGoodsCategoryVos = this.baseMapper.selectAllCategoryList(); |
| | | ArrayList<MallGoodsCategoryVo> objects = new ArrayList<>(); |
| | | if(CollUtil.isNotEmpty(mallGoodsCategoryVos)){ |
| | | mallGoodsCategoryVos.forEach(item -> { |
| | | Long id = item.getId(); |
| | | List<MallGoods> mallGoods = mallGoodsMapper.selectList( |
| | | new LambdaQueryWrapper<MallGoods>() |
| | | .select(MallGoods::getId) |
| | | .eq(MallGoods::getCategoryId, id)); |
| | | if(CollUtil.isEmpty(mallGoods)){ |
| | | objects.add(item); |
| | | } |
| | | }); |
| | | } |
| | | if(CollUtil.isNotEmpty(objects)){ |
| | | mallGoodsCategoryVos.removeAll(objects); |
| | | } |
| | | return mallGoodsCategoryVos; |
| | | } |
| | | |
| | | @Override |
| | |
| | | public List<MallGoodsCategory> findRecommendCategory() { |
| | | return this.baseMapper.selectRecommendCategoryList(); |
| | | } |
| | | |
| | | @Override |
| | | public List<AdminWorldAddressVo> findAllAddressList() { |
| | | List<AdminWorldAddressVo> objects = new ArrayList<>(); |
| | | LambdaQueryWrapper<MallAddressWorld> addressWorldLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | addressWorldLambdaQueryWrapper.eq(MallAddressWorld::getPid, 131) |
| | | .eq(MallAddressWorld::getLevel, 3) |
| | | .orderByAsc(MallAddressWorld::getId); |
| | | // 执行查询 |
| | | List<MallAddressWorld> mallAddressWorlds = mallAddressWorldMapper.selectList(addressWorldLambdaQueryWrapper); |
| | | if(CollUtil.isNotEmpty(mallAddressWorlds)){ |
| | | mallAddressWorlds.forEach(item -> { |
| | | AdminWorldAddressVo adminWorldAddressVo = new AdminWorldAddressVo(); |
| | | adminWorldAddressVo.setId(item.getId()); |
| | | adminWorldAddressVo.setName(item.getName()+"-"+item.getNameEn()+"-"+item.getNamePinyin()); |
| | | objects.add(adminWorldAddressVo); |
| | | }); |
| | | } |
| | | return objects; |
| | | } |
| | | } |