Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
有来技术
youlai-mall
提交
e7aa2678
Y
youlai-mall
项目概览
有来技术
/
youlai-mall
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
youlai-mall
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e7aa2678
编写于
3月 05, 2021
作者:
H
haoxr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor:商品模块调整
上级
a270b36d
变更
35
隐藏空白更改
内联
并排
Showing
35 changed file
with
297 addition
and
186 deletion
+297
-186
mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartItemVo.java
...src/main/java/com/youlai/mall/oms/pojo/vo/CartItemVo.java
+2
-2
mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java
...ava/com/youlai/mall/oms/service/impl/CartServiceImpl.java
+1
-1
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/bo/admin/ProductBO.java
...src/main/java/com/youlai/mall/pms/bo/admin/ProductBO.java
+6
-6
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/bo/app/ProductBO.java
...i/src/main/java/com/youlai/mall/pms/bo/app/ProductBO.java
+4
-4
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsCategorySpec.java
...java/com/youlai/mall/pms/pojo/domain/PmsCategorySpec.java
+1
-1
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsInventory.java
...in/java/com/youlai/mall/pms/pojo/domain/PmsInventory.java
+4
-3
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsProduct.java
...main/java/com/youlai/mall/pms/pojo/domain/PmsProduct.java
+2
-2
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsProductAttrValue.java
.../com/youlai/mall/pms/pojo/domain/PmsProductAttrValue.java
+3
-3
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsProductSpecValue.java
.../com/youlai/mall/pms/pojo/domain/PmsProductSpecValue.java
+3
-3
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/constant/RedisConstants.java
...a/com/youlai/mall/pms/common/constant/RedisConstants.java
+1
-1
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/enums/InventoryOperationEnum.java
.../youlai/mall/pms/common/enums/InventoryOperationEnum.java
+31
-0
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/InventoryController.java
...youlai/mall/pms/controller/admin/InventoryController.java
+9
-9
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/ProductController.java
...m/youlai/mall/pms/controller/admin/ProductController.java
+13
-13
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/InventoryController.java
...m/youlai/mall/pms/controller/app/InventoryController.java
+39
-14
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/ProductController.java
...com/youlai/mall/pms/controller/app/ProductController.java
+6
-6
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java
...ava/com/youlai/mall/pms/controller/app/SkuController.java
+10
-11
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsInventoryMapper.java
...n/java/com/youlai/mall/pms/mapper/PmsInventoryMapper.java
+5
-3
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsProductAttrValueMapper.java
...com/youlai/mall/pms/mapper/PmsProductAttrValueMapper.java
+2
-2
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsProductMapper.java
...ain/java/com/youlai/mall/pms/mapper/PmsProductMapper.java
+3
-3
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/PmsProductSpecValueMapper.java
...com/youlai/mall/pms/mapper/PmsProductSpecValueMapper.java
+3
-3
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsInventoryService.java
...ava/com/youlai/mall/pms/service/IPmsInventoryService.java
+4
-4
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsProductAttrValueService.java
.../youlai/mall/pms/service/IPmsProductAttrValueService.java
+10
-0
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsProductService.java
.../java/com/youlai/mall/pms/service/IPmsProductService.java
+3
-3
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPmsProductSpecValueService.java
.../youlai/mall/pms/service/IPmsProductSpecValueService.java
+9
-0
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsInventoryServiceImpl.java
...youlai/mall/pms/service/impl/PmsInventoryServiceImpl.java
+13
-13
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsProductAttrValueServiceImpl.java
...mall/pms/service/impl/PmsProductAttrValueServiceImpl.java
+17
-0
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsProductServiceImpl.java
...m/youlai/mall/pms/service/impl/PmsProductServiceImpl.java
+49
-49
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/PmsProductSpecValueServiceImpl.java
...mall/pms/service/impl/PmsProductSpecValueServiceImpl.java
+16
-0
mall-pms/pms-boot/src/main/resources/mapper/PmsSkuDao.xml
mall-pms/pms-boot/src/main/resources/mapper/PmsSkuDao.xml
+2
-2
mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/ProductControllerTest.java
...com/youlai/mall/pms/controller/ProductControllerTest.java
+5
-5
mall-pms/pms-search/src/main/java/com/youlai/mall/pms/search/service/IPmsSearchService.java
...com/youlai/mall/pms/search/service/IPmsSearchService.java
+3
-3
mall-pms/pms-search/src/main/java/com/youlai/mall/pms/search/service/impl/PmsSearchServiceImpl.java
...ai/mall/pms/search/service/impl/PmsSearchServiceImpl.java
+5
-5
youlai-common/common-core/src/main/java/com/youlai/common/enums/BusinessTypeEnum.java
...c/main/java/com/youlai/common/enums/BusinessTypeEnum.java
+1
-1
youlai-common/common-core/src/main/java/com/youlai/common/enums/QueryModeEnum.java
.../src/main/java/com/youlai/common/enums/QueryModeEnum.java
+6
-6
youlai-common/common-web/src/main/resources/logback-spring.xml
...i-common/common-web/src/main/resources/logback-spring.xml
+6
-5
未找到文件。
mall-oms/oms-api/src/main/java/com/youlai/mall/oms/pojo/vo/CartItemVo.java
浏览文件 @
e7aa2678
...
...
@@ -87,11 +87,11 @@ public class CartItemVo implements Serializable {
this
.
skuName
=
skuName
;
}
public
Integer
get
Stock
()
{
public
Integer
get
Inventory
()
{
return
stock
;
}
public
void
set
Stock
(
Integer
stock
)
{
public
void
set
Inventory
(
Integer
stock
)
{
this
.
stock
=
stock
;
}
...
...
mall-oms/oms-boot/src/main/java/com/youlai/mall/oms/service/impl/CartServiceImpl.java
浏览文件 @
e7aa2678
...
...
@@ -72,7 +72,7 @@ public class CartServiceImpl implements CartService {
cartItem
.
setSkuImg
(
data
.
getPicUrl
());
cartItem
.
setNumber
(
1
);
cartItem
.
setPrice
(
data
.
getPrice
());
cartItem
.
set
Stock
(
data
.
getStock
());
cartItem
.
set
Inventory
(
data
.
getInventory
());
});
//2、远程查询商品属性
...
...
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/bo/admin/ProductBO.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.bo.admin
;
import
com.youlai.mall.pms.pojo.domain.Pms
Sku
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
AttrValue
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
SpecValue
;
import
com.youlai.mall.pms.pojo.domain.Pms
Inventory
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
AttrValue
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
SpecValue
;
import
com.youlai.mall.pms.pojo.dto.SpuDTO
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
...
...
@@ -17,10 +17,10 @@ public class ProductBO {
private
SpuDTO
spu
;
private
List
<
Pms
Spu
AttrValue
>
attrs
;
private
List
<
Pms
Product
AttrValue
>
attrs
;
private
List
<
Pms
Spu
SpecValue
>
specs
;
private
List
<
Pms
Product
SpecValue
>
specs
;
private
List
<
Pms
Sku
>
skuList
;
private
List
<
Pms
Inventory
>
skuList
;
}
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/bo/app/ProductBO.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.bo.app
;
import
com.youlai.mall.pms.pojo.domain.Pms
Sku
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
AttrValue
;
import
com.youlai.mall.pms.pojo.domain.Pms
Inventory
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
AttrValue
;
import
com.youlai.mall.pms.pojo.domain.PmsCategorySpec
;
import
com.youlai.mall.pms.pojo.dto.SpuDTO
;
import
lombok.AllArgsConstructor
;
...
...
@@ -17,10 +17,10 @@ public class ProductBO {
private
SpuDTO
spu
;
private
List
<
Pms
Spu
AttrValue
>
attrs
;
private
List
<
Pms
Product
AttrValue
>
attrs
;
private
List
<
PmsCategorySpec
>
specs
;
private
List
<
Pms
Sku
>
skuList
;
private
List
<
Pms
Inventory
>
skuList
;
}
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/PmsCategorySpec.java
浏览文件 @
e7aa2678
...
...
@@ -18,6 +18,6 @@ public class PmsCategorySpec extends BaseEntity {
private
String
name
;
@TableField
(
exist
=
false
)
private
List
<
Pms
Spu
SpecValue
>
values
=
new
ArrayList
<>();
private
List
<
Pms
Product
SpecValue
>
values
=
new
ArrayList
<>();
}
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/Pms
Sku
.java
→
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/Pms
Inventory
.java
浏览文件 @
e7aa2678
...
...
@@ -6,16 +6,17 @@ import com.youlai.common.base.BaseEntity;
import
lombok.Data
;
@Data
public
class
Pms
Sku
extends
BaseEntity
{
public
class
Pms
Inventory
extends
BaseEntity
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
id
;
private
Long
spu
Id
;
private
Long
product
Id
;
private
String
name
;
private
String
code
;
private
String
picUrl
;
private
Long
originPrice
;
private
Long
price
;
private
Integer
stock
;
private
Integer
inventory
;
private
Integer
lockInventory
;
private
String
specValueIds
;
}
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/Pms
Spu
.java
→
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/Pms
Product
.java
浏览文件 @
e7aa2678
...
...
@@ -18,7 +18,7 @@ import java.util.List;
@Data
@Accessors
(
chain
=
true
)
@Document
(
indexName
=
"pms_spu"
,
replicas
=
1
,
shards
=
1
,
createIndex
=
true
)
public
class
Pms
Spu
extends
BaseEntity
{
public
class
Pms
Product
extends
BaseEntity
{
@Id
@TableId
(
type
=
IdType
.
AUTO
)
...
...
@@ -43,5 +43,5 @@ public class PmsSpu extends BaseEntity {
private
String
brandName
;
@TableField
(
exist
=
false
)
private
List
<
Pms
Sku
>
skuList
;
private
List
<
Pms
Inventory
>
skuList
;
}
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/Pms
Spu
AttrValue.java
→
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/Pms
Product
AttrValue.java
浏览文件 @
e7aa2678
...
...
@@ -10,12 +10,12 @@ import lombok.Data;
* @date 2020-11-06
*/
@Data
public
class
Pms
Spu
AttrValue
extends
BaseEntity
{
public
class
Pms
Product
AttrValue
extends
BaseEntity
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
id
;
private
Long
spu
Id
;
private
Long
a
ttrId
;
private
Long
product
Id
;
private
Long
categoryA
ttrId
;
private
String
name
;
private
String
value
;
...
...
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/Pms
Spu
SpecValue.java
→
mall-pms/pms-api/src/main/java/com/youlai/mall/pms/pojo/domain/Pms
Product
SpecValue.java
浏览文件 @
e7aa2678
...
...
@@ -10,11 +10,11 @@ import lombok.Data;
* @date 2020-11-06
*/
@Data
public
class
Pms
Spu
SpecValue
extends
BaseEntity
{
public
class
Pms
Product
SpecValue
extends
BaseEntity
{
@TableId
(
type
=
IdType
.
INPUT
)
private
Long
id
;
private
Long
spu
Id
;
private
Long
s
pecId
;
private
Long
product
Id
;
private
Long
categoryS
pecId
;
private
String
value
;
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/RedisConstants.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/
constant/
RedisConstants.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.common
;
package
com.youlai.mall.pms.common
.constant
;
/**
* @author haoxr
...
...
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/common/enums/InventoryOperationEnum.java
0 → 100644
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.common.enums
;
import
lombok.Getter
;
import
lombok.Setter
;
public
enum
InventoryOperationEnum
{
PAGE
(
"page"
),
// 分页查询
LIST
(
"list"
),
//列表查询
TREE
(
"tree"
),
//树形列表
CASCADER
(
"cascader"
),
// 级联列表 对应级联选择器的下拉格式数据
ROUTER
(
"router"
)
;
// 路由列表
@Getter
@Setter
private
String
code
;
InventoryOperationEnum
(
String
code
)
{
this
.
code
=
code
;
}
public
static
InventoryOperationEnum
getValue
(
String
code
){
for
(
InventoryOperationEnum
value
:
values
())
{
if
(
value
.
getCode
().
equals
(
code
))
{
return
value
;
}
}
return
PAGE
;
}
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/InventoryController.java
浏览文件 @
e7aa2678
...
...
@@ -2,9 +2,9 @@ package com.youlai.mall.pms.controller.admin;
import
cn.hutool.core.bean.BeanUtil
;
import
com.youlai.common.result.Result
;
import
com.youlai.mall.pms.pojo.domain.Pms
Sku
;
import
com.youlai.mall.pms.pojo.domain.Pms
Inventory
;
import
com.youlai.mall.pms.pojo.dto.SkuDTO
;
import
com.youlai.mall.pms.service.IPms
Sku
Service
;
import
com.youlai.mall.pms.service.IPms
Inventory
Service
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
...
...
@@ -20,13 +20,13 @@ import org.springframework.web.bind.annotation.*;
@AllArgsConstructor
public
class
InventoryController
{
private
IPms
SkuService
iPmsSku
Service
;
private
IPms
InventoryService
iPmsInventory
Service
;
@ApiOperation
(
value
=
"商品库存明细"
,
httpMethod
=
"GET"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品SkuID"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{id}"
)
public
Result
<
SkuDTO
>
detail
(
@PathVariable
Long
id
)
{
Pms
Sku
sku
=
iPmsSku
Service
.
getById
(
id
);
Pms
Inventory
sku
=
iPmsInventory
Service
.
getById
(
id
);
SkuDTO
skuDTO
=
new
SkuDTO
();
BeanUtil
.
copyProperties
(
sku
,
skuDTO
);
return
Result
.
success
(
skuDTO
);
...
...
@@ -40,8 +40,8 @@ public class InventoryController {
@PutMapping
(
value
=
"/{id}"
)
public
Result
update
(
@PathVariable
Long
id
,
@RequestBody
Pms
Sku
sku
)
{
boolean
status
=
iPms
Sku
Service
.
updateById
(
sku
);
@RequestBody
Pms
Inventory
sku
)
{
boolean
status
=
iPms
Inventory
Service
.
updateById
(
sku
);
return
Result
.
judge
(
status
);
}
...
...
@@ -53,9 +53,9 @@ public class InventoryController {
})
@PutMapping
(
"/{id}/stock"
)
public
Result
updateStock
(
@PathVariable
Long
id
,
@RequestParam
Integer
num
)
{
Pms
Sku
sku
=
iPmsSku
Service
.
getById
(
id
);
sku
.
set
Stock
(
sku
.
getStock
()
+
num
);
boolean
result
=
iPms
Sku
Service
.
updateById
(
sku
);
Pms
Inventory
sku
=
iPmsInventory
Service
.
getById
(
id
);
sku
.
set
Inventory
(
sku
.
getInventory
()
+
num
);
boolean
result
=
iPms
Inventory
Service
.
updateById
(
sku
);
return
Result
.
judge
(
result
);
}
...
...
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/admin/ProductController.java
浏览文件 @
e7aa2678
...
...
@@ -7,8 +7,8 @@ import com.youlai.common.enums.QueryModeEnum;
import
com.youlai.common.result.Result
;
import
com.youlai.common.result.ResultCode
;
import
com.youlai.mall.pms.bo.admin.ProductBO
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
;
import
com.youlai.mall.pms.service.IPms
Spu
Service
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
;
import
com.youlai.mall.pms.service.IPms
Product
Service
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
...
...
@@ -27,7 +27,7 @@ import java.util.stream.Collectors;
@AllArgsConstructor
public
class
ProductController
{
private
IPms
SpuService
iPmsSpu
Service
;
private
IPms
ProductService
iPmsProduct
Service
;
@ApiOperation
(
value
=
"列表分页"
,
httpMethod
=
"GET"
)
@ApiImplicitParams
({
...
...
@@ -48,9 +48,9 @@ public class ProductController {
QueryModeEnum
queryModeEnum
=
QueryModeEnum
.
getValue
(
queryMode
);
switch
(
queryModeEnum
)
{
case
PAGE:
IPage
<
Pms
Spu
>
result
=
iPmsSpu
Service
.
list
(
IPage
<
Pms
Product
>
result
=
iPmsProduct
Service
.
list
(
new
Page
<>(
page
,
limit
),
new
Pms
Spu
().
setName
(
name
).
setCategoryId
(
categoryId
)
new
Pms
Product
().
setName
(
name
).
setCategoryId
(
categoryId
)
);
return
Result
.
success
(
result
.
getRecords
(),
result
.
getTotal
());
default
:
...
...
@@ -62,7 +62,7 @@ public class ProductController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品id"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{id}"
)
public
Result
detail
(
@PathVariable
Long
id
)
{
ProductBO
spu
=
iPms
Spu
Service
.
getBySpuId
(
id
);
ProductBO
spu
=
iPms
Product
Service
.
getBySpuId
(
id
);
return
Result
.
success
(
spu
);
}
...
...
@@ -71,7 +71,7 @@ public class ProductController {
@ApiImplicitParam
(
name
=
"spuBO"
,
value
=
"实体JSON对象"
,
required
=
true
,
paramType
=
"body"
,
dataType
=
"PmsSpuBO"
)
@PostMapping
public
Result
add
(
@RequestBody
ProductBO
spuBO
)
{
boolean
status
=
iPms
Spu
Service
.
add
(
spuBO
);
boolean
status
=
iPms
Product
Service
.
add
(
spuBO
);
return
Result
.
judge
(
status
);
}
...
...
@@ -84,7 +84,7 @@ public class ProductController {
public
Result
update
(
@PathVariable
Long
id
,
@RequestBody
ProductBO
spu
)
{
boolean
status
=
iPms
Spu
Service
.
updateById
(
spu
);
boolean
status
=
iPms
Product
Service
.
updateById
(
spu
);
return
Result
.
judge
(
status
);
}
...
...
@@ -92,7 +92,7 @@ public class ProductController {
@ApiImplicitParam
(
name
=
"ids"
,
value
=
"id集合,以英文逗号','分隔"
,
required
=
true
,
paramType
=
"query"
,
dataType
=
"String"
)
@DeleteMapping
(
"/{ids}"
)
public
Result
delete
(
@PathVariable
String
ids
)
{
iPms
Spu
Service
.
removeBySpuIds
(
Arrays
.
asList
(
ids
.
split
(
","
)).
stream
().
map
(
id
->
Long
.
parseLong
(
id
)).
collect
(
Collectors
.
toList
()));
iPms
Product
Service
.
removeBySpuIds
(
Arrays
.
asList
(
ids
.
split
(
","
)).
stream
().
map
(
id
->
Long
.
parseLong
(
id
)).
collect
(
Collectors
.
toList
()));
return
Result
.
success
();
}
...
...
@@ -102,10 +102,10 @@ public class ProductController {
@ApiImplicitParam
(
name
=
"spu"
,
value
=
"实体JSON对象"
,
required
=
true
,
paramType
=
"body"
,
dataType
=
"PmsSpu"
)
})
@PatchMapping
(
value
=
"/{id}"
)
public
Result
patch
(
@PathVariable
Integer
id
,
@RequestBody
Pms
Spu
spu
)
{
LambdaUpdateWrapper
<
Pms
Spu
>
updateWrapper
=
new
LambdaUpdateWrapper
<
PmsSpu
>().
eq
(
PmsSpu
:
:
getId
,
id
);
updateWrapper
.
set
(
spu
.
getStatus
()
!=
null
,
Pms
Spu
:
:
getStatus
,
spu
.
getStatus
());
boolean
update
=
iPms
Spu
Service
.
update
(
updateWrapper
);
public
Result
patch
(
@PathVariable
Integer
id
,
@RequestBody
Pms
Product
spu
)
{
LambdaUpdateWrapper
<
Pms
Product
>
updateWrapper
=
new
LambdaUpdateWrapper
<
PmsProduct
>().
eq
(
PmsProduct
:
:
getId
,
id
);
updateWrapper
.
set
(
spu
.
getStatus
()
!=
null
,
Pms
Product
:
:
getStatus
,
spu
.
getStatus
());
boolean
update
=
iPms
Product
Service
.
update
(
updateWrapper
);
return
Result
.
success
(
update
);
}
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/InventoryController.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.controller.app
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.youlai.common.result.Result
;
import
com.youlai.mall.pms.pojo.domain.Pms
Sku
;
import
com.youlai.mall.pms.pojo.domain.Pms
Inventory
;
import
com.youlai.mall.pms.pojo.dto.SkuDTO
;
import
com.youlai.mall.pms.pojo.vo.SkuInfoVO
;
import
com.youlai.mall.pms.pojo.vo.WareSkuStockVO
;
import
com.youlai.mall.pms.service.IPms
Sku
Service
;
import
com.youlai.mall.pms.service.IPms
Inventory
Service
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.AllArgsConstructor
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
@Api
(
tags
=
"【移动端】商品库存"
)
@RestController
(
"AppInventoryController"
)
@RequestMapping
(
"/api.app/v1/inventories"
)
@AllArgsConstructor
public
class
InventoryController
{
private
IPms
SkuService
iPmsSku
Service
;
private
IPms
InventoryService
iPmsInventory
Service
;
@ApiOperation
(
value
=
"商品库存详情"
,
httpMethod
=
"GET"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品
SkuId
"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品
库存ID
"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{id}"
)
public
Result
<
SkuDTO
>
detail
(
@PathVariable
Long
id
)
{
Pms
Sku
sku
=
iPmsSku
Service
.
getById
(
id
);
Pms
Inventory
sku
=
iPmsInventory
Service
.
getById
(
id
);
SkuDTO
skuDTO
=
new
SkuDTO
();
BeanUtil
.
copyProperties
(
sku
,
skuDTO
);
return
Result
.
success
(
skuDTO
);
}
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品
SkuId
"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{
skuI
d}/inventory"
)
public
Result
<
Integer
>
getInventoryBy
SkuId
(
@PathVariable
Long
skuI
d
)
{
Integer
inventory
=
iPms
SkuService
.
getInventoryBySkuId
(
skuI
d
);
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品
库存ID
"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{
i
d}/inventory"
)
public
Result
<
Integer
>
getInventoryBy
Id
(
@PathVariable
Long
i
d
)
{
Integer
inventory
=
iPms
InventoryService
.
getInventoryById
(
i
d
);
return
Result
.
success
(
inventory
);
}
@ApiOperation
(
value
=
"订单提交锁定库存"
,
httpMethod
=
"POST"
)
@ApiImplicitParam
(
name
=
"skuStockVO"
,
value
=
"订单库存信息"
,
required
=
true
,
paramType
=
"body"
,
dataType
=
"WareSkuStockVO"
)
@PostMapping
(
"/batch/lock"
)
public
Result
<
Boolean
>
lockStock
(
@RequestBody
WareSkuStockVO
skuStockVO
)
{
try
{
iPmsInventoryService
.
lockStock
(
skuStockVO
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
return
Result
.
failed
();
}
}
@ApiOperation
(
value
=
"订单取消释放库存"
,
httpMethod
=
"POST"
)
@ApiImplicitParam
(
name
=
"skuStockVO"
,
value
=
"订单库存信息"
,
required
=
true
,
paramType
=
"body"
,
dataType
=
"WareSkuStockVO"
)
@PostMapping
(
"/stock/release"
)
public
Result
<
Boolean
>
releaseStock
(
@RequestBody
WareSkuStockVO
skuStockVO
)
{
try
{
iPmsInventoryService
.
releaseStock
(
skuStockVO
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
return
Result
.
failed
();
}
}
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/ProductController.java
浏览文件 @
e7aa2678
...
...
@@ -4,8 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.youlai.common.result.Result
;
import
com.youlai.mall.pms.bo.app.ProductBO
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
;
import
com.youlai.mall.pms.service.IPms
Spu
Service
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
;
import
com.youlai.mall.pms.service.IPms
Product
Service
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
...
...
@@ -19,7 +19,7 @@ import org.springframework.web.bind.annotation.*;
@AllArgsConstructor
public
class
ProductController
{
private
IPms
SpuService
iPmsSpu
Service
;
private
IPms
ProductService
iPmsProduct
Service
;
@ApiOperation
(
value
=
"列表分页"
,
httpMethod
=
"GET"
)
@ApiImplicitParams
({
...
...
@@ -35,9 +35,9 @@ public class ProductController {
String
name
,
Long
categoryId
)
{
IPage
<
Pms
Spu
>
result
=
iPmsSpu
Service
.
list
(
IPage
<
Pms
Product
>
result
=
iPmsProduct
Service
.
list
(
new
Page
<>(
page
,
limit
),
new
Pms
Spu
().
setName
(
name
).
setCategoryId
(
categoryId
)
new
Pms
Product
().
setName
(
name
).
setCategoryId
(
categoryId
)
);
return
Result
.
success
(
result
.
getRecords
(),
result
.
getTotal
());
}
...
...
@@ -46,7 +46,7 @@ public class ProductController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品id"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{id}"
)
public
Result
<
ProductBO
>
detail
(
@PathVariable
Long
id
)
{
ProductBO
product
=
iPms
Spu
Service
.
getProductByIdForApp
(
id
);
ProductBO
product
=
iPms
Product
Service
.
getProductByIdForApp
(
id
);
return
Result
.
success
(
product
);
}
...
...
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/controller/app/SkuController.java
浏览文件 @
e7aa2678
...
...
@@ -2,17 +2,16 @@ package com.youlai.mall.pms.controller.app;
import
cn.hutool.core.bean.BeanUtil
;
import
com.youlai.common.result.Result
;
import
com.youlai.mall.pms.pojo.domain.Pms
Sku
;
import
com.youlai.mall.pms.pojo.domain.Pms
Inventory
;
import
com.youlai.mall.pms.pojo.dto.SkuDTO
;
import
com.youlai.mall.pms.pojo.vo.SkuInfoVO
;
import
com.youlai.mall.pms.pojo.vo.WareSkuStockVO
;
import
com.youlai.mall.pms.service.IPms
Sku
Service
;
import
com.youlai.mall.pms.service.IPms
Inventory
Service
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
...
...
@@ -23,14 +22,14 @@ import java.util.List;
@AllArgsConstructor
public
class
SkuController
{
private
IPms
SkuService
iPmsSku
Service
;
private
IPms
InventoryService
iPmsInventory
Service
;
@ApiOperation
(
value
=
"商品sku详情"
,
httpMethod
=
"GET"
)
@ApiImplicitParam
(
name
=
"id"
,
value
=
"商品sku id"
,
required
=
true
,
paramType
=
"path"
,
dataType
=
"Long"
)
@GetMapping
(
"/{id}"
)
public
Result
<
SkuDTO
>
detail
(
@PathVariable
Long
id
)
{
Pms
Sku
sku
=
iPmsSku
Service
.
getById
(
id
);
Pms
Inventory
sku
=
iPmsInventory
Service
.
getById
(
id
);
SkuDTO
skuDTO
=
new
SkuDTO
();
BeanUtil
.
copyProperties
(
sku
,
skuDTO
);
return
Result
.
success
(
skuDTO
);
...
...
@@ -44,9 +43,9 @@ public class SkuController {
})
@PutMapping
(
"/{id}/stock"
)
public
Result
updateStock
(
@PathVariable
Long
id
,
@RequestParam
Integer
num
)
{
Pms
Sku
sku
=
iPmsSku
Service
.
getById
(
id
);
sku
.
set
Stock
(
sku
.
getStock
()
+
num
);
boolean
result
=
iPms
Sku
Service
.
updateById
(
sku
);
Pms
Inventory
sku
=
iPmsInventory
Service
.
getById
(
id
);
sku
.
set
Inventory
(
sku
.
getInventory
()
+
num
);
boolean
result
=
iPms
Inventory
Service
.
updateById
(
sku
);
return
Result
.
judge
(
result
);
}
...
...
@@ -54,7 +53,7 @@ public class SkuController {
@ApiImplicitParam
(
name
=
"skuIds"
,
value
=
"Sku ID 集合"
,
required
=
true
,
paramType
=
"param"
,
dataType
=
"List"
)
@GetMapping
(
"/infos"
)
public
Result
<
List
<
SkuInfoVO
>>
infos
(
@RequestParam
(
"skuId"
)
List
<
String
>
skuIds
)
{
List
<
SkuInfoVO
>
infos
=
iPms
Sku
Service
.
getSkuInfoByIds
(
skuIds
);
List
<
SkuInfoVO
>
infos
=
iPms
Inventory
Service
.
getSkuInfoByIds
(
skuIds
);
return
Result
.
success
(
infos
);
}
...
...
@@ -65,7 +64,7 @@ public class SkuController {
public
Result
<
Boolean
>
lockStock
(
@RequestBody
WareSkuStockVO
skuStockVO
)
{
try
{
iPms
Sku
Service
.
lockStock
(
skuStockVO
);
iPms
Inventory
Service
.
lockStock
(
skuStockVO
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
return
Result
.
failed
();
...
...
@@ -78,7 +77,7 @@ public class SkuController {
public
Result
<
Boolean
>
releaseStock
(
@RequestBody
WareSkuStockVO
skuStockVO
)
{
try
{
iPms
Sku
Service
.
releaseStock
(
skuStockVO
);
iPms
Inventory
Service
.
releaseStock
(
skuStockVO
);
return
Result
.
success
();
}
catch
(
Exception
e
)
{
return
Result
.
failed
();
...
...
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/Pms
Sku
Mapper.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/Pms
Inventory
Mapper.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.youlai.mall.pms.pojo.domain.Pms
Sku
;
import
com.youlai.mall.pms.pojo.domain.Pms
Inventory
;
import
com.youlai.mall.pms.pojo.vo.SkuInfoVO
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
...
...
@@ -10,12 +10,12 @@ import org.apache.ibatis.annotations.Mapper;
import
java.util.List
;
@Mapper
public
interface
Pms
SkuMapper
extends
BaseMapper
<
PmsSku
>
{
public
interface
Pms
InventoryMapper
extends
BaseMapper
<
PmsInventory
>
{
@Select
(
"<script>"
+
" select * from pms_sku where spu_id=#{spuId} "
+
"</script>"
)
List
<
Pms
Sku
>
listBySpuId
(
Long
spuId
);
List
<
Pms
Inventory
>
listBySpuId
(
Long
spuId
);
/**
* 批量获取商品详情
...
...
@@ -30,6 +30,8 @@ public interface PmsSkuMapper extends BaseMapper<PmsSku> {
* @param number 涉及商品数量
* @return
*/
Long
lockStock
(
@Param
(
"skuId"
)
Long
skuId
,
@Param
(
"number"
)
Integer
number
);
/**
...
...
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/Pms
Spu
AttrValueMapper.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/Pms
Product
AttrValueMapper.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
AttrValue
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
AttrValue
;
import
org.apache.ibatis.annotations.Mapper
;
/**
...
...
@@ -9,6 +9,6 @@ import org.apache.ibatis.annotations.Mapper;
* @date 2020-11-06
*/
@Mapper
public
interface
Pms
SpuAttrValueMapper
extends
BaseMapper
<
PmsSpu
AttrValue
>
{
public
interface
Pms
ProductAttrValueMapper
extends
BaseMapper
<
PmsProduct
AttrValue
>
{
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/Pms
Spu
Mapper.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/Pms
Product
Mapper.java
浏览文件 @
e7aa2678
...
...
@@ -2,7 +2,7 @@ package com.youlai.mall.pms.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
;
import
org.apache.ibatis.annotations.Many
;
import
org.apache.ibatis.annotations.Result
;
import
org.apache.ibatis.annotations.Results
;
...
...
@@ -16,7 +16,7 @@ import java.util.List;
* @date 2020-11-06
*/
@Mapper
public
interface
Pms
SpuMapper
extends
BaseMapper
<
PmsSpu
>
{
public
interface
Pms
ProductMapper
extends
BaseMapper
<
PmsProduct
>
{
@Select
(
"<script>"
+
" SELECT "
+
...
...
@@ -37,5 +37,5 @@ public interface PmsSpuMapper extends BaseMapper<PmsSpu> {
@Result
(
id
=
true
,
column
=
"id"
,
property
=
"id"
),
@Result
(
property
=
"skuList"
,
column
=
"id"
,
many
=
@Many
(
select
=
"com.youlai.mall.pms.mapper.PmsSkuMapper.listBySpuId"
))
})
List
<
Pms
Spu
>
list
(
Page
<
PmsSpu
>
page
,
PmsSpu
spu
);
List
<
Pms
Product
>
list
(
Page
<
PmsProduct
>
page
,
PmsProduct
spu
);
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/Pms
Spu
SpecValueMapper.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/mapper/Pms
Product
SpecValueMapper.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
SpecValue
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
SpecValue
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.Mapper
;
...
...
@@ -13,7 +13,7 @@ import java.util.Map;
* @date 2020-11-06
*/
@Mapper
public
interface
Pms
SpuSpecValueMapper
extends
BaseMapper
<
PmsSpu
SpecValue
>
{
public
interface
Pms
ProductSpecValueMapper
extends
BaseMapper
<
PmsProduct
SpecValue
>
{
@Select
(
"<script>"
+
...
...
@@ -28,6 +28,6 @@ public interface PmsSpuSpecValueMapper extends BaseMapper<PmsSpuSpecValue> {
" spu_id = #{spuId} "
+
" AND spec_id = #{specId} "
+
"</script>"
)
List
<
Pms
Spu
SpecValue
>
listBySpuIdAndSpecId
(
Map
<
String
,
String
>
param
);
List
<
Pms
Product
SpecValue
>
listBySpuIdAndSpecId
(
Map
<
String
,
String
>
param
);
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPms
Sku
Service.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPms
Inventory
Service.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.youlai.mall.pms.pojo.domain.Pms
Sku
;
import
com.youlai.mall.pms.pojo.domain.Pms
Inventory
;
import
com.youlai.mall.pms.pojo.vo.SkuInfoVO
;
import
com.youlai.mall.pms.pojo.vo.WareSkuStockVO
;
import
java.util.List
;
public
interface
IPms
SkuService
extends
IService
<
PmsSku
>
{
public
interface
IPms
InventoryService
extends
IService
<
PmsInventory
>
{
/**
* 批量获取商品详情
...
...
@@ -33,8 +33,8 @@ public interface IPmsSkuService extends IService<PmsSku> {
/**
* 获取商品库存
* @param
skuId
* @param
id 库存ID
* @return
*/
Integer
getInventoryBy
SkuId
(
Long
skuI
d
);
Integer
getInventoryBy
Id
(
Long
i
d
);
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPms
Spu
AttrValueService.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPms
Product
AttrValueService.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
AttrValue
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
AttrValue
;
public
interface
IPms
SpuAttrValueService
extends
IService
<
PmsSpu
AttrValue
>
{
public
interface
IPms
ProductAttrValueService
extends
IService
<
PmsProduct
AttrValue
>
{
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPms
Spu
Service.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPms
Product
Service.java
浏览文件 @
e7aa2678
...
...
@@ -4,13 +4,13 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.youlai.mall.pms.bo.app.ProductBO
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
;
import
java.util.List
;
public
interface
IPms
SpuService
extends
IService
<
PmsSpu
>
{
public
interface
IPms
ProductService
extends
IService
<
PmsProduct
>
{
IPage
<
Pms
Spu
>
list
(
Page
<
PmsSpu
>
page
,
PmsSpu
spu
);
IPage
<
Pms
Product
>
list
(
Page
<
PmsProduct
>
page
,
PmsProduct
spu
);
boolean
add
(
com
.
youlai
.
mall
.
pms
.
bo
.
admin
.
ProductBO
spuBO
);
...
...
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPms
Spu
SpecValueService.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/IPms
Product
SpecValueService.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
SpecValue
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
SpecValue
;
public
interface
IPms
SpuSpecValueService
extends
IService
<
PmsSpu
SpecValue
>
{
public
interface
IPms
ProductSpecValueService
extends
IService
<
PmsProduct
SpecValue
>
{
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/Pms
Sku
ServiceImpl.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/Pms
Inventory
ServiceImpl.java
浏览文件 @
e7aa2678
...
...
@@ -4,13 +4,13 @@ import cn.hutool.core.convert.Convert;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.youlai.common.web.exception.BizException
;
import
com.youlai.mall.pms.common.RedisConstants
;
import
com.youlai.mall.pms.mapper.Pms
Sku
Mapper
;
import
com.youlai.mall.pms.pojo.domain.Pms
Sku
;
import
com.youlai.mall.pms.common.
constant.
RedisConstants
;
import
com.youlai.mall.pms.mapper.Pms
Inventory
Mapper
;
import
com.youlai.mall.pms.pojo.domain.Pms
Inventory
;
import
com.youlai.mall.pms.pojo.vo.SkuInfoVO
;
import
com.youlai.mall.pms.pojo.vo.SkuStockVO
;
import
com.youlai.mall.pms.pojo.vo.WareSkuStockVO
;
import
com.youlai.mall.pms.service.IPms
Sku
Service
;
import
com.youlai.mall.pms.service.IPms
Inventory
Service
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.data.redis.core.RedisTemplate
;
...
...
@@ -22,7 +22,7 @@ import java.util.List;
@Service
@Slf4j
@AllArgsConstructor
public
class
Pms
SkuServiceImpl
extends
ServiceImpl
<
PmsSkuMapper
,
PmsSku
>
implements
IPmsSku
Service
{
public
class
Pms
InventoryServiceImpl
extends
ServiceImpl
<
PmsInventoryMapper
,
PmsInventory
>
implements
IPmsInventory
Service
{
private
RedisTemplate
redisTemplate
;
...
...
@@ -65,28 +65,28 @@ public class PmsSkuServiceImpl extends ServiceImpl<PmsSkuMapper, PmsSku> impleme
* Cache-Aside pattern 缓存、数据库读写模式
* 1. 读取数据,先读缓存,没有就去读数据库,然后将结果写入缓存
* 2. 写入数据,先更新数据库,再删除缓存
* @param
skuId
* @param
id 库存ID
* @return
*/
@Override
public
Integer
getInventoryBy
SkuId
(
Long
skuI
d
)
{
public
Integer
getInventoryBy
Id
(
Long
i
d
)
{
Integer
inventory
=
0
;
// 读->缓存
Object
cacheVal
=
redisTemplate
.
opsForValue
().
get
(
RedisConstants
.
PRODUCT_INVENTORY_PREFIX
+
skuI
d
);
Object
cacheVal
=
redisTemplate
.
opsForValue
().
get
(
RedisConstants
.
PRODUCT_INVENTORY_PREFIX
+
i
d
);
if
(
cacheVal
!=
null
)
{
inventory
=
Convert
.
toInt
(
cacheVal
);
return
inventory
;
}
// 读->数据库
Pms
Sku
pmsInventory
=
this
.
getOne
(
new
LambdaQueryWrapper
<
PmsSku
>()
.
eq
(
Pms
Sku:
:
getId
,
skuI
d
)
.
select
(
Pms
Sku:
:
getStock
));
Pms
Inventory
pmsInventory
=
this
.
getOne
(
new
LambdaQueryWrapper
<
PmsInventory
>()
.
eq
(
Pms
Inventory:
:
getId
,
i
d
)
.
select
(
Pms
Inventory:
:
getInventory
));
if
(
pmsInventory
!=
null
)
{
inventory
=
pmsInventory
.
get
Stock
();
inventory
=
pmsInventory
.
get
Inventory
();
// 写->缓存
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
PRODUCT_INVENTORY_PREFIX
+
skuI
d
,
inventory
);
redisTemplate
.
opsForValue
().
set
(
RedisConstants
.
PRODUCT_INVENTORY_PREFIX
+
i
d
,
inventory
);
}
return
inventory
;
...
...
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/Pms
Spu
AttrValueServiceImpl.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/Pms
Product
AttrValueServiceImpl.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
AttrValue
;
import
com.youlai.mall.pms.mapper.Pms
Spu
AttrValueMapper
;
import
com.youlai.mall.pms.service.IPms
Spu
AttrValueService
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
AttrValue
;
import
com.youlai.mall.pms.mapper.Pms
Product
AttrValueMapper
;
import
com.youlai.mall.pms.service.IPms
Product
AttrValueService
;
import
org.springframework.stereotype.Service
;
/**
...
...
@@ -11,7 +11,7 @@ import org.springframework.stereotype.Service;
* @date 2020-12-12
*/
@Service
public
class
Pms
SpuAttrValueServiceImpl
extends
ServiceImpl
<
PmsSpuAttrValueMapper
,
PmsSpuAttrValue
>
implements
IPmsSpu
AttrValueService
{
public
class
Pms
ProductAttrValueServiceImpl
extends
ServiceImpl
<
PmsProductAttrValueMapper
,
PmsProductAttrValue
>
implements
IPmsProduct
AttrValueService
{
}
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/Pms
Spu
ServiceImpl.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/Pms
Product
ServiceImpl.java
浏览文件 @
e7aa2678
...
...
@@ -8,7 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.youlai.mall.pms.bo.app.ProductBO
;
import
com.youlai.mall.pms.mapper.Pms
Spu
Mapper
;
import
com.youlai.mall.pms.mapper.Pms
Product
Mapper
;
import
com.youlai.mall.pms.pojo.domain.*
;
import
com.youlai.mall.pms.pojo.dto.SpuDTO
;
import
com.youlai.mall.pms.service.*
;
...
...
@@ -26,17 +26,17 @@ import java.util.stream.Collectors;
*/
@Service
@AllArgsConstructor
public
class
Pms
SpuServiceImpl
extends
ServiceImpl
<
PmsSpuMapper
,
PmsSpu
>
implements
IPmsSpu
Service
{
public
class
Pms
ProductServiceImpl
extends
ServiceImpl
<
PmsProductMapper
,
PmsProduct
>
implements
IPmsProduct
Service
{
private
IPms
SkuService
iPmsSku
Service
;
private
IPms
SpuAttrValueService
iPmsSpu
AttrValueService
;
private
IPms
SpuSpecValueService
iPmsSpu
SpecValueService
;
private
IPms
InventoryService
iPmsInventory
Service
;
private
IPms
ProductAttrValueService
iPmsProduct
AttrValueService
;
private
IPms
ProductSpecValueService
iPmsProduct
SpecValueService
;
private
IPmsCategorySpecService
iPmsCategorySpecService
;
@Override
public
IPage
<
Pms
Spu
>
list
(
Page
<
PmsSpu
>
page
,
PmsSpu
spu
)
{
List
<
Pms
Spu
>
list
=
this
.
baseMapper
.
list
(
page
,
spu
);
public
IPage
<
Pms
Product
>
list
(
Page
<
PmsProduct
>
page
,
PmsProduct
spu
)
{
List
<
Pms
Product
>
list
=
this
.
baseMapper
.
list
(
page
,
spu
);
page
.
setRecords
(
list
);
return
page
;
}
...
...
@@ -45,12 +45,12 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
@Transactional
public
boolean
add
(
com
.
youlai
.
mall
.
pms
.
bo
.
admin
.
ProductBO
spuBO
)
{
SpuDTO
spuDTO
=
spuBO
.
getSpu
();
List
<
Pms
Spu
AttrValue
>
attrs
=
spuBO
.
getAttrs
();
List
<
Pms
Spu
SpecValue
>
specs
=
spuBO
.
getSpecs
();
List
<
Pms
Sku
>
skuList
=
spuBO
.
getSkuList
();
List
<
Pms
Product
AttrValue
>
attrs
=
spuBO
.
getAttrs
();
List
<
Pms
Product
SpecValue
>
specs
=
spuBO
.
getSpecs
();
List
<
Pms
Inventory
>
skuList
=
spuBO
.
getSkuList
();
// spu保存
Pms
Spu
spu
=
new
PmsSpu
();
Pms
Product
spu
=
new
PmsProduct
();
BeanUtil
.
copyProperties
(
spuDTO
,
spu
);
if
(
spuDTO
.
getPicUrls
()
!=
null
)
{
String
picUrls
=
JSONUtil
.
toJsonStr
(
spuDTO
.
getPicUrls
());
...
...
@@ -60,20 +60,20 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
// 属性保存
Optional
.
ofNullable
(
attrs
).
ifPresent
(
list
->
{
list
.
forEach
(
item
->
item
.
set
Spu
Id
(
spu
.
getId
()));
iPms
Spu
AttrValueService
.
saveBatch
(
list
);
list
.
forEach
(
item
->
item
.
set
Product
Id
(
spu
.
getId
()));
iPms
Product
AttrValueService
.
saveBatch
(
list
);
});
// 规格保存
Optional
.
ofNullable
(
specs
).
ifPresent
(
list
->
{
list
.
forEach
(
item
->
item
.
set
Spu
Id
(
spu
.
getId
()));
iPms
Spu
SpecValueService
.
saveBatch
(
list
);
list
.
forEach
(
item
->
item
.
set
Product
Id
(
spu
.
getId
()));
iPms
Product
SpecValueService
.
saveBatch
(
list
);
});
// sku保存
Optional
.
ofNullable
(
skuList
).
ifPresent
(
list
->
{
list
.
forEach
(
item
->
item
.
set
Spu
Id
(
spu
.
getId
()));
iPms
Sku
Service
.
saveBatch
(
skuList
);
list
.
forEach
(
item
->
item
.
set
Product
Id
(
spu
.
getId
()));
iPms
Inventory
Service
.
saveBatch
(
skuList
);
});
return
true
;
...
...
@@ -83,7 +83,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
public
com
.
youlai
.
mall
.
pms
.
bo
.
admin
.
ProductBO
getBySpuId
(
Long
id
)
{
// spu
SpuDTO
spuDTO
=
new
SpuDTO
();
Pms
Spu
spu
=
this
.
getById
(
id
);
Pms
Product
spu
=
this
.
getById
(
id
);
BeanUtil
.
copyProperties
(
spu
,
spuDTO
);
if
(
StrUtil
.
isNotBlank
(
spu
.
getPicUrls
()))
{
...
...
@@ -93,12 +93,12 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
}
// 属性
List
<
Pms
SpuAttrValue
>
attrs
=
iPmsSpu
AttrValueService
.
list
(
new
LambdaQueryWrapper
<
Pms
SpuAttrValue
>().
eq
(
PmsSpuAttrValue:
:
getSpu
Id
,
id
));
List
<
Pms
ProductAttrValue
>
attrs
=
iPmsProduct
AttrValueService
.
list
(
new
LambdaQueryWrapper
<
Pms
ProductAttrValue
>().
eq
(
PmsProductAttrValue:
:
getProduct
Id
,
id
));
// 规格
List
<
Pms
SpuSpecValue
>
specs
=
iPmsSpuSpecValueService
.
list
(
new
LambdaQueryWrapper
<
PmsSpuSpecValue
>().
eq
(
PmsSpuSpecValue:
:
getSpu
Id
,
id
));
List
<
Pms
ProductSpecValue
>
specs
=
iPmsProductSpecValueService
.
list
(
new
LambdaQueryWrapper
<
PmsProductSpecValue
>().
eq
(
PmsProductSpecValue:
:
getProduct
Id
,
id
));
// sku
List
<
Pms
Sku
>
skuList
=
iPmsSkuService
.
list
(
new
LambdaQueryWrapper
<
PmsSku
>().
eq
(
PmsSku:
:
getSpu
Id
,
id
));
List
<
Pms
Inventory
>
skuList
=
iPmsInventoryService
.
list
(
new
LambdaQueryWrapper
<
PmsInventory
>().
eq
(
PmsInventory:
:
getProduct
Id
,
id
));
// 组合
com
.
youlai
.
mall
.
pms
.
bo
.
admin
.
ProductBO
spuBO
=
new
com
.
youlai
.
mall
.
pms
.
bo
.
admin
.
ProductBO
(
spuDTO
,
attrs
,
specs
,
skuList
);
...
...
@@ -110,12 +110,12 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
public
boolean
updateById
(
com
.
youlai
.
mall
.
pms
.
bo
.
admin
.
ProductBO
spuBO
)
{
SpuDTO
spuDTO
=
spuBO
.
getSpu
();
List
<
Pms
Spu
AttrValue
>
attrs
=
spuBO
.
getAttrs
();
List
<
Pms
Spu
SpecValue
>
specs
=
spuBO
.
getSpecs
();
List
<
Pms
Sku
>
skuList
=
spuBO
.
getSkuList
();
List
<
Pms
Product
AttrValue
>
attrs
=
spuBO
.
getAttrs
();
List
<
Pms
Product
SpecValue
>
specs
=
spuBO
.
getSpecs
();
List
<
Pms
Inventory
>
skuList
=
spuBO
.
getSkuList
();
// spu保存
Pms
Spu
spu
=
new
PmsSpu
();
Pms
Product
spu
=
new
PmsProduct
();
BeanUtil
.
copyProperties
(
spuDTO
,
spu
);
if
(
spuDTO
.
getPicUrls
()
!=
null
)
{
String
picUrls
=
JSONUtil
.
toJsonStr
(
spuDTO
.
getPicUrls
());
...
...
@@ -125,53 +125,53 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
// 属性保存
Optional
.
ofNullable
(
attrs
).
ifPresent
(
list
->
{
list
.
forEach
(
item
->
item
.
set
Spu
Id
(
spu
.
getId
()));
list
.
forEach
(
item
->
item
.
set
Product
Id
(
spu
.
getId
()));
// 删除此次保存删除的
List
<
Long
>
ids
=
list
.
stream
().
map
(
item
->
item
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
Long
>
dbIds
=
iPms
SpuAttrValueService
.
list
(
new
LambdaQueryWrapper
<
PmsSpuAttrValue
>().
eq
(
PmsSpuAttrValue:
:
getSpu
Id
,
spu
.
getId
())
.
select
(
Pms
Spu
AttrValue:
:
getId
))
List
<
Long
>
dbIds
=
iPms
ProductAttrValueService
.
list
(
new
LambdaQueryWrapper
<
PmsProductAttrValue
>().
eq
(
PmsProductAttrValue:
:
getProduct
Id
,
spu
.
getId
())
.
select
(
Pms
Product
AttrValue:
:
getId
))
.
stream
()
.
map
(
item
->
item
.
getId
())
.
collect
(
Collectors
.
toList
());
List
<
Long
>
removeIds
=
dbIds
.
stream
().
filter
(
id
->
!
ids
.
contains
(
id
)).
collect
(
Collectors
.
toList
());
iPms
Spu
AttrValueService
.
removeByIds
(
removeIds
);
iPms
Product
AttrValueService
.
removeByIds
(
removeIds
);
iPms
Spu
AttrValueService
.
saveOrUpdateBatch
(
list
);
iPms
Product
AttrValueService
.
saveOrUpdateBatch
(
list
);
});
// 规格保存
Optional
.
ofNullable
(
specs
).
ifPresent
(
list
->
{
list
.
forEach
(
item
->
item
.
set
Spu
Id
(
spu
.
getId
()));
list
.
forEach
(
item
->
item
.
set
Product
Id
(
spu
.
getId
()));
// 删除此次保存删除的
List
<
Long
>
ids
=
list
.
stream
().
map
(
item
->
item
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
Long
>
dbIds
=
iPms
SpuSpecValueService
.
list
(
new
LambdaQueryWrapper
<
PmsSpuSpecValue
>().
eq
(
PmsSpuSpecValue:
:
getSpu
Id
,
spu
.
getId
())
.
select
(
Pms
Spu
SpecValue:
:
getId
))
List
<
Long
>
dbIds
=
iPms
ProductSpecValueService
.
list
(
new
LambdaQueryWrapper
<
PmsProductSpecValue
>().
eq
(
PmsProductSpecValue:
:
getProduct
Id
,
spu
.
getId
())
.
select
(
Pms
Product
SpecValue:
:
getId
))
.
stream
()
.
map
(
item
->
item
.
getId
())
.
collect
(
Collectors
.
toList
());
List
<
Long
>
removeIds
=
dbIds
.
stream
().
filter
(
id
->
!
ids
.
contains
(
id
)).
collect
(
Collectors
.
toList
());
iPms
Spu
SpecValueService
.
removeByIds
(
removeIds
);
iPms
Product
SpecValueService
.
removeByIds
(
removeIds
);
iPms
Spu
SpecValueService
.
saveOrUpdateBatch
(
list
);
iPms
Product
SpecValueService
.
saveOrUpdateBatch
(
list
);
});
// sku保存
Optional
.
ofNullable
(
skuList
).
ifPresent
(
list
->
{
list
.
forEach
(
item
->
item
.
set
Spu
Id
(
spu
.
getId
()));
list
.
forEach
(
item
->
item
.
set
Product
Id
(
spu
.
getId
()));
// 删除此次保存删除的
List
<
Long
>
ids
=
list
.
stream
().
map
(
item
->
item
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
Long
>
dbIds
=
iPms
SkuService
.
list
(
new
LambdaQueryWrapper
<
PmsSku
>().
eq
(
PmsSku:
:
getSpu
Id
,
spu
.
getId
())
.
select
(
Pms
Sku
:
:
getId
))
List
<
Long
>
dbIds
=
iPms
InventoryService
.
list
(
new
LambdaQueryWrapper
<
PmsInventory
>().
eq
(
PmsInventory:
:
getProduct
Id
,
spu
.
getId
())
.
select
(
Pms
Inventory
:
:
getId
))
.
stream
()
.
map
(
item
->
item
.
getId
())
.
collect
(
Collectors
.
toList
());
List
<
Long
>
removeIds
=
dbIds
.
stream
().
filter
(
id
->
!
ids
.
contains
(
id
)).
collect
(
Collectors
.
toList
());
iPms
Sku
Service
.
removeByIds
(
removeIds
);
iPms
Inventory
Service
.
removeByIds
(
removeIds
);
iPms
Sku
Service
.
saveOrUpdateBatch
(
skuList
);
iPms
Inventory
Service
.
saveOrUpdateBatch
(
skuList
);
});
return
true
;
}
...
...
@@ -181,11 +181,11 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
Optional
.
ofNullable
(
spuIds
).
ifPresent
(
ids
->
ids
.
forEach
(
spuId
->
{
// sku
iPms
SkuService
.
remove
(
new
LambdaQueryWrapper
<
PmsSku
>().
eq
(
PmsSku:
:
getSpu
Id
,
spuId
));
iPms
InventoryService
.
remove
(
new
LambdaQueryWrapper
<
PmsInventory
>().
eq
(
PmsInventory:
:
getProduct
Id
,
spuId
));
// 规格
iPms
SpuSpecValueService
.
remove
(
new
LambdaQueryWrapper
<
PmsSpuSpecValue
>().
eq
(
PmsSpu
SpecValue:
:
getId
,
spuId
));
iPms
ProductSpecValueService
.
remove
(
new
LambdaQueryWrapper
<
PmsProductSpecValue
>().
eq
(
PmsProduct
SpecValue:
:
getId
,
spuId
));
// 属性
iPms
SpuAttrValueService
.
remove
(
new
LambdaQueryWrapper
<
PmsSpuAttrValue
>().
eq
(
PmsSpuAttrValue:
:
getSpu
Id
,
spuId
));
iPms
ProductAttrValueService
.
remove
(
new
LambdaQueryWrapper
<
PmsProductAttrValue
>().
eq
(
PmsProductAttrValue:
:
getProduct
Id
,
spuId
));
// spu
this
.
removeById
(
spuId
);
})
...
...
@@ -196,7 +196,7 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
@Override
public
ProductBO
getProductByIdForApp
(
Long
spuId
)
{
// spu
Pms
Spu
spu
=
this
.
getById
(
spuId
);
Pms
Product
spu
=
this
.
getById
(
spuId
);
SpuDTO
spuDTO
=
new
SpuDTO
();
BeanUtil
.
copyProperties
(
spu
,
spuDTO
);
if
(
StrUtil
.
isNotBlank
(
spu
.
getPicUrls
()))
{
...
...
@@ -205,16 +205,16 @@ public class PmsSpuServiceImpl extends ServiceImpl<PmsSpuMapper, PmsSpu> impleme
spuDTO
.
setPicUrls
(
pics
);
}
// 属性
List
<
Pms
SpuAttrValue
>
attrs
=
iPmsSpu
AttrValueService
.
list
(
new
LambdaQueryWrapper
<
Pms
Spu
AttrValue
>(
).
eq
(
Pms
SpuAttrValue:
:
getSpu
Id
,
spuId
)
List
<
Pms
ProductAttrValue
>
attrs
=
iPmsProduct
AttrValueService
.
list
(
new
LambdaQueryWrapper
<
Pms
Product
AttrValue
>(
).
eq
(
Pms
ProductAttrValue:
:
getProduct
Id
,
spuId
)
);
// 规格
List
<
PmsCategorySpec
>
specs
=
iPmsCategorySpecService
.
listBySpuId
(
spuId
);
// sku
List
<
Pms
Sku
>
skuList
=
iPmsSkuService
.
list
(
new
LambdaQueryWrapper
<
PmsSku
>().
eq
(
PmsSku:
:
getSpu
Id
,
spuId
));
List
<
Pms
Inventory
>
skuList
=
iPmsInventoryService
.
list
(
new
LambdaQueryWrapper
<
PmsInventory
>().
eq
(
PmsInventory:
:
getProduct
Id
,
spuId
));
ProductBO
product
=
new
ProductBO
(
spuDTO
,
attrs
,
specs
,
skuList
);
return
product
;
...
...
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/Pms
Spu
SpecValueServiceImpl.java
→
mall-pms/pms-boot/src/main/java/com/youlai/mall/pms/service/impl/Pms
Product
SpecValueServiceImpl.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.service.impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
SpecValue
;
import
com.youlai.mall.pms.mapper.Pms
Spu
SpecValueMapper
;
import
com.youlai.mall.pms.service.IPms
Spu
SpecValueService
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
SpecValue
;
import
com.youlai.mall.pms.mapper.Pms
Product
SpecValueMapper
;
import
com.youlai.mall.pms.service.IPms
Product
SpecValueService
;
import
org.springframework.stereotype.Service
;
/**
...
...
@@ -11,6 +11,6 @@ import org.springframework.stereotype.Service;
* @date 2020-11-06
*/
@Service
public
class
Pms
SpuSpecValueServiceImpl
extends
ServiceImpl
<
PmsSpuSpecValueMapper
,
PmsSpuSpecValue
>
implements
IPmsSpu
SpecValueService
{
public
class
Pms
ProductSpecValueServiceImpl
extends
ServiceImpl
<
PmsProductSpecValueMapper
,
PmsProductSpecValue
>
implements
IPmsProduct
SpecValueService
{
}
mall-pms/pms-boot/src/main/resources/mapper/PmsSkuDao.xml
浏览文件 @
e7aa2678
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.youlai.mall.pms.mapper.Pms
Sku
Mapper"
>
<mapper
namespace=
"com.youlai.mall.pms.mapper.Pms
Inventory
Mapper"
>
<update
id=
"lockStock"
>
update pms_sku
...
...
@@ -45,4 +45,4 @@
</foreach>
</where>
</select>
</mapper>
\ No newline at end of file
</mapper>
mall-pms/pms-boot/src/test/java/com/youlai/mall/pms/controller/ProductControllerTest.java
浏览文件 @
e7aa2678
...
...
@@ -4,9 +4,9 @@ import com.youlai.common.result.ResultCode;
import
com.youlai.mall.pms.bo.app.ProductBO
;
import
com.youlai.mall.pms.controller.admin.ProductController
;
import
com.youlai.mall.pms.pojo.domain.PmsCategorySpec
;
import
com.youlai.mall.pms.service.IPms
Spu
AttrValueService
;
import
com.youlai.mall.pms.service.IPms
Product
AttrValueService
;
import
com.youlai.mall.pms.service.IPmsCategorySpecService
;
import
com.youlai.mall.pms.service.IPms
Spu
Service
;
import
com.youlai.mall.pms.service.IPms
Product
Service
;
import
lombok.extern.slf4j.Slf4j
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -60,16 +60,16 @@ public class ProductControllerTest {
}
@Autowired
public
IPms
SpuAttrValueService
iPmsSpu
AttrValueService
;
public
IPms
ProductAttrValueService
iPmsProduct
AttrValueService
;
@Autowired
private
IPms
SpuService
iPmsSpu
Service
;
private
IPms
ProductService
iPmsProduct
Service
;
@Test
public
void
getProduct
()
{
ProductBO
product
=
iPms
Spu
Service
.
getProductByIdForApp
(
1
l
);
ProductBO
product
=
iPms
Product
Service
.
getProductByIdForApp
(
1
l
);
log
.
info
(
product
.
toString
());
}
}
mall-pms/pms-search/src/main/java/com/youlai/mall/pms/search/service/IPmsSearchService.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.search.service
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
;
import
java.io.IOException
;
import
java.util.List
;
...
...
@@ -13,7 +13,7 @@ public interface IPmsSearchService {
* @return
* @throws IOException
*/
Pms
Spu
searchSpuById
(
String
id
)
throws
IOException
;
Pms
Product
searchSpuById
(
String
id
)
throws
IOException
;
/**
* 根据商品名称关键字搜索商品
...
...
@@ -21,5 +21,5 @@ public interface IPmsSearchService {
* @param key 商品名称关键字
* @return SKU商品集合
*/
List
<
Pms
Spu
>
searchSpuByKey
(
String
key
)
throws
IOException
;
List
<
Pms
Product
>
searchSpuByKey
(
String
key
)
throws
IOException
;
}
mall-pms/pms-search/src/main/java/com/youlai/mall/pms/search/service/impl/PmsSearchServiceImpl.java
浏览文件 @
e7aa2678
package
com.youlai.mall.pms.search.service.impl
;
import
com.youlai.mall.pms.pojo.domain.Pms
Spu
;
import
com.youlai.mall.pms.pojo.domain.Pms
Product
;
import
com.youlai.mall.pms.search.service.IPmsSearchService
;
import
com.youlai.mall.pms.search.utils.ElasticsearchConvertUtils
;
import
com.youlai.mall.pms.search.utils.ElasticsearchUtils
;
...
...
@@ -24,17 +24,17 @@ public class PmsSearchServiceImpl implements IPmsSearchService {
private
ElasticsearchUtils
elasticsearchUtils
;
@Override
public
Pms
Spu
searchSpuById
(
String
id
)
throws
IOException
{
public
Pms
Product
searchSpuById
(
String
id
)
throws
IOException
{
log
.
info
(
"根据文档id查询商品信息,id:{}"
,
id
);
return
elasticsearchUtils
.
findById
(
PMS_SPU
,
id
,
Pms
Spu
.
class
);
return
elasticsearchUtils
.
findById
(
PMS_SPU
,
id
,
Pms
Product
.
class
);
}
@Override
public
List
<
Pms
Spu
>
searchSpuByKey
(
String
key
)
throws
IOException
{
public
List
<
Pms
Product
>
searchSpuByKey
(
String
key
)
throws
IOException
{
log
.
info
(
"根据商品名称查询商品信息,name:{}"
,
key
);
SearchSourceBuilder
builder
=
new
SearchSourceBuilder
();
builder
.
query
(
QueryBuilders
.
matchQuery
(
"name"
,
key
));
SearchHits
<
Pms
Spu
>
searchHits
=
elasticsearchUtils
.
search
(
PMS_SPU
,
PmsSpu
.
class
,
builder
.
query
());
SearchHits
<
Pms
Product
>
searchHits
=
elasticsearchUtils
.
search
(
PMS_SPU
,
PmsProduct
.
class
,
builder
.
query
());
return
ElasticsearchConvertUtils
.
searchHitsConvertDataList
(
searchHits
);
}
}
youlai-common/common-core/src/main/java/com/youlai/common/enums/BusinessTypeEnum.java
浏览文件 @
e7aa2678
...
...
@@ -5,7 +5,7 @@ import lombok.Setter;
/**
* @author haoxr
* @date 2021-02-17
13:13
* @date 2021-02-17
*/
public
enum
BusinessTypeEnum
{
...
...
youlai-common/common-core/src/main/java/com/youlai/common/enums/QueryModeEnum.java
浏览文件 @
e7aa2678
...
...
@@ -5,17 +5,17 @@ import lombok.Setter;
public
enum
QueryModeEnum
{
PAGE
(
"page"
,
"分页查询"
),
LIST
(
"list"
,
"列表查询"
),
TREE
(
"tree"
,
"树形列表"
),
CASCADER
(
"cascader"
,
"级联列表"
),
//
对应级联选择器的下拉格式数据
ROUTER
(
"router"
,
"路由列表"
)
;
PAGE
(
"page"
),
// 分页查询
LIST
(
"list"
),
//列表查询
TREE
(
"tree"
),
//树形列表
CASCADER
(
"cascader"
),
// 级联列表
对应级联选择器的下拉格式数据
ROUTER
(
"router"
)
;
// 路由列表
@Getter
@Setter
private
String
code
;
QueryModeEnum
(
String
code
,
String
desc
)
{
QueryModeEnum
(
String
code
)
{
this
.
code
=
code
;
}
...
...
youlai-common/common-web/src/main/resources/logback-spring.xml
浏览文件 @
e7aa2678
...
...
@@ -13,7 +13,8 @@
</pattern>
</encoder>
</appender>
<!-- -->
<!-- Logstash收集日志输出到ElasticSearch -->
<appender
name=
"LOGIN_LOGSTASH"
class=
"net.logstash.logback.appender.LogstashTcpSocketAppender"
>
<destination>
g.youlai.store:5044
</destination>
<encoder
charset=
"UTF-8"
class=
"net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder"
>
...
...
@@ -33,7 +34,7 @@
"class": "%logger",
"message": "%message",
"stack_trace": "%exception{20}",
"a
ppname": "login"
<!-- 登录日志记录索引名 logstash-%{appname
}-yyyy.MM.dd -->
"a
ction": "login"
<!-- 自定义字段 登录日志索引名 logstash-%{action
}-yyyy.MM.dd -->
}
</pattern>
</pattern>
...
...
@@ -42,12 +43,12 @@
<keepAliveDuration>
5 minutes
</keepAliveDuration>
</appender>
<!-- additivity="false" 不会将日志反馈到root中 -->
<logger
name=
"com.youlai.common.web.aspect.LoginLogAspect"
level=
"INFO"
additivity=
"false"
>
<appender-ref
ref=
"CONSOLE"
/>
<!-- additivity="true" 默认是true 会向上传递至root -->
<logger
name=
"com.youlai.common.web.aspect.LoginLogAspect"
level=
"INFO"
additivity=
"true"
>
<appender-ref
ref=
"LOGIN_LOGSTASH"
/>
</logger>
<!-- 根logger -->
<root
level=
"INFO"
>
<appender-ref
ref=
"CONSOLE"
/>
</root>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录