第81集 查询分组未关联的属性
就是一个业务逻辑,了解即可。
@Override
public PageUtils getNoRelationAttr(Map<String, Object> params, Long attrgroupId) {
//1、当前分组只能关联自己所属的分类里面的所有属性
AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attrgroupId);
Long catelogId = attrGroupEntity.getCatelogId();
//2、当前分组只能关联别的分组没有引用的属性
//2.1)、当前分类下的其他分组
List<AttrGroupEntity> group = attrGroupDao.selectList(new QueryWrapper<AttrGroupEntity>().eq("catelog_id", catelogId));
List<Long> collect = group.stream().map(item -> {
return item.getAttrGroupId();
}).collect(Collectors.toList());
//2.2)、这些分组关联的属性
List<AttrAttrgroupRelationEntity> groupId = relationDao.selectList(new QueryWrapper<AttrAttrgroupRelationEntity>().in("attr_group_id", collect));
List<Long> attrIds = groupId.stream().map(item -> {
return item.getAttrId();
}).collect(Collectors.toList());
//2.3)、从当前分类的所有属性中移除这些属性;
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<AttrEntity>().eq("catelog_id", catelogId).eq("attr_type",ProductConstant.AttrEnum.ATTR_TYPE_BASE.getCode());
if(attrIds!=null && attrIds.size()>0){
wrapper.notIn("attr_id", attrIds);
}
String key = (String) params.get("key");
if(!StringUtils.isEmpty(key)){
wrapper.and((w)->{
w.eq("attr_id",key).or().like("attr_name",key);
return w;
});
}
IPage<AttrEntity> page = this.page(new Query<AttrEntity>().getPage(params), wrapper);
PageUtils pageUtils = new PageUtils(page);
return pageUtils;
}
第82集 新增分组和属性关联
这个也是编写下业务逻辑代码,过
第83集 会员等级
主要将会员等级页面前端放入项目中,过
第84集 获取分类关联的品牌
1、ControLer:处理请求,接受和校验数据
2、Service接受controLLer传来的数据,进行业务处理
3、ControLLer接受Service处理完的数据,封装页面指定的vd
之后那个java代码编写的挺简单的,主要是一个根据catelog_id查询pms_category_brand_relation这个表,然后同时获取Brand表的信息的一个流程。
这里前端有个报错PubSub is not defined,这个根据评论区的解决方法,成功解决
1、npm install --save pubsub-js
2、在src下的main.js中引用:
① import PubSub from 'pubsub-js'
② Vue.编辑prototype.PubSub = PubSub
第85集 获取分类下所有分组
这个代码也比较简单直接,过
逻辑就是根据三级分类id获取到pms_attr_group这个表的信息,然后再查中间表pms_attr_attrgroup_relation查出attr_id,在根据这个查pms_attr这个表获取到下面的cpu品牌和型号信息
第86集 商品新增Vo抽取
这节主要看下规格参数,销售属性是什么含义。
第87集,主要介绍了如何保存刚才上传的一大堆数据。
(spu相当于mate40,sku相当于每一个不同版本颜色的mate 40)
//1、保存spu基本信息pms_spu_infd//
2、保存spu的描述图片 pms_spu_info_desc//
3、保存spu的图片集pms_spu_images//
4、保存spu的规格参数;pms_product_attr_value//
5、保存spu的积分信息;guLimaLL_sms->sms_spu_bounds//
5、保存当前spu对应的所有sku信息;
5.1)、sku的基本信息;pms_sku_info//
5.2)、sku的图片信息;pms_sku_images//
5.3)、sku的销售属性信息:pms_sku_sale_attr_vaLue//
5.4)、sku的优惠、满减等信息;guLimaLL_sms->sms_sku_Ladder\sms_sku_fuLL_reduction\sns
第88集,第89集 具体写上述代码
就是一些具体的保存代码,没什么亮点,过
第90集 openFeign远程调用
product 的开启feign
@EnableFeignClients
@MapperScan("com.buu.gulimall.product.dao")
public class GulimallProductApplication {
public static void main(String[] args) {
SpringApplication.run(GulimallProductApplication.class, args);
}
}
@FeignClient("gulimall-coupon")
public interface CouponFeignService {
/**
* 1、CouponFeignService.saveSpuBounds(spuBoundTo);
* 1)、@RequestBody将这个对象转为json。
* 2)、找到gulimall-coupon服务,给/coupon/spubounds/save发送请求。
* 将上一步转的json放在请求体位置,发送请求;
* 3)、对方服务收到请求。请求体里有json数据。
* (@RequestBody SpuBoundsEntity spuBounds);将请求体的json转为SpuBoundsEntity;
* 只要json数据模型是兼容的。双方服务无需使用同一个to
* @param spuBoundTo
* @return
*/
@PostMapping("/coupon/spubounds/save")
R saveSpuBounds(@RequestBody SpuBoundTo spuBoundTo);
@PostMapping("/coupon/skufullreduction/saveinfo")
R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
CouponFeignService.saveSpuBounds(spuBoundTo);
1)、@RequestBody将这个对象转为json。
2)、找到guLimaLL-coupon服务,给/coupon/spubounds/save发送请求。将上一步转的json放到请求体位置,发送请求
3)、对方服务收到请求。请求体里有json数据。(@RequestBody SpuBoundsEntity spuBounds);将请求体的json转为SpuBoundsEntity;
4) 、只要json数据模型是兼容的。双方服务无需使用同一个to
第91集 整体内容的测试
总体上诉的代码主要写的内容有:就是把SpuSaveVo的内容,根据各各service层保存到各各数据库中。
老师这节课教了下如何用debug测试我们的代码,且将一些bug进行修改了。
第92集 整体内容的测试
过
第93集 spu的检索
这里用的一个动态SQL的一种表现形式,只不过是后端实现。
动态sql就是根据选择条件的不同,查询的结果也不同。
@Override
public PageUtils ueryPageByCondition(Map<String, Object> params) {
QueryWrapper<SpuInfoEntity> wrapper = new QueryWrapper<>();
String key = (String) params.get("key");
if(!StringUtils.isEmpty(key)){
wrapper.and((w)->{
w.eq("id",key).or().like("spu_name",key);
});
}
// status=1 and (id=1 or spu_name like xxx)
String status = (String) params.get("status");
if(!StringUtils.isEmpty(status)){
wrapper.eq("publish_status",status);
}
String brandId = (String) params.get("brandId");
if(!StringUtils.isEmpty(brandId)&&!"0".equalsIgnoreCase(brandId)){
wrapper.eq("brand_id",brandId);
}
String catelogId = (String) params.get("catelogId");
if(!StringUtils.isEmpty(catelogId)&&!"0".equalsIgnoreCase(catelogId)){
wrapper.eq("catalog_id",catelogId);
}
IPage<SpuInfoEntity> page = this.page(
new Query<SpuInfoEntity>().getPage(params),
wrapper
);
return new PageUtils(page);
}
使用特定时间格式结构
spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
第94集 Sku检索
这个和上一集内容类似,过
第95集 仓库管理
ware_info 仓库表
ware_sku 代表某一个仓库某一件商品保存几件,库存锁定
purchase_detail 采购需求
purchase 采购单
@EnableTransactionManagement
之后开启服务,我这里有个报错,com.alibaba.nacos.api.exception.NacosException: java.lang.reflect.InvocationTargetException,这个是,由于nacos配置地址,没写全导致的。
可以查看SQL语句的配置
logging:
level:
com.atguigu:debug:
其他的内容基本上简单,过。
第96集 查询库存
这节又和之前的多条件查询一致了,过
第97集 采购简要流程
这里主要要合并采购单,实际上就是将这个 wms_purchase_detail的purchase_id和status设置为同一个即可。
第98集
代码逻辑:1、确认当前采购单是新建或者已分配状态 2、改变采购单的状态 3、改变采购项的状态
业务逻辑:合并完采购单,采购人员选择单子进行采购,这个条件就变成
第99集,第100集 完成采购
这两集的都是基础的业务逻辑,没新的内容,过,基础篇完结撒花。