Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
4f50845b
提交
4f50845b
authored
10月 07, 2021
作者:
zhuyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. ProductSPU 迁移springcloud.
2. 调用方manager通过feign调用spu api
上级
c50f99e7
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
223 行增加
和
193 行删除
+223
-193
ManagementWebApplication.java
.../iocoder/mall/managementweb/ManagementWebApplication.java
+1
-1
ProductSpuController.http
...anagementweb/controller/product/ProductSpuController.http
+14
-8
ProductSpuFeign.java
.../cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java
+0
-20
ProductSpuManager.java
...mall/managementweb/manager/product/ProductSpuManager.java
+5
-9
ProductRecommendManager.java
.../manager/promotion/recommend/ProductRecommendManager.java
+5
-5
ProductSpuFeign.java
.../iocoder/mall/productservice/rpc/spu/ProductSpuFeign.java
+77
-0
ProductSpuRpc.java
...cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java
+0
-65
ProductSpuController.http
.../mall/productservice/controller/ProductSpuController.http
+9
-0
ProductSpuController.java
.../mall/productservice/controller/ProductSpuController.java
+58
-27
SpuController.java
...iocoder/mall/productservice/controller/SpuController.java
+0
-31
pom.xml
promotion-service-project/promotion-service-app/pom.xml
+4
-0
PromotionServiceApplication.java
...er/mall/promotionservice/PromotionServiceApplication.java
+4
-0
PriceManager.java
...der/mall/promotionservice/manager/price/PriceManager.java
+7
-5
ProductRecommendManager.java
...ionservice/manager/recommend/ProductRecommendManager.java
+4
-5
pom.xml
search-service-project/search-service-app/pom.xml
+4
-0
SearchServiceApplication.java
.../iocoder/mall/searchservice/SearchServiceApplication.java
+4
-0
SearchProductManager.java
...l/searchservice/manager/product/SearchProductManager.java
+6
-5
pom.xml
shop-web-app/pom.xml
+4
-1
ShopWebApplication.java
...main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java
+4
-0
ProductSpuController.http
...mall/shopweb/controller/product/ProductSpuController.http
+3
-3
ProductSpuManager.java
...coder/mall/shopweb/service/product/ProductSpuManager.java
+5
-4
ProductRecommendManager.java
...ll/shopweb/service/promotion/ProductRecommendManager.java
+5
-4
没有找到文件。
management-web-app/src/main/java/cn/iocoder/mall/managementweb/ManagementWebApplication.java
浏览文件 @
4f50845b
...
...
@@ -7,7 +7,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
@EnableFeignClients
(
basePackages
=
{
"cn.iocoder.mall.productservice.rpc.spu"
})
public
class
ManagementWebApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
management-web-app/src/main/java/cn/iocoder/mall/managementweb/controller/product/ProductSpuController.http
浏览文件 @
4f50845b
### /product-spu/page 成功(全部)
GET
{{baseUrl}}/product-spu/page?pageNo=1&pageSize=1
0
GET
http://127.0.0.1:18083/management-api/product-spu/page?pageNo=1&pageSize=10
0
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer
{{accessToken}}
Authorization: Bearer
yudaoyuanma
### /product-spu/page 成功(有库存 + 上架)
GET {{baseUrl}}/product-spu/page?pageNo=1&pageSize=10&hasQuantity=true&visible=true
...
...
@@ -14,11 +14,11 @@ Content-Type: application/x-www-form-urlencoded
Authorization: Bearer {{accessToken}}
### /product-spu/create 成功
POST
{{baseUrl}}
/product-spu/create
POST
http://127.0.0.1:18083/management-api
/product-spu/create
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer
{{accessToken}}
Authorization: Bearer
yudaoyuanma
name=
测试商品标题&description=测试
商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
name=
新商品&description=新
商品描述&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
&skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,3
&skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=2,4
...
...
@@ -40,11 +40,11 @@ name=测试商品标题&description=测试商品描述&cid=637&sellPoint=丑&pic
&skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=1,2,4
### /product-spu/update 成功
POST
{{baseUrl}}
/product-spu/update
POST
http://127.0.0.1:18083/management-api
/product-spu/update
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer
{{accessToken}}
Authorization: Bearer
yudaoyuanma
id=
59&name=测试商品标题&description=测试商品描述
&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
id=
64&name=新商品测试&description=新商品测试
&cid=637&sellPoint=丑&picUrls=1,2,3&visible=true
&skus[0].price=1&skus[0].quantity=100&skus[0].attrValueIds=1,3
&skus[1].price=2&skus[1].quantity=50&skus[1].attrValueIds=2,4
...
...
@@ -57,3 +57,9 @@ Authorization:Bearer yudaoyuanma
###
### /product-spu/get
GET http://127.0.0.1:18083/management-api/product-spu/list?productSpuIds=32,33,34
Content-Type: application/x-www-form-urlencoded
Authorization:Bearer yudaoyuanma
###
management-web-app/src/main/java/cn/iocoder/mall/managementweb/feign/ProductSpuFeign.java
deleted
100644 → 0
浏览文件 @
c50f99e7
package
cn
.
iocoder
.
mall
.
managementweb
.
feign
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
@FeignClient
(
value
=
"product-service"
)
public
interface
ProductSpuFeign
{
/**
* 获得商品 SPU
*
* @param productSpuId 商品 SPU 编号
* @return 商品 SPU
*/
@GetMapping
(
value
=
"/product/spu/get"
)
CommonResult
<
ProductSpuRespDTO
>
getProductSpu
(
@RequestParam
(
"productSpuId"
)
Integer
productSpuId
);
}
management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/product/ProductSpuManager.java
浏览文件 @
4f50845b
...
...
@@ -7,10 +7,8 @@ import cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuPageReq
import
cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuRespVO
;
import
cn.iocoder.mall.managementweb.controller.product.vo.spu.ProductSpuUpdateReqVO
;
import
cn.iocoder.mall.managementweb.convert.product.ProductSpuConvert
;
import
cn.iocoder.mall.managementweb.feign.ProductSpuFeign
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpuRpc
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpuFeign
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO
;
import
org.apache.dubbo.config.annotation.DubboReference
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -22,8 +20,6 @@ import java.util.List;
@Service
public
class
ProductSpuManager
{
@DubboReference
(
version
=
"${dubbo.consumer.ProductSpuRpc.version}"
)
private
ProductSpuRpc
productSpuRpc
;
@Autowired
private
ProductSpuFeign
productSpuFeign
;
...
...
@@ -35,7 +31,7 @@ public class ProductSpuManager {
* @return 商品 SPU
*/
public
Integer
createProductSpu
(
ProductSpuCreateReqVO
createVO
)
{
CommonResult
<
Integer
>
createProductSpuResult
=
productSpu
Rpc
.
createProductSpu
(
ProductSpuConvert
.
INSTANCE
.
convert
(
createVO
));
CommonResult
<
Integer
>
createProductSpuResult
=
productSpu
Feign
.
createProductSpu
(
ProductSpuConvert
.
INSTANCE
.
convert
(
createVO
));
createProductSpuResult
.
checkError
();
return
createProductSpuResult
.
getData
();
}
...
...
@@ -46,7 +42,7 @@ public class ProductSpuManager {
* @param updateVO 更新商品 SPU VO
*/
public
void
updateProductSpu
(
ProductSpuUpdateReqVO
updateVO
)
{
CommonResult
<
Boolean
>
updateProductSpuResult
=
productSpu
Rpc
.
updateProductSpu
(
ProductSpuConvert
.
INSTANCE
.
convert
(
updateVO
));
CommonResult
<
Boolean
>
updateProductSpuResult
=
productSpu
Feign
.
updateProductSpu
(
ProductSpuConvert
.
INSTANCE
.
convert
(
updateVO
));
updateProductSpuResult
.
checkError
();
}
...
...
@@ -69,7 +65,7 @@ public class ProductSpuManager {
* @return 商品 SPU列表
*/
public
List
<
ProductSpuRespVO
>
listProductSpus
(
List
<
Integer
>
productSpuIds
)
{
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpuResult
=
productSpu
Rpc
.
listProductSpus
(
productSpuIds
);
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpuResult
=
productSpu
Feign
.
listProductSpus
(
productSpuIds
);
listProductSpuResult
.
checkError
();
return
ProductSpuConvert
.
INSTANCE
.
convertList
(
listProductSpuResult
.
getData
());
}
...
...
@@ -81,7 +77,7 @@ public class ProductSpuManager {
* @return 商品 SPU分页结果
*/
public
PageResult
<
ProductSpuRespVO
>
pageProductSpu
(
ProductSpuPageReqVO
pageVO
)
{
CommonResult
<
PageResult
<
ProductSpuRespDTO
>>
pageProductSpuResult
=
productSpu
Rpc
.
pageProductSpu
(
ProductSpuConvert
.
INSTANCE
.
convert
(
pageVO
));
CommonResult
<
PageResult
<
ProductSpuRespDTO
>>
pageProductSpuResult
=
productSpu
Feign
.
pageProductSpu
(
ProductSpuConvert
.
INSTANCE
.
convert
(
pageVO
));
pageProductSpuResult
.
checkError
();
return
ProductSpuConvert
.
INSTANCE
.
convertPage
(
pageProductSpuResult
.
getData
());
}
...
...
management-web-app/src/main/java/cn/iocoder/mall/managementweb/manager/promotion/recommend/ProductRecommendManager.java
浏览文件 @
4f50845b
...
...
@@ -8,11 +8,12 @@ import cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRe
import
cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendPageReqVO
;
import
cn.iocoder.mall.managementweb.controller.promotion.recommend.vo.ProductRecommendUpdateReqVO
;
import
cn.iocoder.mall.managementweb.convert.promotion.ProductRecommendConvert
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Rpc
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Feign
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO
;
import
cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc
;
import
cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendRespDTO
;
import
org.apache.dubbo.config.annotation.DubboReference
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -28,9 +29,8 @@ public class ProductRecommendManager {
@DubboReference
(
version
=
"${dubbo.consumer.ProductRecommendRpc.version}"
)
private
ProductRecommendRpc
productRecommendRpc
;
@DubboReference
(
version
=
"${dubbo.consumer.ProductSpuRpc.version}"
)
private
ProductSpuRpc
productSpuRpc
;
@Autowired
private
ProductSpuFeign
productSpuFeign
;
/**
* 创建商品推荐
*
...
...
@@ -78,7 +78,7 @@ public class ProductRecommendManager {
PageResult
<
ProductRecommendDetailVO
>
pageResult
=
ProductRecommendConvert
.
INSTANCE
.
convertPage
(
pageProductRecommendResult
.
getData
());
if
(!
CollectionUtils
.
isEmpty
(
pageResult
.
getList
()))
{
// 获取商品信息,并进行拼接
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpusResult
=
productSpu
Rpc
.
listProductSpus
(
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpusResult
=
productSpu
Feign
.
listProductSpus
(
CollectionUtils
.
convertSet
(
pageResult
.
getList
(),
ProductRecommendDetailVO:
:
getProductSpuId
));
listProductSpusResult
.
checkError
();
Map
<
Integer
,
ProductSpuRespDTO
>
productSpuMap
=
CollectionUtils
.
convertMap
(
listProductSpusResult
.
getData
(),
ProductSpuRespDTO:
:
getId
);
...
...
product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuFeign.java
0 → 100644
浏览文件 @
4f50845b
package
cn
.
iocoder
.
mall
.
productservice
.
rpc
.
spu
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.common.framework.vo.PageResult
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.*
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
java.util.Collection
;
import
java.util.List
;
@FeignClient
(
value
=
"product-service"
)
public
interface
ProductSpuFeign
{
/**
* 获得商品 SPU
*
* @param productSpuId 商品 SPU 编号
* @return 商品 SPU
*/
@GetMapping
(
value
=
"/product/spu/get"
)
CommonResult
<
ProductSpuRespDTO
>
getProductSpu
(
@RequestParam
(
"productSpuId"
)
Integer
productSpuId
);
/**
* 创建商品 SPU
*
* @param createDTO 创建商品 SPU DTO
* @return 商品 SPU编号
*/
@PostMapping
(
value
=
"/product/spu/create"
)
CommonResult
<
Integer
>
createProductSpu
(
@RequestBody
ProductSpuAndSkuCreateReqDTO
createDTO
);
/**
* 更新商品 SPU
*
* @param updateDTO 更新商品 SPU DTO
*/
@PostMapping
(
value
=
"/product/spu/update"
)
CommonResult
<
Boolean
>
updateProductSpu
(
@RequestBody
ProductSpuAndSkuUpdateReqDTO
updateDTO
);
/**
* 获得商品 SPU列表
*
* @param productSpuIds 商品 SPU 编号列表
* @return 商品 SPU 列表
*/
@GetMapping
(
value
=
"/product/spu/list"
)
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpus
(
@RequestParam
(
"productSpuIds"
)
Collection
<
Integer
>
productSpuIds
);
/**
* 获得商品 SPU 分页
*
* @param pageDTO 商品 SPU 分页查询
* @return 商品 SPU 分页结果
*/
@PostMapping
(
value
=
"/product/spu/page"
)
CommonResult
<
PageResult
<
ProductSpuRespDTO
>>
pageProductSpu
(
@RequestBody
ProductSpuPageReqDTO
pageDTO
);
/**
* 顺序获得商品 SPU 编号数组
*
* @param lastSpuId 最后一个商品 SPU 编号
* @param limit 数量
* @return 商品 SPU 编号数组
*/
@GetMapping
(
value
=
"/product/spu/lislistProductSpuIdst"
)
CommonResult
<
List
<
Integer
>>
listProductSpuIds
(
@RequestParam
(
"lastSpuId"
)
Integer
lastSpuId
,
@RequestParam
(
"limit"
)
Integer
limit
);
@GetMapping
(
value
=
"/product/spu/getProductSpuDetail"
)
CommonResult
<
ProductSpuDetailRespDTO
>
getProductSpuDetail
(
@RequestParam
(
"productSpuId"
)
Integer
productSpuId
,
@RequestParam
(
"fields"
)
Collection
<
String
>
fields
);
}
product-service-project/product-service-api/src/main/java/cn/iocoder/mall/productservice/rpc/spu/ProductSpuRpc.java
deleted
100644 → 0
浏览文件 @
c50f99e7
package
cn
.
iocoder
.
mall
.
productservice
.
rpc
.
spu
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.common.framework.vo.PageResult
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.*
;
import
java.util.Collection
;
import
java.util.List
;
/**
* 商品 SPU Rpc 接口
*/
public
interface
ProductSpuRpc
{
/**
* 创建商品 SPU
*
* @param createDTO 创建商品 SPU DTO
* @return 商品 SPU编号
*/
CommonResult
<
Integer
>
createProductSpu
(
ProductSpuAndSkuCreateReqDTO
createDTO
);
/**
* 更新商品 SPU
*
* @param updateDTO 更新商品 SPU DTO
*/
CommonResult
<
Boolean
>
updateProductSpu
(
ProductSpuAndSkuUpdateReqDTO
updateDTO
);
/**
* 获得商品 SPU
*
* @param productSpuId 商品 SPU 编号
* @return 商品 SPU
*/
CommonResult
<
ProductSpuRespDTO
>
getProductSpu
(
Integer
productSpuId
);
/**
* 获得商品 SPU列表
*
* @param productSpuIds 商品 SPU 编号列表
* @return 商品 SPU 列表
*/
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpus
(
Collection
<
Integer
>
productSpuIds
);
/**
* 获得商品 SPU 分页
*
* @param pageDTO 商品 SPU 分页查询
* @return 商品 SPU 分页结果
*/
CommonResult
<
PageResult
<
ProductSpuRespDTO
>>
pageProductSpu
(
ProductSpuPageReqDTO
pageDTO
);
/**
* 顺序获得商品 SPU 编号数组
*
* @param lastSpuId 最后一个商品 SPU 编号
* @param limit 数量
* @return 商品 SPU 编号数组
*/
CommonResult
<
List
<
Integer
>>
listProductSpuIds
(
Integer
lastSpuId
,
Integer
limit
);
CommonResult
<
ProductSpuDetailRespDTO
>
getProductSpuDetail
(
Integer
productSpuId
,
Collection
<
String
>
fields
);
}
product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/ProductSpuController.http
浏览文件 @
4f50845b
...
...
@@ -2,3 +2,12 @@
GET http://localhost:38082/product/spu/get?productSpuId=32
###
### /product/spu/get 获得商品 SPU
GET http://localhost:38082/product/spu/lislistProductSpuIdst?lastSpuId=30&limit=10
###
### /product/spu/get 获得商品 SPU
GET http://localhost:38082/product/spu/getProductSpuDetail?productSpuId=32&fields=attr,sku
###
product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/
rpc/spu/ProductSpuRpcImpl
.java
→
product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/
controller/ProductSpuController
.java
浏览文件 @
4f50845b
package
cn
.
iocoder
.
mall
.
productservice
.
rpc
.
spu
;
package
cn
.
iocoder
.
mall
.
productservice
.
controller
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.common.framework.vo.PageResult
;
import
cn.iocoder.mall.productservice.manager.spu.ProductSpuManager
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.*
;
import
org.apache.dubbo.config.annotation.DubboService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.Valid
;
import
java.util.Collection
;
import
java.util.List
;
import
static
cn
.
iocoder
.
common
.
framework
.
vo
.
CommonResult
.
success
;
/**
* 商品 SPU Rpc 实现类
*/
@DubboService
public
class
ProductSpuRpcImpl
implements
ProductSpuRpc
{
@RestController
@RequestMapping
(
"/product/spu"
)
@Api
(
"商品spu"
)
public
class
ProductSpuController
{
@Autowired
private
ProductSpuManager
productSpuManager
;
@Override
public
CommonResult
<
Integer
>
createProductSpu
(
ProductSpuAndSkuCreateReqDTO
createDTO
)
{
return
success
(
productSpuManager
.
createProductSpu
(
createDTO
));
@GetMapping
(
"/get"
)
@ApiOperation
(
"获得商品 SPU"
)
@ApiImplicitParam
(
name
=
"productSpuId"
,
value
=
"商品 SPU 编号"
,
required
=
true
)
public
CommonResult
<
ProductSpuRespDTO
>
getProductSpu
(
@RequestParam
(
value
=
"productSpuId"
)
Integer
productSpuId
)
{
return
success
(
productSpuManager
.
getProductSpu
(
productSpuId
));
}
@Override
public
CommonResult
<
Boolean
>
updateProductSpu
(
ProductSpuAndSkuUpdateReqDTO
updateDTO
)
{
/**
* 更新商品 SPU
*
* @param updateDTO 更新商品 SPU DTO
*/
@PostMapping
(
"/update"
)
@ApiOperation
(
"更新商品 SPU"
)
public
CommonResult
<
Boolean
>
updateProductSpu
(
@Valid
@RequestBody
ProductSpuAndSkuUpdateReqDTO
updateDTO
)
{
productSpuManager
.
updateProductSpu
(
updateDTO
);
return
success
(
true
);
}
@Override
public
CommonResult
<
ProductSpuRespDTO
>
getProductSpu
(
Integer
productSpuId
)
{
return
success
(
productSpuManager
.
getProductSpu
(
productSpuId
));
@PostMapping
(
"/create"
)
@ApiOperation
(
"创建商品 SPU"
)
public
CommonResult
<
Integer
>
createProductSpu
(
@Valid
@RequestBody
ProductSpuAndSkuCreateReqDTO
createDTO
)
{
return
success
(
productSpuManager
.
createProductSpu
(
createDTO
));
}
@Override
public
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpus
(
Collection
<
Integer
>
productSpuIds
)
{
@GetMapping
(
"/list"
)
@ApiOperation
(
"获得商品 SPU 列表"
)
@ApiImplicitParam
(
name
=
"productSpuIds"
,
value
=
"商品 SPU 编号列表"
,
required
=
true
)
public
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpus
(
@RequestParam
(
"productSpuIds"
)
List
<
Integer
>
productSpuIds
)
{
return
success
(
productSpuManager
.
listProductSpus
(
productSpuIds
));
}
@Override
public
CommonResult
<
PageResult
<
ProductSpuRespDTO
>>
pageProductSpu
(
ProductSpuPageReqDTO
pageDTO
)
{
return
success
(
productSpuManager
.
pageProductSpu
(
pageDTO
));
@PostMapping
(
"/page"
)
@ApiOperation
(
"获得商品 SPU 分页"
)
public
CommonResult
<
PageResult
<
ProductSpuRespDTO
>>
pageProductSpu
(
@RequestBody
ProductSpuPageReqDTO
pageVO
)
{
// 全部:无搜索条件
// 在售中:visible = true && hasQuantity = true
// 已售罄:visible = true && hasQuantity = false
// 仓库中:visible = false
return
success
(
productSpuManager
.
pageProductSpu
(
pageVO
));
}
@Override
public
CommonResult
<
List
<
Integer
>>
listProductSpuIds
(
Integer
lastSpuId
,
Integer
limit
)
{
/**
* 顺序获得商品 SPU 编号数组
*
* @param lastSpuId 最后一个商品 SPU 编号
* @param limit 数量
* @return 商品 SPU 编号数组
*/
@GetMapping
(
"/lislistProductSpuIdst"
)
public
CommonResult
<
List
<
Integer
>>
lislistProductSpuIdst
(
@RequestParam
(
"lastSpuId"
)
Integer
lastSpuId
,
@RequestParam
(
"limit"
)
Integer
limit
)
{
// 全部:无搜索条件
// 在售中:visible = true && hasQuantity = true
// 已售罄:visible = true && hasQuantity = false
// 仓库中:visible = false
return
success
(
productSpuManager
.
listProductSpuIds
(
lastSpuId
,
limit
));
}
@Override
public
CommonResult
<
ProductSpuDetailRespDTO
>
getProductSpuDetail
(
Integer
productSpuId
,
Collection
<
String
>
fields
)
{
return
success
(
productSpuManager
.
getProductSpuDetail
(
productSpuId
,
fields
));
}
@GetMapping
(
"/getProductSpuDetail"
)
public
CommonResult
<
ProductSpuDetailRespDTO
>
getProductSpuDetail
(
@RequestParam
(
"productSpuId"
)
Integer
productSpuId
,
@RequestParam
(
"fields"
)
Collection
<
String
>
fields
)
{
return
success
(
productSpuManager
.
getProductSpuDetail
(
productSpuId
,
fields
));
}
}
product-service-project/product-service-app/src/main/java/cn/iocoder/mall/productservice/controller/SpuController.java
deleted
100644 → 0
浏览文件 @
c50f99e7
package
cn
.
iocoder
.
mall
.
productservice
.
controller
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.productservice.manager.spu.ProductSpuManager
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
static
cn
.
iocoder
.
common
.
framework
.
vo
.
CommonResult
.
success
;
@RestController
@RequestMapping
(
"/product/spu"
)
@Api
(
"商品spu"
)
public
class
SpuController
{
@Autowired
private
ProductSpuManager
productSpuManager
;
@GetMapping
(
"/get"
)
@ApiOperation
(
"获得商品 SPU"
)
@ApiImplicitParam
(
name
=
"productSpuId"
,
value
=
"商品 SPU 编号"
,
required
=
true
)
public
CommonResult
<
ProductSpuRespDTO
>
getProductSpu
(
@RequestParam
(
value
=
"productSpuId"
)
Integer
productSpuId
)
{
return
success
(
productSpuManager
.
getProductSpu
(
productSpuId
));
}
}
promotion-service-project/promotion-service-app/pom.xml
浏览文件 @
4f50845b
...
...
@@ -104,6 +104,10 @@
<artifactId>
aspectjweaver
</artifactId>
<version>
1.9.6
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
</dependencies>
<build>
...
...
promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/PromotionServiceApplication.java
浏览文件 @
4f50845b
...
...
@@ -3,8 +3,12 @@ package cn.iocoder.mall.promotionservice;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
(
basePackages
=
{
"cn.iocoder.mall.productservice.rpc.spu"
})
public
class
PromotionServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/price/PriceManager.java
浏览文件 @
4f50845b
...
...
@@ -6,9 +6,11 @@ import cn.iocoder.common.framework.vo.CommonResult;
import
cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc
;
import
cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO
;
import
cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Rpc
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Feign
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO
;
import
cn.iocoder.mall.promotion.api.enums.*
;
import
cn.iocoder.mall.promotion.api.enums.MeetTypeEnum
;
import
cn.iocoder.mall.promotion.api.enums.PreferentialTypeEnum
;
import
cn.iocoder.mall.promotion.api.enums.RangeTypeEnum
;
import
cn.iocoder.mall.promotion.api.enums.activity.PromotionActivityStatusEnum
;
import
cn.iocoder.mall.promotion.api.enums.activity.PromotionActivityTypeEnum
;
import
cn.iocoder.mall.promotion.api.rpc.activity.dto.PromotionActivityRespDTO
;
...
...
@@ -36,8 +38,8 @@ public class PriceManager {
@DubboReference
(
version
=
"${dubbo.consumer.ProductSkuRpc.version}"
)
private
ProductSkuRpc
productSkuRpc
;
@
DubboReference
(
version
=
"${dubbo.consumer.ProductSpuRpc.version}"
)
private
ProductSpu
Rpc
productSpuRpc
;
@
Autowired
private
ProductSpu
Feign
productSpuFeign
;
@Autowired
private
PromotionActivityService
promotionActivityService
;
...
...
@@ -95,7 +97,7 @@ public class PriceManager {
private
List
<
PriceProductCalcRespDTO
.
Item
>
initCalcOrderPriceItems
(
List
<
ProductSkuRespDTO
>
skus
,
Map
<
Integer
,
PriceProductCalcReqDTO
.
Item
>
calcProductItemDTOMap
)
{
// 获得商品分类 Map
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpusResult
=
productSpu
Rpc
.
listProductSpus
(
CollectionUtils
.
convertSet
(
skus
,
ProductSkuRespDTO:
:
getSpuId
));
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpusResult
=
productSpu
Feign
.
listProductSpus
(
CollectionUtils
.
convertSet
(
skus
,
ProductSkuRespDTO:
:
getSpuId
));
listProductSpusResult
.
checkError
();
Map
<
Integer
,
Integer
>
spuIdCategoryIdMap
=
CollectionUtils
.
convertMap
(
listProductSpusResult
.
getData
(),
// SPU 编号与 Category 编号的映射
ProductSpuRespDTO:
:
getId
,
ProductSpuRespDTO:
:
getCid
);
...
...
promotion-service-project/promotion-service-app/src/main/java/cn/iocoder/mall/promotionservice/manager/recommend/ProductRecommendManager.java
浏览文件 @
4f50845b
...
...
@@ -3,11 +3,10 @@ package cn.iocoder.mall.promotionservice.manager.recommend;
import
cn.iocoder.common.framework.exception.util.ServiceExceptionUtil
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.common.framework.vo.PageResult
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Rpc
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Feign
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO
;
import
cn.iocoder.mall.promotion.api.rpc.recommend.dto.*
;
import
cn.iocoder.mall.promotionservice.service.recommend.ProductRecommendService
;
import
org.apache.dubbo.config.annotation.DubboReference
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -23,8 +22,8 @@ import static cn.iocoder.mall.promotion.api.enums.PromotionErrorCodeConstants.PR
@Validated
public
class
ProductRecommendManager
{
@
DubboReference
(
validation
=
"true"
,
version
=
"${dubbo.consumer.ProductSpuRpc.version}"
)
private
ProductSpu
Rpc
productSpuRpc
;
@
Autowired
private
ProductSpu
Feign
productSpuFeign
;
@Autowired
private
ProductRecommendService
productRecommendService
;
...
...
@@ -56,7 +55,7 @@ public class ProductRecommendManager {
}
private
void
checkProductSpu
(
Integer
productSpuId
)
{
CommonResult
<
ProductSpuRespDTO
>
getProductSpuResult
=
productSpu
Rpc
.
getProductSpu
(
productSpuId
);
CommonResult
<
ProductSpuRespDTO
>
getProductSpuResult
=
productSpu
Feign
.
getProductSpu
(
productSpuId
);
getProductSpuResult
.
checkError
();
if
(
getProductSpuResult
.
getData
()
==
null
)
{
throw
ServiceExceptionUtil
.
exception
(
PRODUCT_RECOMMEND_PRODUCT_NOT_EXISTS
);
...
...
search-service-project/search-service-app/pom.xml
浏览文件 @
4f50845b
...
...
@@ -101,6 +101,10 @@
<artifactId>
aspectjweaver
</artifactId>
<version>
1.9.6
</version>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
</dependencies>
<build>
...
...
search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/SearchServiceApplication.java
浏览文件 @
4f50845b
...
...
@@ -2,8 +2,12 @@ package cn.iocoder.mall.searchservice;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
(
basePackages
=
{
"cn.iocoder.mall.productservice.rpc.spu"
})
public
class
SearchServiceApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
search-service-project/search-service-app/src/main/java/cn/iocoder/mall/searchservice/manager/product/SearchProductManager.java
浏览文件 @
4f50845b
...
...
@@ -8,7 +8,7 @@ import cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO;
import
cn.iocoder.mall.productservice.rpc.sku.ProductSkuRpc
;
import
cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuListQueryReqDTO
;
import
cn.iocoder.mall.productservice.rpc.sku.dto.ProductSkuRespDTO
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Rpc
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Feign
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO
;
import
cn.iocoder.mall.searchservice.convert.product.SearchProductConvert
;
import
cn.iocoder.mall.searchservice.rpc.product.dto.SearchProductConditionReqDTO
;
...
...
@@ -33,13 +33,14 @@ public class SearchProductManager {
private
static
final
Integer
REBUILD_FETCH_PER_SIZE
=
100
;
@DubboReference
(
version
=
"${dubbo.consumer.ProductSpuRpc.version}"
)
private
ProductSpuRpc
productSpuRpc
;
@DubboReference
(
version
=
"${dubbo.consumer.ProductSkuRpc.version}"
)
private
ProductSkuRpc
productSkuRpc
;
@DubboReference
(
version
=
"${dubbo.consumer.ProductCategoryRpc.version}"
)
private
ProductCategoryRpc
productCategoryRpc
;
@Autowired
private
ProductSpuFeign
productSpuFeign
;
// @DubboReference( version = "${dubbo.consumer.CartService.version}")
// private CartService cartService;
...
...
@@ -68,7 +69,7 @@ public class SearchProductManager {
int
rebuildCounts
=
0
;
while
(
true
)
{
// 从商品服务,增量获取商品列表编号
CommonResult
<
List
<
Integer
>>
listProductSpuIdsResult
=
productSpu
Rpc
.
listProductSpuIds
(
lastId
,
REBUILD_FETCH_PER_SIZE
);
CommonResult
<
List
<
Integer
>>
listProductSpuIdsResult
=
productSpu
Feign
.
listProductSpuIds
(
lastId
,
REBUILD_FETCH_PER_SIZE
);
listProductSpuIdsResult
.
checkError
();
List
<
Integer
>
spuIds
=
listProductSpuIdsResult
.
getData
();
// 逐个重建索引到 ES 中
...
...
@@ -93,7 +94,7 @@ public class SearchProductManager {
*/
public
Boolean
saveProduct
(
Integer
id
)
{
// 获得商品 SPU
CommonResult
<
ProductSpuRespDTO
>
productSpuResult
=
productSpu
Rpc
.
getProductSpu
(
id
);
CommonResult
<
ProductSpuRespDTO
>
productSpuResult
=
productSpu
Feign
.
getProductSpu
(
id
);
productSpuResult
.
checkError
();
if
(
productSpuResult
.
getData
()
==
null
)
{
log
.
error
(
"[saveProduct][商品 SPU({}) 不存在]"
,
id
);
...
...
shop-web-app/pom.xml
浏览文件 @
4f50845b
...
...
@@ -117,7 +117,10 @@
<groupId>
org.mapstruct
</groupId>
<artifactId>
mapstruct-jdk8
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-starter-openfeign
</artifactId>
</dependency>
</dependencies>
<build>
...
...
shop-web-app/src/main/java/cn/iocoder/mall/shopweb/ShopWebApplication.java
浏览文件 @
4f50845b
...
...
@@ -2,8 +2,12 @@ package cn.iocoder.mall.shopweb;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.client.discovery.EnableDiscoveryClient
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
(
basePackages
=
{
"cn.iocoder.mall.productservice.rpc.spu"
})
public
class
ShopWebApplication
{
public
static
void
main
(
String
[]
args
)
{
...
...
shop-web-app/src/main/java/cn/iocoder/mall/shopweb/controller/product/ProductSpuController.http
浏览文件 @
4f50845b
### /product-spu/page 成功(全部)
GET
{{shop-api-base-url}}
/product-spu/page?pageNo=1&pageSize=10&keyword=骚气
GET
http://127.0.0.1:18084/shop-api
/product-spu/page?pageNo=1&pageSize=10&keyword=骚气
Content-Type: application/x-www-form-urlencoded
### /product-spu/search-condition 成功
GET
{{shop-api-base-url}}
/product-spu/search-condition?keyword=骚气
GET
http://127.0.0.1:18084/shop-api
/product-spu/search-condition?keyword=骚气
Content-Type: application/x-www-form-urlencoded
### /product-spu/get-detail 成功
GET
{{shop-api-base-url}}
/product-spu/get-detail?id=63
GET
http://127.0.0.1:18084/shop-api
/product-spu/get-detail?id=63
Content-Type: application/x-www-form-urlencoded
###
shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/product/ProductSpuManager.java
浏览文件 @
4f50845b
...
...
@@ -6,7 +6,7 @@ import cn.iocoder.common.framework.vo.PageResult;
import
cn.iocoder.mall.productservice.enums.spu.ProductSpuDetailFieldEnum
;
import
cn.iocoder.mall.productservice.rpc.category.ProductCategoryRpc
;
import
cn.iocoder.mall.productservice.rpc.category.dto.ProductCategoryRespDTO
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Rpc
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Feign
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuDetailRespDTO
;
import
cn.iocoder.mall.searchservice.enums.product.SearchProductConditionFieldEnum
;
import
cn.iocoder.mall.searchservice.rpc.product.SearchProductRpc
;
...
...
@@ -19,6 +19,7 @@ import cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuRespVO;
import
cn.iocoder.mall.shopweb.controller.product.vo.product.ProductSpuSearchConditionRespVO
;
import
cn.iocoder.mall.shopweb.convert.product.ProductSpuConvert
;
import
org.apache.dubbo.config.annotation.DubboReference
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -39,8 +40,8 @@ public class ProductSpuManager {
@DubboReference
(
version
=
"${dubbo.consumer.ProductCategoryRpc.version}"
)
private
ProductCategoryRpc
productCategoryRpc
;
@
DubboReference
(
version
=
"${dubbo.consumer.ProductSpuRpc.version}"
)
private
ProductSpu
Rpc
productSpuRpc
;
@
Autowired
private
ProductSpu
Feign
productSpuFeign
;
public
PageResult
<
ProductSpuRespVO
>
pageProductSpu
(
ProductSpuPageReqVO
pageReqVO
)
{
CommonResult
<
PageResult
<
SearchProductRespDTO
>>
pageResult
=
...
...
@@ -69,7 +70,7 @@ public class ProductSpuManager {
}
public
ProductSpuDetailRespVO
getProductSpuDetail
(
Integer
id
)
{
CommonResult
<
ProductSpuDetailRespDTO
>
getProductSpuDetailResult
=
productSpu
Rpc
.
getProductSpuDetail
(
id
,
CommonResult
<
ProductSpuDetailRespDTO
>
getProductSpuDetailResult
=
productSpu
Feign
.
getProductSpuDetail
(
id
,
Arrays
.
asList
(
ProductSpuDetailFieldEnum
.
SKU
.
getField
(),
ProductSpuDetailFieldEnum
.
ATTR
.
getField
()));
getProductSpuDetailResult
.
checkError
();
return
ProductSpuConvert
.
INSTANCE
.
convert
(
getProductSpuDetailResult
.
getData
());
...
...
shop-web-app/src/main/java/cn/iocoder/mall/shopweb/service/promotion/ProductRecommendManager.java
浏览文件 @
4f50845b
...
...
@@ -3,7 +3,7 @@ package cn.iocoder.mall.shopweb.service.promotion;
import
cn.iocoder.common.framework.enums.CommonStatusEnum
;
import
cn.iocoder.common.framework.util.CollectionUtils
;
import
cn.iocoder.common.framework.vo.CommonResult
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Rpc
;
import
cn.iocoder.mall.productservice.rpc.spu.ProductSpu
Feign
;
import
cn.iocoder.mall.productservice.rpc.spu.dto.ProductSpuRespDTO
;
import
cn.iocoder.mall.promotion.api.rpc.recommend.ProductRecommendRpc
;
import
cn.iocoder.mall.promotion.api.rpc.recommend.dto.ProductRecommendListReqDTO
;
...
...
@@ -13,6 +13,7 @@ import cn.iocoder.mall.shopweb.convert.promotion.ProductRecommendConvert;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Multimap
;
import
org.apache.dubbo.config.annotation.DubboReference
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.validation.annotation.Validated
;
...
...
@@ -30,8 +31,8 @@ public class ProductRecommendManager {
@DubboReference
(
version
=
"${dubbo.consumer.ProductRecommendRpc.version}"
)
private
ProductRecommendRpc
productRecommendRpc
;
@
DubboReference
(
version
=
"${dubbo.consumer.ProductSpuRpc.version}"
)
private
ProductSpu
Rpc
productSpuRpc
;
@
Autowired
private
ProductSpu
Feign
productSpuFeign
;
public
Map
<
Integer
,
Collection
<
ProductSpuRespVO
>>
listProductRecommends
()
{
// 查询商品推荐列表
...
...
@@ -49,7 +50,7 @@ public class ProductRecommendManager {
}
private
Map
<
Integer
,
ProductSpuRespDTO
>
getProductSkuMap
(
List
<
ProductRecommendRespDTO
>
productRecommends
)
{
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpusResult
=
productSpu
Rpc
.
listProductSpus
(
CommonResult
<
List
<
ProductSpuRespDTO
>>
listProductSpusResult
=
productSpu
Feign
.
listProductSpus
(
CollectionUtils
.
convertSet
(
productRecommends
,
ProductRecommendRespDTO:
:
getProductSpuId
));
listProductSpusResult
.
checkError
();
return
CollectionUtils
.
convertMap
(
listProductSpusResult
.
getData
(),
ProductSpuRespDTO:
:
getId
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论