Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
0282e820
提交
0282e820
authored
12月 03, 2020
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
c18231dd
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
44 行增加
和
37 行删除
+44
-37
ItemController.java
...a/com/example/afrishop_v3/controllers/ItemController.java
+44
-37
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/ItemController.java
浏览文件 @
0282e820
...
...
@@ -46,21 +46,21 @@ public class ItemController {
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"6"
)
Integer
pageSize
,
@RequestParam
(
value
=
"order"
,
required
=
false
)
String
order
)
{
return
new
Result
<>(
repository
.
findAllItems
(
PageRequest
.
of
(
pageNum
,
pageSize
)));
return
new
Result
<>(
repository
.
findAllItems
(
PageRequest
.
of
(
pageNum
,
pageSize
)));
}
@GetMapping
(
"/queryItemsByTypeTwo"
)
public
Result
queryItemsByTypeTwo
(
@RequestParam
(
"typeTwoId"
)
String
typeTwoId
,
public
Result
queryItemsByTypeTwo
(
@RequestParam
(
"typeTwoId"
)
String
typeTwoId
,
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"0"
)
Integer
pageNum
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"6"
)
Integer
pageSize
,
@RequestParam
(
value
=
"order"
,
required
=
false
)
String
order
)
{
return
new
Result
<>(
repository
.
findAllByItemCategorytwo
(
typeTwoId
,
PageRequest
.
of
(
pageNum
,
pageSize
,
getSort
(
order
))));
return
new
Result
<>(
repository
.
findAllByItemCategorytwo
(
typeTwoId
,
PageRequest
.
of
(
pageNum
,
pageSize
,
getSort
(
order
))));
}
@GetMapping
(
"/queryCategoryTwoByCid/{categoryId}"
)
public
Result
queryCategoryTwoByCid
(
@PathVariable
(
"categoryId"
)
String
categoryId
)
{
public
Result
queryCategoryTwoByCid
(
@PathVariable
(
"categoryId"
)
String
categoryId
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Optional
<
TbCfGoodstype
>
byId
=
goodstypeRepository
.
findById
(
categoryId
);
...
...
@@ -89,15 +89,21 @@ public class ItemController {
try
{
List
<
SearchModel
>
list
=
repository
.
searchAllItems
(
name
,
pageNum
*
pageSize
,
pageSize
);
List
<
SearchModel
>
list
=
repository
.
searchAllItems
(
name
,
pageNum
*
pageSize
,
pageSize
);
Long
count
=
repository
.
countAllBySearchItems
(
name
);
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"content"
,
list
);
map
.
put
(
"totalPage"
,
count
);
Long
totalPage
=
0L
;
if
(
count
%
pageSize
==
0
)
{
totalPage
=
count
/
pageSize
;
}
else
{
totalPage
=
count
/
pageSize
+
1
;
}
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"content"
,
list
);
map
.
put
(
"totalPage"
,
totalPage
);
return
new
Result
<>(
map
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
getMessage
());
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
e
.
getMessage
());
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
e
.
getMessage
());
}
}
...
...
@@ -114,53 +120,54 @@ public class ItemController {
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"12"
)
Integer
pageSize
)
{
Optional
<
TbCfStationItem
>
byId
=
repository
.
findById
(
itemId
);
if
(
byId
.
isPresent
()
)
{
if
(
byId
.
isPresent
()
)
{
TbCfStationItem
stationItem
=
byId
.
get
();
Page
<
TbCfStationItem
>
recommendItems
=
repository
.
getRecommendItems
(
itemId
,
stationItem
.
getItemDescritionId
(),
stationItem
.
getItemCategorytwo
(),
stationItem
.
getItemCategory
(),
PageRequest
.
of
(
pageNum
,
pageSize
));
return
new
Result
<>(
recommendItems
);
}
return
new
Result
<>(
new
ArrayList
<>(),
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getCode
(),
"Item id is invalid or not found"
);
return
new
Result
<>(
new
ArrayList
<>(),
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getCode
(),
"Item id is invalid or not found"
);
}
@GetMapping
(
"/queryItemByDescription/{descriptionId}"
)
public
Result
queryItemByDescription
(
@PathVariable
(
"descriptionId"
)
String
descriptionId
,
@RequestParam
(
value
=
"order"
,
required
=
false
)
String
order
)
{
return
new
Result
<>(
repository
.
findAllByItemDescritionId
(
descriptionId
,
getSort
(
order
)));
return
new
Result
<>(
repository
.
findAllByItemDescritionId
(
descriptionId
,
getSort
(
order
)));
}
@GetMapping
(
"/queryItemsByTypeThree"
)
public
Result
queryItemsByTypeThree
(
@RequestParam
(
"typeThreeId"
)
String
typeThreeId
,
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"0"
)
Integer
pageNum
,
public
Result
queryItemsByTypeThree
(
@RequestParam
(
"typeThreeId"
)
String
typeThreeId
,
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"0"
)
Integer
pageNum
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"6"
)
Integer
pageSize
,
@RequestParam
(
value
=
"order"
,
required
=
false
)
String
order
)
{
return
new
Result
<>(
repository
.
findAllByItemDescritionId
(
typeThreeId
,
PageRequest
.
of
(
pageNum
,
pageSize
,
getSort
(
order
))));
return
new
Result
<>(
repository
.
findAllByItemDescritionId
(
typeThreeId
,
PageRequest
.
of
(
pageNum
,
pageSize
,
getSort
(
order
))));
}
private
Sort
getSort
(
String
order
){
return
"priceUp"
.
equals
(
order
)
?
sort
(
"asc"
)
:
"priceDown"
.
equals
(
order
)
?
sort
(
"desc"
)
:
sort
(
order
,
"createTime"
);
private
Sort
getSort
(
String
order
)
{
return
"priceUp"
.
equals
(
order
)
?
sort
(
"asc"
)
:
"priceDown"
.
equals
(
order
)
?
sort
(
"desc"
)
:
sort
(
order
,
"createTime"
);
}
private
Sort
sort
(
String
order
){
private
Sort
sort
(
String
order
)
{
String
col
=
"discountPrice"
;
return
sort
(
order
,
col
);
return
sort
(
order
,
col
);
}
private
Sort
sort
(
String
order
,
String
col
)
{
return
Sort
.
by
(
order
(
order
,
col
));
private
Sort
sort
(
String
order
,
String
col
)
{
return
Sort
.
by
(
order
(
order
,
col
));
}
private
Sort
.
Order
order
(
String
order
,
String
col
)
{
return
"desc"
.
equals
(
order
)
?
desc
(
col
)
:
asc
(
col
);
private
Sort
.
Order
order
(
String
order
,
String
col
)
{
return
"desc"
.
equals
(
order
)
?
desc
(
col
)
:
asc
(
col
);
}
private
Sort
sort2
(
String
order
){
String
[]
cols
=
new
String
[]{
"itemTop"
,
"discountPrice"
,
"createTime"
};
private
Sort
sort2
(
String
order
)
{
String
[]
cols
=
new
String
[]{
"itemTop"
,
"discountPrice"
,
"createTime"
};
List
<
Sort
.
Order
>
list
=
new
ArrayList
<>();
for
(
String
col
:
cols
){
list
.
add
(
order
(
order
,
col
)
);
for
(
String
col
:
cols
)
{
list
.
add
(
order
(
order
,
col
)
);
}
return
Sort
.
by
(
list
);
...
...
@@ -171,18 +178,18 @@ public class ItemController {
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"0"
)
Integer
pageNum
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"6"
)
Integer
pageSize
,
@RequestParam
(
value
=
"order"
,
required
=
false
)
String
order
)
{
return
new
Result
<>(
repository
.
findAllByItemLabelContaining
(
label
,
PageRequest
.
of
(
pageNum
,
pageSize
,
getSort
(
order
))));
return
new
Result
<>(
repository
.
findAllByItemLabelContaining
(
label
,
PageRequest
.
of
(
pageNum
,
pageSize
,
getSort
(
order
))));
}
@GetMapping
(
"/queryItemSku"
)
public
Result
queryItemSku
(
@RequestParam
(
value
=
"itemId"
)
String
itemId
,
public
Result
queryItemSku
(
@RequestParam
(
value
=
"itemId"
)
String
itemId
,
@RequestParam
(
value
=
"userId"
,
required
=
false
)
String
userId
)
{
Optional
<
TbCfStationItem
>
itemOptional
=
repository
.
findById
(
itemId
);
if
(
!
itemOptional
.
isPresent
()
)
return
new
Result
(
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getCode
(),
"Item Id is not found"
);
if
(!
itemOptional
.
isPresent
()
)
return
new
Result
(
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getCode
(),
"Item Id is not found"
);
List
<
TbCfCategory
>
categoryList
=
categoryRepository
.
findAllByItemIdOrderByOrderNumAsc
(
itemId
);
...
...
@@ -196,13 +203,13 @@ public class ItemController {
//商品详情
Optional
<
TbCfItemDesc
>
byId
=
descRepository
.
findById
(
itemId
);
map
.
put
(
"score"
,
item
.
getTotalScore
());
map
.
put
(
"isCollection"
,
userId
!=
null
&&
!
userId
.
isEmpty
()
&&
collectionRepository
.
existsByUserIdAndItemItemId
(
userId
,
itemId
));
map
.
put
(
"optionList"
,
categoryList
);
map
.
put
(
"itemDetail"
,
skusList
);
map
.
put
(
"score"
,
item
.
getTotalScore
());
map
.
put
(
"isCollection"
,
userId
!=
null
&&
!
userId
.
isEmpty
()
&&
collectionRepository
.
existsByUserIdAndItemItemId
(
userId
,
itemId
));
map
.
put
(
"optionList"
,
categoryList
);
map
.
put
(
"itemDetail"
,
skusList
);
map
.
put
(
"itemInfo"
,
item
);
map
.
put
(
"itemParam"
,
itemParamList
);
map
.
put
(
"itemDesc"
,
byId
.
orElse
(
new
TbCfItemDesc
()));
map
.
put
(
"itemDesc"
,
byId
.
orElse
(
new
TbCfItemDesc
()));
return
new
Result
<>(
map
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论