2-2 SPU和SKU详解及MyBatisPlus自动生成

本文详细介绍了云商城后台系统中SPU(Standard Product Unit)和SKU(Stock Keeping Unit)的概念,并展示了如何使用MyBatisPlus进行数据操作。内容包括分类、品牌和属性的加载,商品发布过程中的Sku和Spu管理,以及MyBatisPlus的代码生成配置,旨在提升开发效率。
摘要由CSDN通过智能技术生成

private Integer status;

}

/*****

  • @Author: 波波

  • @Description: 云商城

****/

@Data

@A

《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》

【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享

llArgsConstructor

@NoArgsConstructor

//MyBatisPlus表映射注解

@TableName(value = “sku_attribute”)

public class SkuAttribute implements Serializable {

@TableId(type = IdType.AUTO)

private Integer id;

private String name;

private String options;

private Integer sort;

//对应分类

@TableField(exist = false)

private List categories;

}

@Data

@AllArgsConstructor

@NoArgsConstructor

//MyBatisPlus表映射注解

@TableName(value = “spu”)

public class Spu {

@TableId(type = IdType.ASSIGN_ID)

private String id;

private String name;

private String intro;

private Integer brandId;

private Integer categoryOneId;

private Integer categoryTwoId;

private Integer categoryThreeId;

private String images;

private String afterSalesService;

private String content;

private String attributeList;

private Integer isMarketable;

private Integer isDelete;

private Integer status;

}

3.1 分类加载

分类功能需要实现按照父ID查询,最开始初始化加载的是顶级父类,parent_id=0,后面每次点击的时候都根据传入的id查询子分类。

1)Mapper

创建com.bobo.vip.mall.goods.mapper.CategoryMapper,代码如下:

public interface CategoryMapper extends BaseMapper {

}

2)Service

接口:com.bobo.vip.mall.goods.service.CategoryService代码如下:

public interface CategoryService extends IService {

/**

  • 根据父ID查询子分类

  • @param pid

  • @return

*/

List queryByParentId(Integer pid);

}

实现类:com.bobo.vip.mall.goods.service.impl.CategoryServiceImpl代码如下:

@Service

public class CategoryServiceImpl extends ServiceImpl<CategoryMapper,Category> implements CategoryService {

@Autowired

private CategoryMapper categoryMapper;

/***

  • 根据父ID查询子分类

  • @param pid

  • @return

*/

@Override

public List queryByParentId(Integer pid) {

//条件封装

QueryWrapper queryWrapper = new QueryWrapper();

queryWrapper.eq

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值