谷粒商城-商品服务-新增商品功能开发(商品图片无法展示问题没有解决)
在网关配置路由
- id: member_routeuri: lb://gulimemberpredicates:- Path=/api/gulimember/**filters:- RewritePath=/api/(?<segment>.*),/$\{segment}
并将所有逆向生成的工程调式出来
获取分类关联的品牌
例如:手机(分类)-> 品牌(华为)
CategoryBrandRelationController.java
@GetMapping("/brands/list")public R relationBrandsList(@RequestParam(value = "catId",required = true)Long catId){List<BrandEntity> vos = categoryBrandRelationService.getBrandsByCatId(catId);List<BrandVo> collect = vos.stream().map(item -> {BrandVo brandVo = new BrandVo();brandVo.setBrandId(item.getBrandId());brandVo.setBrandName(item.getName());return brandVo;}).collect(Collectors.toList());return R.ok().put("data",collect);}
返回信息只需品牌id和品牌名 所以编写一个只包含品牌id和品牌名的Vo
BrandVo
import lombok.Data;@Data
public class BrandVo {/*** "brandId": 0,* "brandName": "string",*/private Long brandId;private String brandName;
}
CategoryBrandRelationServiceImpl.java
/*** 查询指定品牌的分类信息* @param catId* @return*/@Overridepublic List<BrandEntity> getBrandsByCatId(Long catId) {List<CategoryBrandRelationEntity> catelogId = relationDao.selectList(new QueryWrapper<CategoryBrandRelationEntity>().eq("catelog_id", catId));List<BrandEntity> collect = catelogId.stream().map(item -> {Long brandId = item.getBrandId();BrandEntity byId = brandService.getById(brandId);return byId;}).collect(Collectors.toList());return collect;}
P75没完成
P86需要再排查
获取分类下所有分组以及属性
创建 AttrGroupWithAttrsVo.java 整合该类型的结果并返回
@Data
public class AttrGroupWithAttrsVo {/*** 分组id*/private Long attrGroupId;/*** 组名*/private String attrGroupName;/*** 排序*/private Integer sort;/*** 描述*/private String descript;/*** 组图标*/private String icon;/*** 所属分类id*/private Long catelogId;private List<AttrEntity> attrs;
}
AttrGroupServiceImpl.java
/*** 根据分类id查出所有分组以及组里的属性* @param catelogId* @return*/@Overridepublic List<AttrGroupWithAttrsVo> getAttrGroupWithAttrsByCatelogId(Long catelogId) {//1、查询分组信息List<AttrGroupEntity> attrGroupEntities = this.list(new QueryWrapper<AttrGroupEntity>().eq("catelog_id", catelogId));//2、查询所有属性List<AttrGroupWithAttrsVo> collect = attrGroupEntities.stream().map(group -> {AttrGroupWithAttrsVo attrsVo = new AttrGroupWithAttrsVo();BeanUtils.copyProperties(group,attrsVo);//查询属性List<AttrEntity> attrs = attrService.getRelationAttr(attrsVo.getAttrGroupId());attrsVo.setAttrs(attrs);return attrsVo;}).collect(Collectors.toList());return collect;}
商品新增业务流程分析
保存商品vo
SpuInfoController.java
@RequestMapping("/save")public R save(@RequestBody SpuSaveVo vo){spuInfoService.saveSpuInfo(vo);return R.ok();}
SkuInfoServiceImpl.java
//主要保存商品基本的spu和sku信息
public void saveSpuInfo(SpuSaveVo vo) {//1.保存商品基本信息 pms_spu_infoSpuInfoEntity infoEntity=new SpuInfoEntity();BeanUtils.copyProperties(vo,infoEntity);infoEntity.setCreateTime(new Date());infoEntity.setUpdateTime(new Date());this.saveBaseSpuInfo(infoEntity);//2.保存描述 pms_spu_info_descList<String> decript = vo.getDecript();SpuInfoDescEntity descEntity = new SpuInfoDescEntity();descEntity.setSpuId(infoEntity.getId());descEntity.setDecript(String.join(",",decript));spuInfoDescService.saveSpuInfoDesc(descEntity);//3.保存图片集pms_spu_imagesList<String> images=vo.getImages();spuImagesService.saveImages(infoEntity.getId(),images);//4.保存spu规格参数 pms_product_attr_valueList<BaseAttrs> baseAttrs=vo.getBaseAttrs();List<ProductAttrValueEntity> collect=baseAttrs.stream().map(attr->{ProductAttrValueEntity valueEntity=new ProductAttrValueEntity();valueEntity.setAttrId(attr.getAttrId());AttrEntity attrEntity=attrService.getById(attr.getAttrId());valueEntity.setAttrName(attrEntity.getAttrName());valueEntity.setAttrValue(attr.getAttrValues());valueEntity.setQuickShow(attr.getShowDesc());valueEntity.setSpuId(infoEntity.getId());return valueEntity;}).collect(Collectors.toList());productAttrValueService.saveProdutAttr(collect);//5.保存spu的积分信息:gulimall_sms->sms_spu_bounds//5.保存当前spu对应的所有sku信息//5.1 sku基本信息 pms_sku_infoList<Skus> skus = vo.getSkus();if(skus!=null&&skus.size()>0){skus.forEach(item->{//存储默认图片String defaultImg="";for(Images image:item.getImages()){if(image.getDefaultImg()==1){defaultImg=image.getImgUrl();}}SkuInfoEntity skuInfoEntity=new SkuInfoEntity();BeanUtils.copyProperties(item,skuInfoEntity);skuInfoEntity.setBrandId(infoEntity.getBrandId());skuInfoEntity.setCatalogId(infoEntity.getCatalogId());skuInfoEntity.setSaleCount(0L);skuInfoEntity.setSpuId(infoEntity.getId());skuInfoEntity.setSkuDefaultImg(defaultImg);skuInfoService.saveSkuInfo(skuInfoEntity);Long skuId=skuInfoEntity.getSkuId();List<SkuImagesEntity> imagesEntities=item.getImages().stream().map(img->{SkuImagesEntity skuImagesEntity = new SkuImagesEntity();skuImagesEntity.setSkuId(skuId);skuImagesEntity.setImgUrl(img.getImgUrl());skuImagesEntity.setDefaultImg(img.getDefaultImg());return skuImagesEntity;}).collect(Collectors.toList());//5.2 sku图片信息 pms_sku_imagesskuImagesService.saveBatch(imagesEntities);List<Attr> attr= item.getAttr();List<SkuSaleAttrValueEntity> skuSaleAttrValueEntities=attr.stream().map(a->{SkuSaleAttrValueEntity attrValueEntity = new SkuSaleAttrValueEntity();BeanUtils.copyProperties(a,attrValueEntity);attrValueEntity.setSkuId(skuId);return attrValueEntity;}).collect(Collectors.toList());//5.3 sku销售属性信息 pms_sku_sale_attr_valueskuSaleAttrValueService.saveBatch(skuSaleAttrValueEntities);});}//5.4 sku优惠、满减信息:gulimall_sms->sms_sku_ladder\sms_sku_full_reduction\sms_member_price}
调用远程服务保存优惠券信息
使用远程服务
可以调用coupon中对应的服务
CouponFeignService.java
@FeignClient("gulicoupon")
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* @return*/@PostMapping("/gulicoupon/spubounds/save")R saveSpuBounds(@RequestBody SpuBoundTo spuBoundTo);@PostMapping("/gulicoupon/skufullreduction/saveinfo")R saveSkuReduction(@RequestBody SkuReductionTo skuReductionTo);
}
SPU检索

SpuInfoController.java
@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params){PageUtils page = spuInfoService.queryPageByCondition(params);return R.ok().put("page", page);}
SpuInfoServiceImpl.java
@Overridepublic PageUtils queryPageByCondition(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);}/*** status: 2* key:* brandId: 9* catelogId: 225*/IPage<SpuInfoEntity> page = this.page(new Query<SpuInfoEntity>().getPage(params),wrapper);return new PageUtils(page);}
SKU检索
SkuInfoController.java
@RequestMapping("/list")public R list(@RequestParam Map<String, Object> params){PageUtils page = skuInfoService.queryPageByCondition(params);return R.ok().put("page", page);}
SkuInfoServiceImpl.java
@Overridepublic PageUtils queryPageByCondition(Map<String, Object> params) {QueryWrapper<SkuInfoEntity> queryWrapper = new QueryWrapper<>();/*** key:* catelogId: 0* brandId: 0* 价格区间* min: 0* max: 0*/String key = (String) params.get("key");if(!StringUtils.isEmpty(key)){queryWrapper.and((wrapper)->{wrapper.eq("sku_id",key).or().like("sku_name",key);});}String catelogId = (String) params.get("catelogId");if(!StringUtils.isEmpty(catelogId)&&!"0".equalsIgnoreCase(catelogId)){queryWrapper.eq("catalog_id",catelogId);}String brandId = (String) params.get("brandId");if(!StringUtils.isEmpty(brandId)&&!"0".equalsIgnoreCase(catelogId)){queryWrapper.eq("brand_id",brandId);}String min = (String) params.get("min");if(!StringUtils.isEmpty(min)){queryWrapper.ge("price",min);}String max = (String) params.get("max");if(!StringUtils.isEmpty(max) ){try{BigDecimal bigDecimal = new BigDecimal(max);if(bigDecimal.compareTo(new BigDecimal("0"))==1){queryWrapper.le("price",max);}}catch (Exception e){}}IPage<SkuInfoEntity> page = this.page(new Query<SkuInfoEntity>().getPage(params),queryWrapper);return new PageUtils(page);}
商品管理-SPU规格维护(暂未解决)
相关文章:
谷粒商城-商品服务-新增商品功能开发(商品图片无法展示问题没有解决)
在网关配置路由 - id: member_routeuri: lb://gulimemberpredicates:- Path/api/gulimember/**filters:- RewritePath/api/(?<segment>.*),/$\{segment}并将所有逆向生成的工程调式出来 获取分类关联的品牌 例如:手机(分类)-> 品…...
Open3D 点云数据处理基础(Python版)
Open3D 点云数据处理基础(Python版) 文章目录 1 概述 2 安装 2.1 PyCharm 与 Python 安装 2.3 Anaconda 安装 2.4 Open3D 0.13.0 安装 2.5 新建一个 Python 项目 3 点云读写 4 点云可视化 2.1 可视化单个点云 2.2 同一窗口可视化多个点云 2.3…...
使用vue-qr,报错in ./node_modules/vue-qr/dist/vue-qr.js
找到node_modules—>vue-qr/dist/vue-qr.js文件,搜…e,将…去掉,然后重新运行项目。...
百川2大模型微调问题解决
之前用https://github.com/FlagAlpha/Llama2-Chinese微调过几个模型,总体来说llama2的生态还是比较好的,过程很顺利。微调百川2就没那么顺利了,所以简单做个记录 1. 数据准备,我的数据是单轮对话,之前微调llama2已经按…...
MySQL的事务-原子性
MySQL的事务处理具有ACID的特性,即原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)和持久性(Durability)。 1. 原子性指的是事务中所有操作都是原子性的,要…...
D3839|完全背包
完全背包: 首先01背包的滚动数组中的解法是内嵌的循环是从大到小遍历,为了保证每个物品仅被添加一次。 for(int i 0; i < weight.size(); i) { // 遍历物品for(int j bagWeight; j > weight[i]; j--) { // 遍历背包容量dp[j] max(dp[j], dp[j…...
Java之Synchronized与锁升级
Synchronized与锁升级 一、概述 在多线程并发编程中 synchronized 一直是元老级角色,很多人都会称呼它为重量级锁。但是,随着 Java SE 1.6 对 synchronized 进行了各种优化之后,有些情况下它就并不那么重了。 本文详细介绍 Java SE 1.6 中为…...
kitex出现:open conf/test/conf.yaml: no such file or directory
open conf/test/conf.yaml: no such file or directory https://github.com/cloudwego/cwgo/issues/120 https://github.com/cloudwego/cwgo/issues/29 在使用Kitex生成的代码中,单元测试时回报错,如标题所示。出现该错的原因是,biz/servic…...
sql server多表查询
查询目标 现在有学生表和学生选课信息表,stu和stuSelect,stu中包含学生用户名、名字,stuSelect表中包含学生用户名,所选课程名 学生表: nameusername李明Li Ming李华Li Hua 学生选课表: usernameCourse…...
如何利用PPT绘图并导出清晰图片
在写论文的过程中,免不了需要绘图,但是visio等软件绘图没有在ppt上绘图比较熟练,尤其流程图结构图. 但是ppt导出的图片也不够清晰,默认分辨率是96dpi,而杂志投稿一般要求至300dpi。解决办法如下: 1.打开注…...
1.倒排索引 2.逻辑斯提回归算法
1.倒排索引 https://help.aliyun.com/zh/open-search/retrieval-engine-edition/introduction-to-inverted-indexes 倒排索引(Inverted Index)是一种数据结构,用于快速查找包含某个特定词或词语的文档。它主要用于全文搜索引擎等应用&#…...
Kafka消费者组
消费者总体工作流程 Consumer Group(CG):消费者组,由多个consumer组成。形成一个消费者组的条件,是所有消费者的groupid相同。 • 消费者组内每个消费者负责消费不同分区的数据,一个分区只能由一个组内消费…...
四. 基于环视Camera的BEV感知算法-BEVDepth
目录 前言0. 简述1. 算法动机&开创性思路2. 主体结构3. 损失函数4. 性能对比总结下载链接参考 前言 自动驾驶之心推出的《国内首个BVE感知全栈系列学习教程》,链接。记录下个人学习笔记,仅供自己参考 本次课程我们来学习下课程第四章——基于环视Cam…...
CentOS系统环境搭建(二十五)——使用docker compose安装mysql
centos系统环境搭建专栏🔗点击跳转 文章目录 使用docker compose安装mysqlMySQL81.新建文件夹2.创建docker-compose.yaml3.创建my.cnf4.mysql容器的启动和关闭 MySQL5.71.新建文件夹2.创建docker-compose.yaml3.创建my.cnf4.mysql容器的启动和关闭 使用docker comp…...
协作机器人(Collaborative-Robot)安全碰撞的速度与接触力
协作机器人(Collaborative-Robot)的安全碰撞速度和接触力是一个非常重要的安全指标。在设计和使用协作机器人时,必须确保其与人类或其他物体的碰撞不会对人员造成伤害。 对于协作机器人的安全碰撞速度,一般会设定一个上限值&…...
第11章 GUI Page400~402 步骤二 画直线
运行效果: 源代码: /**************************************************************** Name: wxMyPainterApp.h* Purpose: Defines Application Class* Author: yanzhenxi (3065598272qq.com)* Created: 2023-12-21* Copyright: yanzhen…...
华为gre隧道全部跑静态路由
最终实现: 1、pc1能用nat上网ping能pc3 2、pc1能通过gre访问pc2 3、全部用静态路由做,没有用ospf,如果要用ospf,那么两边除了路由器上跑ospf,核心交换机也得用ospf r2配置: acl number 3000 rule 5 deny…...
【c++】入门1
c关键字 命名空间 在C/C中,变量、函数和后面要学到的类都是大量存在的,这些变量、函数和类的名称将都存在于全局作用域中,可能会导致很多冲突。使用命名空间的目的是对标识符的名称进行本地化,以避免命名冲突或名字污染ÿ…...
Python之Django项目的功能配置
1.创建Django项目 进入项目管理目录,比如:D盘 执行命令:diango-admin startproject demo1 创建项目 如果提示diango命令不存在,搜索diango-admin程序的位置,然后加入到环境变量path中。 进入项目,cd demo…...
P4 音频知识点——PCM音频原始数据
目录 前言 01 PCM音频原始数据 1.1 频率 1.2 振幅: 1.3 比特率 1.4 采样 1.5 量化 1.6 编码 02. PCM数据有以下重要的参数: 采样率: 采集深度 通道数 PCM比特率 PCM文件大小计算: …...
Chapter03-Authentication vulnerabilities
文章目录 1. 身份验证简介1.1 What is authentication1.2 difference between authentication and authorization1.3 身份验证机制失效的原因1.4 身份验证机制失效的影响 2. 基于登录功能的漏洞2.1 密码爆破2.2 用户名枚举2.3 有缺陷的暴力破解防护2.3.1 如果用户登录尝试失败次…...
AI Agent与Agentic AI:原理、应用、挑战与未来展望
文章目录 一、引言二、AI Agent与Agentic AI的兴起2.1 技术契机与生态成熟2.2 Agent的定义与特征2.3 Agent的发展历程 三、AI Agent的核心技术栈解密3.1 感知模块代码示例:使用Python和OpenCV进行图像识别 3.2 认知与决策模块代码示例:使用OpenAI GPT-3进…...
3.3.1_1 检错编码(奇偶校验码)
从这节课开始,我们会探讨数据链路层的差错控制功能,差错控制功能的主要目标是要发现并且解决一个帧内部的位错误,我们需要使用特殊的编码技术去发现帧内部的位错误,当我们发现位错误之后,通常来说有两种解决方案。第一…...
深入浅出:JavaScript 中的 `window.crypto.getRandomValues()` 方法
深入浅出:JavaScript 中的 window.crypto.getRandomValues() 方法 在现代 Web 开发中,随机数的生成看似简单,却隐藏着许多玄机。无论是生成密码、加密密钥,还是创建安全令牌,随机数的质量直接关系到系统的安全性。Jav…...
postgresql|数据库|只读用户的创建和删除(备忘)
CREATE USER read_only WITH PASSWORD 密码 -- 连接到xxx数据库 \c xxx -- 授予对xxx数据库的只读权限 GRANT CONNECT ON DATABASE xxx TO read_only; GRANT USAGE ON SCHEMA public TO read_only; GRANT SELECT ON ALL TABLES IN SCHEMA public TO read_only; GRANT EXECUTE O…...
第25节 Node.js 断言测试
Node.js的assert模块主要用于编写程序的单元测试时使用,通过断言可以提早发现和排查出错误。 稳定性: 5 - 锁定 这个模块可用于应用的单元测试,通过 require(assert) 可以使用这个模块。 assert.fail(actual, expected, message, operator) 使用参数…...
苍穹外卖--缓存菜品
1.问题说明 用户端小程序展示的菜品数据都是通过查询数据库获得,如果用户端访问量比较大,数据库访问压力随之增大 2.实现思路 通过Redis来缓存菜品数据,减少数据库查询操作。 缓存逻辑分析: ①每个分类下的菜品保持一份缓存数据…...
Java-41 深入浅出 Spring - 声明式事务的支持 事务配置 XML模式 XML+注解模式
点一下关注吧!!!非常感谢!!持续更新!!! 🚀 AI篇持续更新中!(长期更新) 目前2025年06月05日更新到: AI炼丹日志-28 - Aud…...
论文浅尝 | 基于判别指令微调生成式大语言模型的知识图谱补全方法(ISWC2024)
笔记整理:刘治强,浙江大学硕士生,研究方向为知识图谱表示学习,大语言模型 论文链接:http://arxiv.org/abs/2407.16127 发表会议:ISWC 2024 1. 动机 传统的知识图谱补全(KGC)模型通过…...
在web-view 加载的本地及远程HTML中调用uniapp的API及网页和vue页面是如何通讯的?
uni-app 中 Web-view 与 Vue 页面的通讯机制详解 一、Web-view 简介 Web-view 是 uni-app 提供的一个重要组件,用于在原生应用中加载 HTML 页面: 支持加载本地 HTML 文件支持加载远程 HTML 页面实现 Web 与原生的双向通讯可用于嵌入第三方网页或 H5 应…...
