Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
platform
/
platform-shopmall-parent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bf6b4e71
authored
Apr 26, 2023
by
刘宇峰
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
同步商品信息-优化代码
1 parent
ad3fe834
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
7 deletions
platform-shopmall-api/src/main/java/cn/com/glsx/admin/api/ShopmallGoodsApiService.java
platform-shopmall/src/main/java/cn/com/glsx/admin/modules/api/GoodsApiController.java
platform-shopmall/src/main/java/cn/com/glsx/admin/modules/service/GoodsService.java
platform-shopmall/src/test/java/cn/com/glsx/admin/modules/service/GoodsServiceTest.java
platform-shopmall-api/src/main/java/cn/com/glsx/admin/api/ShopmallGoodsApiService.java
View file @
bf6b4e7
...
@@ -100,7 +100,7 @@ public interface ShopmallGoodsApiService {
...
@@ -100,7 +100,7 @@ public interface ShopmallGoodsApiService {
public
List
<
QueryGoodsSaleLimitListResponse
>
queryGoodsSaleLimitList
(
@RequestParam
(
"goodsSkuCodes"
)
List
<
String
>
goodsSkuCodes
);
public
List
<
QueryGoodsSaleLimitListResponse
>
queryGoodsSaleLimitList
(
@RequestParam
(
"goodsSkuCodes"
)
List
<
String
>
goodsSkuCodes
);
@GetMapping
(
value
=
"/syncGoodsListData"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@GetMapping
(
value
=
"/syncGoodsListData"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Integer
syncGoodsListData
();
public
Integer
syncGoodsListData
(
@RequestBody
List
<
String
>
goodsSkuCodes
);
@PostMapping
(
value
=
"/syncGoodsInfoData"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
@PostMapping
(
value
=
"/syncGoodsInfoData"
,
produces
=
MediaType
.
APPLICATION_JSON_VALUE
)
public
Integer
syncGoodsInfoData
(
@RequestBody
List
<
String
>
goodsSkuCodes
);
public
Integer
syncGoodsInfoData
(
@RequestBody
List
<
String
>
goodsSkuCodes
);
...
...
platform-shopmall/src/main/java/cn/com/glsx/admin/modules/api/GoodsApiController.java
View file @
bf6b4e7
...
@@ -80,8 +80,8 @@ public class GoodsApiController implements ShopmallGoodsApiService {
...
@@ -80,8 +80,8 @@ public class GoodsApiController implements ShopmallGoodsApiService {
@Operation
(
summary
=
"同步全部商品数据接口"
)
@Operation
(
summary
=
"同步全部商品数据接口"
)
@Override
@Override
public
Integer
syncGoodsListData
()
{
public
Integer
syncGoodsListData
(
List
<
String
>
goodsSkuCodes
)
{
return
goodsService
.
syncGoodsListData
();
return
goodsService
.
syncGoodsListData
(
goodsSkuCodes
);
}
}
@Operation
(
summary
=
"同步特定商品数据接口"
)
@Operation
(
summary
=
"同步特定商品数据接口"
)
...
...
platform-shopmall/src/main/java/cn/com/glsx/admin/modules/service/GoodsService.java
View file @
bf6b4e7
...
@@ -194,13 +194,17 @@ public class GoodsService implements InitializingBean {
...
@@ -194,13 +194,17 @@ public class GoodsService implements InitializingBean {
*
*
* @return
* @return
*/
*/
public
Integer
syncGoodsListData
()
{
public
Integer
syncGoodsListData
(
List
<
String
>
goodsSkuCodes
)
{
log
.
info
(
"开始同步商品数据"
);
log
.
info
(
"开始同步全部商品数据"
);
QueryGoodsListResponse
totalListResponse
=
cloudCraneService
.
queryGoodsList
(
new
QueryGoodsListRequest
(
1
,
100
));
QueryGoodsListByConditionRequest
conditionRequest
=
new
QueryGoodsListByConditionRequest
();
conditionRequest
.
setPageNum
(
1
);
conditionRequest
.
setPageSize
(
100
);
QueryGoodsListByConditionResponse
totalListResponse
=
cloudCraneService
.
queryGoodsListByCondition
(
conditionRequest
);
Integer
totalCount
=
totalListResponse
.
getTotalCount
();
Integer
totalCount
=
totalListResponse
.
getTotalCount
();
Integer
totalPage
=
totalListResponse
.
getTotalPage
();
Integer
totalPage
=
totalListResponse
.
getTotalPage
();
log
.
info
(
"商品数据{}条,{}页"
,
totalCount
,
totalPage
);
log
.
info
(
"商品数据{}条,{}页"
,
totalCount
,
totalPage
);
if
(
CollectionUtils
.
isNotEmpty
(
totalListResponse
.
getGoodsSkuList
()))
{
List
<
String
>
goodsSkuCodeList
=
totalListResponse
.
getGoodsSkuList
().
stream
().
map
(
GoodsSkuListItem:
:
getGoodsSkuCode
).
collect
(
Collectors
.
toList
());
List
<
String
>
goodsSkuCodeList
=
totalListResponse
.
getGoodsSkuList
().
stream
().
map
(
GoodsSkuListItem:
:
getGoodsSkuCode
).
collect
(
Collectors
.
toList
());
//同步第一页
//同步第一页
Integer
syncCnt
=
syncGoodsInfoData
(
goodsSkuCodeList
,
false
);
Integer
syncCnt
=
syncGoodsInfoData
(
goodsSkuCodeList
,
false
);
...
@@ -215,6 +219,8 @@ public class GoodsService implements InitializingBean {
...
@@ -215,6 +219,8 @@ public class GoodsService implements InitializingBean {
}
}
return
syncCnt
;
return
syncCnt
;
}
}
return
0
;
}
/**
/**
* 同步特定商品(供本系统、定时任务调用)
* 同步特定商品(供本系统、定时任务调用)
...
...
platform-shopmall/src/test/java/cn/com/glsx/admin/modules/service/GoodsServiceTest.java
View file @
bf6b4e7
...
@@ -52,7 +52,7 @@ public class GoodsServiceTest {
...
@@ -52,7 +52,7 @@ public class GoodsServiceTest {
@Test
@Test
public
void
testSyncAllGoods
()
{
public
void
testSyncAllGoods
()
{
goodsService
.
syncGoodsListData
();
goodsService
.
syncGoodsListData
(
null
);
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment