package com.demo.service.impl; import com.demo.dao.CategoryMapper; import com.demo.dao.ProductMapper; import com.demo.pojo.Category; import com.demo.pojo.CategoryExample; import com.demo.pojo.Product; import com.demo.service.ForeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; @Service public class ForeServiceImpl implements ForeService { @Autowired private CategoryMapper categoryMapper; @Autowired private ProductMapper productMapper; @Override public List listToThree() { CategoryExample example = new CategoryExample(); example.createCriteria().andIdBetween(1,4); //从1开始计数 List categories = categoryMapper.selectByExample(example); return categories; } @Override public List getFivePro() { return productMapper.randFive(); } }