• JSD-2204-(业务逻辑开发)-发酷鲨商城front模块-开发购物车功能-Day09


    1.开发酷鲨商城front模块

    1.1按分类id查询spu列表

    用户会根据分类树中的分类的名称,查询它需要的商品类别

    点击商品分类名称时,实际上我们获得了它的分类id(categoryId)

    我们可以根据这个id到pms_spu表中查询商品信息

    并进行分页显示

    这个查询目标仍然为mall-pms数据库,是product模块管理的范围

    所以我们在业务逻辑层中编写利用dubbo调用即可,还是不需要写mapper

    下面就在业务逻辑层中创建FrontProductServiceImpl

    1. @Service
    2. @Slf4j
    3. public class FrontProductServiceImpl implements IFrontProductService {
    4. @DubboReference
    5. private IForFrontSpuService dubboSpuService;
    6. @Override
    7. public JsonPage listSpuByCategoryId(Long categoryId, Integer page, Integer pageSize) {
    8. // IForFrontSpuService实现类中已经完成了分页查询的细节,我们直接调用即可
    9. JsonPage list=
    10. dubboSpuService.listSpuByCategoryId(categoryId,page,pageSize);
    11. // 返回 list!!!
    12. return list;
    13. }
    14. @Override
    15. public SpuStandardVO getFrontSpuById(Long id) {
    16. return null;
    17. }
    18. @Override
    19. public List getFrontSkusBySpuId(Long spuId) {
    20. return null;
    21. }
    22. @Override
    23. public SpuDetailStandardVO getSpuDetail(Long spuId) {
    24. return null;
    25. }
    26. @Override
    27. public List getSpuAttributesBySpuId(Long spuId) {
    28. return null;
    29. }
    30. }

    业务逻辑层实现类先只实现按分类id分页查询的功能即可

    创建FrontSpuController编写调用代码如下

    1. @RestController
    2. @RequestMapping("/front/spu")
    3. @Api(tags = "前台商品spu模块")
    4. public class FrontSpuController {
    5. @Autowired
    6. private IFrontProductService frontProductService;
    7. // localhost:10004/front/spu/list/3
    8. @GetMapping("/list/{categoryId}")
    9. @ApiOperation("根据分类id分页查询spu列表")
    10. @ApiImplicitParams({
    11. @ApiImplicitParam(value = "分类id",name="categoryId",example = "3",
    12. required = true,dataType = "long"),
    13. @ApiImplicitParam(value = "页码",name="page",example = "1",
    14. required = true,dataType = "int"),
    15. @ApiImplicitParam(value = "每页条数",name="pageSize",example = "2",
    16. required = true,dataType = "int")
    17. })
    18. public JsonResult> listSpuByPage(
    19. @PathVariable Long categoryId, Integer page,Integer pageSize){
    20. JsonPage jsonPage=
    21. frontProductService.listSpuByCategoryId(categoryId,page,pageSize);
    22. return JsonResult.ok(jsonPage);
    23. }
    24. }

    然后在Nacos\Seata\Redis启动的前提下

    顺序启动Product\Front

    进行测试

    http://localhost:10004/doc.html

    1.2实现查询商品详情页

    上面章节完成了查询spu列表

    在商品列表中选中商品后,会显示这个商品的详情信息

    商品详情页我们需要显示的信息包括

    • 根据spuId查询spu信息
    • 根据spuId查询spuDetail详情
    • 根据spuId查询当前Spu包含的所有属性
    • 根据spuId查询对应的sku列表

    继续编写FrontProductServiceImpl其他没有实现的方法

    1. @Service
    2. @Slf4j
    3. public class FrontProductServiceImpl implements IFrontProductService {
    4. @DubboReference
    5. private IForFront
  • 相关阅读:
    服务器中了locked勒索病毒怎么处理,locked勒索病毒解密,数据恢复
    互联网摸鱼日报(2022-11-25)
    MySQL的备份恢复
    Wi-Fi显示无IP分配是什么意思?编程
    Jquery学习笔记
    数据结构-学习-01-线性表之顺序表-初始化、销毁、清理、获取长度、判断为空、获取元素等实现
    开发deepstram的自定义插件,使用gst-dseaxmple插件进行扩充,实现deepstream图像输出前的预处理,实现图像自定义绘制图(精四)
    进程环境~
    信息学奥赛一本通:1129:统计数字字符个数
    红细胞膜包裹PLGA纳米颗粒/荧光染料标记细胞膜仿生介孔二氧化硅/载量子点细胞膜的制备
  • 原文地址:https://blog.csdn.net/TheNewSystrm/article/details/126610641