谷粒商城-商品服务-新增商品功能开发(商品图片无法展示问题没有解决)

在网关配置路由

        - 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);}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/241559.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

前端性能优化二十一:静态文件打包方案

1. 打包方案落地: ①. 公共组件拆分:a. 业务中有N个js文件,把公用的js文件抽离出来,做成组件.b. 其它文件直接调用这个组件即可.c. 在用户访问时,js文件的大小是比较少的.d. 公用部分在其它页面也不用再加载,直接走cdn文件的缓存即可.②. 压缩:JS、CSS、图片③. 合并:a. 一个业…

Python算法例26 落单的数Ⅳ

1. 问题描述 给定数组&#xff0c;除了一个数出现一次外&#xff0c;所有数都出现两次&#xff0c;并且所有出现两次的数都挨着&#xff0c;找出出现一次的数。 2. 问题示例 给出nums[3&#xff0c;3&#xff0c;2&#xff0c;2&#xff0c;4&#xff0c;5&#xff0c;5]&am…

springboot(ssm校园资产管理系统 高校财务管理系统Java系统

springboot(ssm校园资产管理系统 高校财务管理系统Java系统 开发语言&#xff1a;Java 框架&#xff1a;ssm/springboot vue JDK版本&#xff1a;JDK1.8&#xff08;或11&#xff09; 服务器&#xff1a;tomcat 数据库&#xff1a;mysql 5.7&#xff08;或8.0&#xff09;…

sql server多表查询

查询目标 现在有学生表和学生选课信息表&#xff0c;stu和stuSelect&#xff0c;stu中包含学生用户名、名字&#xff0c;stuSelect表中包含学生用户名&#xff0c;所选课程名 学生表&#xff1a; nameusername李明Li Ming李华Li Hua 学生选课表&#xff1a; usernameCourse…

ZooKeeper 使用介绍和原理详解

目录 1. 介绍 重要性 应用场景 2. ZooKeeper 架构 服务角色 数据模型 工作原理 3. 安装和配置 下载 ZooKeeper 安装和配置 启动 ZooKeeper 验证和管理 停止和关闭 4. ZooKeeper 数据模型 数据结构和层次命名空间&#xff1a; 节点类型和 Watcher 机制&#xff…

基于python的excel检查和读写软件

软件版本&#xff1a;python3.6 窗口和界面gui代码&#xff1a; class mygui:def _init_(self):passdef run(self):root Tkinter.Tk()root.title(ExcelRun)max_w, max_h root.maxsize()root.geometry(f500x500{int((max_w - 500) / 2)}{int((max_h - 300) / 2)}) # 居中显示…

每日一题(LeetCode)----栈和队列--滑动窗口最大值

每日一题(LeetCode)----栈和队列–滑动窗口最大值 1.题目&#xff08;239. 滑动窗口最大值&#xff09; 给你一个整数数组 nums&#xff0c;有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧。你只可以看到在滑动窗口内的 k 个数字。滑动窗口每次只向右移动一位。 …

【MySQL】MySQL的数据类型

MySQL的数据类型 一、数据类型分类二、数值类型1、整数类型2、bit类型3、小数类型 三、字符串类型四、时间日期类型五、enum和set类型enum和set查找 数据类型的作用&#xff1a; 决定了存储数据时应该开辟的空间大小和数据的取值范围。决定了如何识别一个特定的二进制序列。 …

AI创作系统ChatGPT系统源码,支持Midjourney绘画,GPT语音对话+DALL-E3文生图

一、前言 SparkAi创作系统是基于ChatGPT进行开发的Ai智能问答系统和Midjourney绘画系统&#xff0c;支持OpenAI-GPT全模型国内AI全模型。本期针对源码系统整体测试下来非常完美&#xff0c;可以说SparkAi是目前国内一款的ChatGPT对接OpenAI软件系统。那么如何搭建部署AI创作Ch…

R语言基础 | 安徽某高校《统计建模与R软件》期末复习

第一节 数字、字符与向量 1.1 向量的赋值 c<-(1,2,3,4,5) 1.2 向量的运算 对于向量&#xff0c;我们可以直接对其作加&#xff08;&#xff09;&#xff0c;减&#xff08;-&#xff09;&#xff0c;乘&#xff08;*&#xff09;&#xff0c;除&#xff08;/&#xff09…

[网络安全] 端口号 持续更新中.......

netstat -an 查看所有端口号 常见端口: FTP(文件传输协议) : 20数据, 21(控制) SSH (远程连接服务) :22 telnet(远程登录): 23 SMTP (简单邮件传输服务) : 25 DNS (域名系统): 53 DHCP (动态主机配置协议) : 67服务器 ,68客户机 TFTP(小文件传输协议): 69 HTTP(…

【shell脚本实战学习笔记】#1

shell脚本实战学习笔记#1 脚本编写场景需求&#xff1a; 编写一个比较数据大小的shell脚本&#xff0c;要求判断用户只能输入两位数字&#xff0c;不能是字符或其他特殊字符&#xff1b;并且在shell脚本中需要用到函数来控制执行顺序。 知识点&#xff1a;shell函数&#xff…

Semaphone应用源码分析(二)

3.3.3 Semaphore公平实现 公平与非公平只是差了一个方法的实现tryAcquireShared实现 这个方法的实现中&#xff0c;如果是公平实现&#xff0c;需要先查看AQS中排队的情况 // 信号量公平实现 protected int tryAcquireShared(int acquires) { // 死循环。 for (;;) { // 公平…

paddle 55 使用Paddle Inference部署嵌入nms的PPYoloe模型(端到端fps达到52.63)

Paddle Inference 是飞桨的原生推理库,提供服务器端的高性能推理能力。由于 Paddle Inference 能力直接基于飞桨的训练算子,因此它支持飞桨训练出的所有模型的推理。paddle平台训练出的模型转换为静态图时可以选用Paddle Inference的框架进行推理,博主以前都是将静态图转换为…

科研学习|论文解读——面向电商内容安全风险管控的协同过滤推荐算法研究

【论文完整内容详见知网链接】&#xff1a; 面向电商内容安全风险管控的协同过滤推荐算法研究 - 中国知网 (cnki.net) 面向电商内容安全风险管控的协同过滤推荐算法研究* 摘 要&#xff1a;[目的/意义]随着电商平台商家入驻要求降低以及商品上线审核流程简化&#xff0c;内容安…

Centos安装vsftpd:centos配置vsftpd,ftp报200和227错误

一、centos下载安装vsftpd&#xff08;root权限&#xff09; 1、下载安装 yum -y install vsftpd 2、vsftpd的配置文件 /etc/vsftpd.conf 3、备份原来的配置文件 sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.backup 4、修改配置文件如下&#xff1a;vi /etc/vsftpd.conf …

go从0到1项目实战体系十三:全局/局部变量

1. 全局/局部变量: ①. 全局变量:a. C和Go语言中,定义在函数外面的就是全局变量.②. 局部变量:a. C和Go语言中,写在{}中、函数中、函数的形参,就是局部变量.b. 只能在{}里面有效.2. 作用域: ①. 全局变量:a. C语言中,全局变量的作用域是从定义的那一行开始,直到文件末尾为止.…

体验一下 CodeGPT 插件

体验一下 CodeGPT 插件 0. 背景1. CodeGPT 插件安装2. CodeGPT 插件基本配置3. (可选)CodeGPT 插件预制提示词原始配置(英文)4. CodeGPT 插件预制提示词配置(中文)5. 简单验证一下 0. 背景 看到B站Up主 “wwwzhouhui” 一个关于 CodeGPT 的视频&#xff0c;感觉挺有意思&#…

SpringMVC:整合 SSM 中篇

文章目录 SpringMVC - 04整合 SSM 中篇一、优化二、总结三、说明注意&#xff1a; SpringMVC - 04 整合 SSM 中篇 一、优化 在 spring-dao.xml 中配置 dao 接口扫描&#xff0c;可以动态地实现 dao 接口注入到 Spring 容器中。 优化前&#xff1a;手动创建 SqlSessionTempl…

HarmonyOS和OpenHarmony的区别

1.概要 众所周知&#xff0c;鸿蒙是华为开发的一款分布式操作系统。因为开发系统&#xff0c;最重要的是集思广益&#xff0c;大家共同维护。为了在IOS和Android之间生存&#xff0c;鸿蒙的茁壮成长一定是需要开源&#xff0c;各方助力才能实现。   在这种思想上&#xff0c;…