class WholesaleServiceImpl extends ServiceImpl<WholesaleMapper, Wholesale> implements WholesaleService {

    @Autowired
    private Cache<List<Wholesale>> cache;

    @Override
    @Cacheable(key = "#goodsId")
    public List<Wholesale> findByGoodsId(String goodsId) {
        LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Wholesale::getGoodsId, goodsId);
        return this.list(queryWrapper).stream().sorted(Comparator.comparing(Wholesale::getNum)).collect(Collectors.toList());
    }

    @Override
    @Cacheable(key = "#templateId+'_template'")
    public List<Wholesale> findByTemplateId(String templateId) {
        LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Wholesale::getTemplateId, templateId);
        return this.list(queryWrapper).stream().sorted(Comparator.comparing(Wholesale::getNum)).collect(Collectors.toList());
    }

    @Override
    @CacheEvict(key = "#templateId+'_template'")
    public Boolean removeByTemplateId(String templateId) {<FILL_FUNCTION_BODY>}

    @Override
    @CacheEvict(key = "#goodsId")
    public Boolean removeByGoodsId(String goodsId) {
        LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Wholesale::getGoodsId, goodsId);
        cache.remove("{wholesale}_" + goodsId);
        return this.remove(queryWrapper);
    }

    @Override
    public Wholesale match(String goodsId, Integer num) {
        List<Wholesale> wholesaleList = cache.get("{wholesale}_" + goodsId);
        if (wholesaleList == null) {
            wholesaleList = this.findByGoodsId(goodsId);
            cache.put("{wholesale}_" + goodsId, wholesaleList);
        }
        List<Wholesale> matchList = wholesaleList.stream()
                .filter(wholesale -> wholesale.getNum() <= num)
                .collect(Collectors.toList());
        if (CollUtil.isNotEmpty(matchList)) {
            return matchList.get(matchList.size() - 1);
        } else if (CollUtil.isNotEmpty(wholesaleList) && CollUtil.isEmpty(matchList)) {
            throw new ServiceException(ResultCode.DO_NOT_MATCH_WHOLESALE);
        }
        return null;
    }
}

        LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Wholesale::getTemplateId, templateId);
        cache.remove("{wholesale}_" + templateId + "_template");
        return this.remove(queryWrapper);
    
<no_super_class>