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

本文介绍了在酷鲨商城front模块中开发购物车功能的过程,涉及分类id查询商品列表、商品详情页实现,以及单点登录的解决方案,特别是JWT登录流程。在开发购物车功能时,强调了用户登录状态判断和业务逻辑,包括新增、修改购物车商品的操作。同时回顾了Spring Security和单点登录(SSO)的概念,分析了Session共享和JWT令牌的优缺点。
摘要由CSDN通过智能技术生成

1.开发酷鲨商城front模块

1.1按分类id查询spu列表

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

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

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

并进行分页显示

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

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

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

@Service
@Slf4j
public class FrontProductServiceImpl implements IFrontProductService {

    @DubboReference
    private IForFrontSpuService dubboSpuService;

    @Override
    public JsonPage<SpuListItemVO> listSpuByCategoryId(Long categoryId, Integer page, Integer pageSize) {
        // IForFrontSpuService实现类中已经完成了分页查询的细节,我们直接调用即可
        JsonPage<SpuListItemVO> list=
                dubboSpuService.listSpuByCategoryId(categoryId,page,pageSize);
        // 返回 list!!!
        return list;
    }

    @Override
    public SpuStandardVO getFrontSpuById(Long id) {
        return null;
    }

    @Override
    public List<SkuStandardVO> getFrontSkusBySpuId(Long spuId) {
        return null;
    }

    @Override
    public SpuDetailStandardVO getSpuDetail(Long spuId) {
        return null;
    }

    @Override
    public List<AttributeStandardVO> getSpuAttributesBySpuId(Long spuId) {
        return null;
    }
}

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

创建FrontSpuController编写调用代码如下

@RestController
@RequestMapping("/front/spu")
@Api(tags = "前台商品spu模块")
public class FrontSpuController {
    @Autowired
    private IFrontProductService frontProductService;

    // localhost:10004/front/spu/list/3
    @GetMapping("/list/{categoryId}")
    @ApiOperation("根据分类id分页查询spu列表")
    @ApiImplicitParams({
            @ApiImplicitParam(value = "分类id",name="categoryId",example = "3",
                                required = true,dataType = "long"),
            @ApiImplicitParam(value = "页码",name="page",example = "1",
                    required = true,dataType = "int"),
            @ApiImplicitParam(value = "每页条数",name="pageSize",example = "2",
                    required = true,dataType = "int")
    })
    public JsonResult<JsonPage<SpuListItemVO>> listSpuByPage(
            @PathVariable Long categoryId, Integer page,Integer pageSize){
        JsonPage<SpuListItemVO> jsonPage=
                frontProductService.listSpuByCategoryId(categoryId,page,pageSize);
        return JsonResult.ok(jsonPage);
    }


}

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

顺序启动Product\Front

进行测试

http://localhost:10004/doc.html

1.2实现查询商品详情页

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

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

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

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

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

@Service
@Slf4j
public class FrontProductServiceImpl implements IFrontProductService {

    @DubboReference
    priva
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值