1.业务层实现:
CategoryService :
public interface CategoryService {
public ResultVO listCategories();
public ResultVO listFirstLevelCategories();
}
CategoryServiceImpl:
@Service
public class CategoryServiceImpl implements CategoryService {
@Autowired
private CategoryMapper categoryMapper;
//查询分类列表(包含三个级别的分类)
public ResultVO listCategories() {
List<CategoryVO> categoryVOS = categoryMapper.selectAllCategories();
ResultVO resultVO = new ResultVO(ResStatus.OK, "success", categoryVOS);
return resultVO;
}
//查询所有一级分类,同时查询当前一级分类下销量最高的6个商品
public ResultVO listFirstLevelCategories() {
List<CategoryVO> categoryVOS = categoryMapper.selectFirstLevelCategories();
ResultVO resultVO = new ResultVO(ResStatus.OK, "success", categoryVOS);
return resultVO;
}
}
2.控制层实现:
@RestController
@CrossOrigin
@RequestMapping("/index")
@Api(value = "提供首页数据显示所需的接口",tags = "首页管理")
public class IndexController {
@Autowired
private IndexImgService indexImgService;
@Autowired
private CategoryService categoryService;
@Autowired
private ProductService productService;
@GetMapping("/indeximg")
@ApiOperation("首页轮播图接口")
public ResultVO listIndexImgs(){
return indexImgService.listIndexImgs();
}
@GetMapping("/category-list")
@ApiOperation("商品分类查询接口")
public ResultVO listCategory(){
return categoryService.listCategories();
}
@GetMapping("/list-recommends")
@ApiOperation("查询新品商品的接口")
public ResultVO listRecommendProducts(){
return productService.listRecommendProducts();
}
@GetMapping("/category-recommends")
@ApiOperation("查询分类推荐商品的接口")
public ResultVO listRecommendProductsByCategory(){
return categoryService.listFirstLevelCategories();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/128109.html