Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Y
yudao-cloud
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
hblj
yudao-cloud
Commits
c1e34b90
提交
c1e34b90
authored
7月 10, 2019
作者:
zhenxianyimeng
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
7f4d070e
11f601a0
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
104 行增加
和
21 行删除
+104
-21
product.js
mobile-web/src/api/product.js
+7
-0
user.js
mobile-web/src/api/user.js
+16
-7
detail.vue
mobile-web/src/page/product/detail.vue
+33
-2
list.vue
mobile-web/src/page/user/favorite/list.vue
+12
-8
UserFavoriteController.java
.../application/controller/users/UserFavoriteController.java
+9
-1
UserProductSpuCollectionsService.java
...coder/mall/user/api/UserProductSpuCollectionsService.java
+10
-0
UserProductSpuCollectionsServiceImpl.java
...ser/biz/service/UserProductSpuCollectionsServiceImpl.java
+17
-2
UserProductSpuCollectionsMapper.xml
...main/resources/mapper/UserProductSpuCollectionsMapper.xml
+0
-1
没有找到文件。
mobile-web/src/api/product.js
浏览文件 @
c1e34b90
...
@@ -31,3 +31,10 @@ export function getProductSpuInfo(id) {
...
@@ -31,3 +31,10 @@ export function getProductSpuInfo(id) {
}
}
});
});
}
}
export
function
collectionSpu
(
spuId
,
hasCollectionType
)
{
return
request
({
url
:
'/product-api/users/spu/collection/'
+
spuId
+
'/'
+
hasCollectionType
,
method
:
'post'
});
}
mobile-web/src/api/user.js
浏览文件 @
c1e34b90
import
request
from
"../config/request"
;
import
request
from
"../config/request"
;
export
function
GetFavorite
(
data
){
export
function
GetFavorite
Page
(
pageNo
,
pageSize
){
return
request
({
return
request
({
url
:
'/
User/GetFavorit
e'
,
url
:
'/
user-api/users/favorite/pag
e'
,
method
:
'
pos
t'
,
method
:
'
ge
t'
,
params
:
{
data
}
params
:
{
pageNo
,
pageSize
}
})
})
}
}
export
function
DelFavorite
(
i
d
){
export
function
DelFavorite
(
spuI
d
){
return
request
({
return
request
({
url
:
'/User/DelFavorite'
,
url
:
'/user-api/users/favorite/remove'
,
method
:
'DELETE'
,
params
:
{
spuId
}
})
}
export
function
hasUserSpuFavorite
(
spuId
){
return
request
({
url
:
'/user-api/users/favorite/hasUserFavorite'
,
method
:
'get'
,
method
:
'get'
,
params
:
{
id
:
id
}
params
:
{
spuId
}
})
})
}
}
export
function
GetCoupon
(
data
){
export
function
GetCoupon
(
data
){
return
request
({
return
request
({
url
:
'/User/GetCoupon'
,
url
:
'/User/GetCoupon'
,
...
...
mobile-web/src/page/product/detail.vue
浏览文件 @
c1e34b90
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
</div>
</div>
<van-goods-action>
<van-goods-action>
<van-goods-action-mini-btn
icon=
"like-o"
@
click=
"
sorry
"
>
<van-goods-action-mini-btn
icon=
"like-o"
@
click=
"
onFavoriteClicked
"
>
收藏
收藏
</van-goods-action-mini-btn>
</van-goods-action-mini-btn>
<van-goods-action-mini-btn
icon=
"cart"
:info=
"cartCount > 0 ? cartCount : undefined"
@
click=
"onClickCart"
>
<van-goods-action-mini-btn
icon=
"cart"
:info=
"cartCount > 0 ? cartCount : undefined"
@
click=
"onClickCart"
>
...
@@ -171,8 +171,9 @@
...
@@ -171,8 +171,9 @@
<
script
>
<
script
>
// import skuData from '../../data/sku';
// import skuData from '../../data/sku';
import
{
getProductSpuInfo
}
from
'../../api/product'
;
import
{
getProductSpuInfo
,
collectionSpu
}
from
'../../api/product'
;
import
{
addCart
,
countCart
,
getCartCalcSkuPrice
}
from
'../../api/order'
;
import
{
addCart
,
countCart
,
getCartCalcSkuPrice
}
from
'../../api/order'
;
import
{
hasUserSpuFavorite
}
from
'../../api/user'
;
import
{
Dialog
}
from
'vant'
;
import
{
Dialog
}
from
'vant'
;
import
{
checkLogin
}
from
"../../utils/cache"
;
import
{
checkLogin
}
from
"../../utils/cache"
;
...
@@ -290,6 +291,7 @@
...
@@ -290,6 +291,7 @@
}
}
});
});
},
},
onClickCart
()
{
onClickCart
()
{
this
.
$router
.
push
(
'/cart'
);
this
.
$router
.
push
(
'/cart'
);
},
},
...
@@ -305,6 +307,35 @@
...
@@ -305,6 +307,35 @@
onClickShowTag
()
{
onClickShowTag
()
{
this
.
showTag
=
true
;
this
.
showTag
=
true
;
},
},
onFavoriteClicked
(){
if
(
!
checkLogin
())
{
Dialog
.
alert
({
title
:
'系统提示'
,
message
:
'未登陆用户,暂时不支持使用购物车'
,
});
return
;
}
let
id
=
this
.
$route
.
params
.
id
;
// 商品编号
let
hasCollectionType
=
1
;
// 收藏类型 默认收藏
hasUserSpuFavorite
(
id
).
then
(
data
=>
{
let
hasCollection
=
data
;
// alert("是否收藏==" + hasCollection);
if
(
hasCollection
){
hasCollectionType
=
2
;
}
// alert("hasCollectionType==" + hasCollectionType);
collectionSpu
(
id
,
hasCollectionType
).
then
(
data
=>
{
let
v
=
data
;
if
(
hasCollectionType
==
1
&&
v
){
alert
(
"商品已收藏"
);
}
else
if
(
hasCollectionType
==
2
&&
v
){
alert
(
"商品已取消"
);
}
})
});
},
onBuyClicked
(
data
)
{
onBuyClicked
(
data
)
{
const
{
selectedNum
}
=
data
;
const
{
selectedNum
}
=
data
;
this
.
$router
.
push
({
this
.
$router
.
push
({
...
...
mobile-web/src/page/user/favorite/list.vue
浏览文件 @
c1e34b90
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<div
v-for=
"(item,index) in list"
:key=
"index"
>
<div
v-for=
"(item,index) in list"
:key=
"index"
>
<van-swipe-cell
:right-width=
"65"
:on-close=
"onClose(item)"
>
<van-swipe-cell
:right-width=
"65"
:on-close=
"onClose(item)"
>
<product-card
:product=
'item'
/>
<product-card
:product=
'item'
/>
<span>
{{
item
.
spuName
}}
</span>
<span
slot=
"right"
>
删除
</span>
<span
slot=
"right"
>
删除
</span>
</van-swipe-cell>
</van-swipe-cell>
</div>
</div>
...
@@ -17,7 +18,7 @@
...
@@ -17,7 +18,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
{
GetFavorite
,
DelFavorite
}
from
"../../../api/user.js"
;
import
{
GetFavorite
Page
,
DelFavorite
}
from
"../../../api/user.js"
;
export
default
{
export
default
{
data
(){
data
(){
...
@@ -26,6 +27,7 @@ export default {
...
@@ -26,6 +27,7 @@ export default {
finished
:
false
,
finished
:
false
,
list
:[],
list
:[],
page
:
0
,
page
:
0
,
pageSize
:
10
}
}
},
},
methods
:{
methods
:{
...
@@ -41,7 +43,7 @@ export default {
...
@@ -41,7 +43,7 @@ export default {
this
.
$dialog
.
confirm
({
this
.
$dialog
.
confirm
({
message
:
'确定删除吗?'
message
:
'确定删除吗?'
}).
then
(()
=>
{
}).
then
(()
=>
{
DelFavorite
(
item
.
i
d
).
then
(
response
=>
{
DelFavorite
(
item
.
spuI
d
).
then
(
response
=>
{
this
.
$toast
(
'删除成功'
);
this
.
$toast
(
'删除成功'
);
this
.
$router
.
go
(
0
);
this
.
$router
.
go
(
0
);
})
})
...
@@ -54,13 +56,15 @@ export default {
...
@@ -54,13 +56,15 @@ export default {
}
}
},
},
onLoad
()
{
onLoad
()
{
this
.
page
++
;
let
pageNo
=
this
.
page
+
1
;
GetFavorite
().
then
(
response
=>
{
GetFavoritePage
(
pageNo
,
this
.
pageSize
).
then
(
response
=>
{
response
.
list
.
forEach
(
item
=>
{
this
.
page
=
pageNo
;
this
.
list
.
push
(
item
);
this
.
list
.
push
(...
response
.
list
);
});
// response.list.forEach(item => {
// this.list.push(item);
// });
this
.
loading
=
false
;
this
.
loading
=
false
;
if
(
response
.
TotalPage
<=
this
.
page
){
if
(
this
.
list
.
length
>=
response
.
total
){
this
.
finished
=
true
;
this
.
finished
=
true
;
}
}
...
...
user/user-application/src/main/java/cn/iocoder/mall/user/application/controller/users/UserFavoriteController.java
浏览文件 @
c1e34b90
...
@@ -39,8 +39,16 @@ public class UserFavoriteController {
...
@@ -39,8 +39,16 @@ public class UserFavoriteController {
@DeleteMapping
(
"remove"
)
@DeleteMapping
(
"remove"
)
@RequiresLogin
@RequiresLogin
@ApiOperation
(
value
=
"用户商品收藏-删除"
)
@ApiOperation
(
value
=
"用户商品收藏-删除"
)
public
CommonResult
<
Boolean
>
removeFavorite
(
@RequestParam
(
"spuId"
)
final
Integer
spuId
)
{
public
CommonResult
<
Boolean
>
remove
User
Favorite
(
@RequestParam
(
"spuId"
)
final
Integer
spuId
)
{
final
Integer
userId
=
UserSecurityContextHolder
.
getContext
().
getUserId
();
final
Integer
userId
=
UserSecurityContextHolder
.
getContext
().
getUserId
();
return
userProductSpuCollectionsService
.
deleteUserProductSpuCollections
(
userId
,
spuId
);
return
userProductSpuCollectionsService
.
deleteUserProductSpuCollections
(
userId
,
spuId
);
}
}
@GetMapping
(
"hasUserFavorite"
)
@RequiresLogin
@ApiOperation
(
value
=
"用户商品收藏-是否收藏"
)
public
CommonResult
<
Boolean
>
hasUserSpuFavorite
(
@RequestParam
(
"spuId"
)
final
Integer
spuId
)
{
final
Integer
userId
=
UserSecurityContextHolder
.
getContext
().
getUserId
();
return
userProductSpuCollectionsService
.
hasUserSpuFavorite
(
spuId
,
userId
);
}
}
}
user/user-service-api/src/main/java/cn/iocoder/mall/user/api/UserProductSpuCollectionsService.java
浏览文件 @
c1e34b90
...
@@ -51,4 +51,14 @@ public interface UserProductSpuCollectionsService {
...
@@ -51,4 +51,14 @@ public interface UserProductSpuCollectionsService {
* @return
* @return
*/
*/
CommonResult
<
Boolean
>
deleteUserProductSpuCollections
(
Integer
userId
,
Integer
spuId
);
CommonResult
<
Boolean
>
deleteUserProductSpuCollections
(
Integer
userId
,
Integer
spuId
);
/**
* 检验用户商品是否收藏
* @param spuId
* @param userId
* @return
*/
CommonResult
<
Boolean
>
hasUserSpuFavorite
(
Integer
spuId
,
Integer
userId
);
}
}
user/user-service-impl/src/main/java/cn/iocoder/mall/user/biz/service/UserProductSpuCollectionsServiceImpl.java
浏览文件 @
c1e34b90
...
@@ -96,11 +96,26 @@ public class UserProductSpuCollectionsServiceImpl implements UserProductSpuColle
...
@@ -96,11 +96,26 @@ public class UserProductSpuCollectionsServiceImpl implements UserProductSpuColle
if
(
userProductSpuCollectionsBO
!=
null
)
{
if
(
userProductSpuCollectionsBO
!=
null
)
{
// 未取消收藏的数据
// 未取消收藏的数据
if
(
userProductSpuCollectionsBO
.
getDeleted
().
equals
(
DeletedStatusEnum
.
DELETED_NO
.
getValue
()))
{
if
(
userProductSpuCollectionsBO
.
getDeleted
().
equals
(
DeletedStatusEnum
.
DELETED_NO
.
getValue
()))
{
UserProductSpuCollectionsUpdateDTO
userProductSpuCollectionsUpdateDTO
=
new
UserProductSpuCollectionsUpdateDTO
().
setId
(
userProductSpuCollectionsBO
.
getId
())
UserProductSpuCollectionsUpdateDTO
userProductSpuCollectionsUpdateDTO
=
new
UserProductSpuCollectionsUpdateDTO
()
.
setUpdateTime
(
new
Date
()).
setDeleted
(
DeletedStatusEnum
.
DELETED_YES
.
getValue
());
.
setId
(
userProductSpuCollectionsBO
.
getId
()).
setUpdateTime
(
new
Date
())
.
setDeleted
(
DeletedStatusEnum
.
DELETED_YES
.
getValue
());
result
=
this
.
updateUserProductSpuCollections
(
userProductSpuCollectionsUpdateDTO
);
result
=
this
.
updateUserProductSpuCollections
(
userProductSpuCollectionsUpdateDTO
);
}
}
}
}
return
CommonResult
.
success
(
result
>
0
?
Boolean
.
TRUE
:
Boolean
.
FALSE
);
return
CommonResult
.
success
(
result
>
0
?
Boolean
.
TRUE
:
Boolean
.
FALSE
);
}
}
@Override
public
CommonResult
<
Boolean
>
hasUserSpuFavorite
(
final
Integer
spuId
,
final
Integer
userId
)
{
UserProductSpuCollectionsBO
userProductSpuCollectionsBO
=
this
.
getUserSpuCollectionsByUserIdAndSpuId
(
userId
,
spuId
);
if
(
userProductSpuCollectionsBO
!=
null
)
{
// 收藏
final
boolean
hasCollect
=
userProductSpuCollectionsBO
.
getDeleted
()
.
equals
(
DeletedStatusEnum
.
DELETED_NO
.
getValue
());
return
CommonResult
.
success
(
hasCollect
);
}
return
CommonResult
.
success
(
Boolean
.
FALSE
);
}
}
}
user/user-service-impl/src/main/resources/mapper/UserProductSpuCollectionsMapper.xml
浏览文件 @
c1e34b90
...
@@ -24,7 +24,6 @@
...
@@ -24,7 +24,6 @@
<where>
<where>
user_id = #{userId} AND deleted = 0
user_id = #{userId} AND deleted = 0
</where>
</where>
ORDER BY sort ASC
<if
test=
"offset != null and limit != null"
>
<if
test=
"offset != null and limit != null"
>
LIMIT #{offset}, #{limit}
LIMIT #{offset}, #{limit}
</if>
</if>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论