Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
575eb0a8
Commit
575eb0a8
authored
Aug 06, 2018
by
zhh
Browse files
购物车功能修改
parent
f75835ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
mall-portal/src/main/java/com/macro/mall/portal/controller/OmsCartItemController.java
View file @
575eb0a8
...
...
@@ -4,6 +4,7 @@ import com.macro.mall.model.OmsCartItem;
import
com.macro.mall.portal.domain.CartProduct
;
import
com.macro.mall.portal.domain.CommonResult
;
import
com.macro.mall.portal.service.OmsCartItemService
;
import
com.macro.mall.portal.service.UmsMemberService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -22,11 +23,14 @@ import java.util.List;
public
class
OmsCartItemController
{
@Autowired
private
OmsCartItemService
cartItemService
;
@Autowired
private
UmsMemberService
memberService
;
@ApiOperation
(
"添加商品到购物车"
)
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
add
(
@RequestBody
OmsCartItem
cartItem
)
{
cartItem
.
setMemberId
(
memberService
.
getCurrentMember
().
getId
());
int
count
=
cartItemService
.
add
(
cartItem
);
if
(
count
>
0
)
{
return
new
CommonResult
().
success
(
count
);
...
...
@@ -35,10 +39,10 @@ public class OmsCartItemController {
}
@ApiOperation
(
"获取某个会员的购物车列表"
)
@RequestMapping
(
value
=
"/list
/{memberId}
"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/list"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
list
(
@PathVariable
Long
memberId
)
{
List
<
OmsCartItem
>
cartItemList
=
cartItemService
.
list
(
member
Id
);
public
Object
list
()
{
List
<
OmsCartItem
>
cartItemList
=
cartItemService
.
list
(
member
Service
.
getCurrentMember
().
getId
()
);
return
new
CommonResult
().
success
(
cartItemList
);
}
...
...
@@ -46,9 +50,8 @@ public class OmsCartItemController {
@RequestMapping
(
value
=
"/update/quantity"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
updateQuantity
(
@RequestParam
Long
id
,
@RequestParam
Long
memberId
,
@RequestParam
Integer
quantity
)
{
int
count
=
cartItemService
.
updateQuantity
(
id
,
member
Id
,
quantity
);
int
count
=
cartItemService
.
updateQuantity
(
id
,
member
Service
.
getCurrentMember
().
getId
()
,
quantity
);
if
(
count
>
0
)
{
return
new
CommonResult
().
success
(
count
);
}
...
...
@@ -67,6 +70,7 @@ public class OmsCartItemController {
@RequestMapping
(
value
=
"/update/attr"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
updateAttr
(
@RequestBody
OmsCartItem
cartItem
)
{
cartItem
.
setMemberId
(
memberService
.
getCurrentMember
().
getId
());
int
count
=
cartItemService
.
updateAttr
(
cartItem
);
if
(
count
>
0
)
{
return
new
CommonResult
().
success
(
count
);
...
...
@@ -77,8 +81,8 @@ public class OmsCartItemController {
@ApiOperation
(
"删除购物车中的某个商品"
)
@RequestMapping
(
value
=
"/delete"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
delete
(
@RequestParam
Long
memberId
,
@RequestParam
(
"ids"
)
List
<
Long
>
ids
)
{
int
count
=
cartItemService
.
delete
(
member
Id
,
ids
);
public
Object
delete
(
@RequestParam
(
"ids"
)
List
<
Long
>
ids
)
{
int
count
=
cartItemService
.
delete
(
member
Service
.
getCurrentMember
().
getId
()
,
ids
);
if
(
count
>
0
)
{
return
new
CommonResult
().
success
(
count
);
}
...
...
mall-portal/src/main/java/com/macro/mall/portal/domain/MemberDetails.java
View file @
575eb0a8
...
...
@@ -54,4 +54,8 @@ public class MemberDetails implements UserDetails {
public
boolean
isEnabled
()
{
return
umsMember
.
getStatus
()==
1
;
}
public
UmsMember
getUmsMember
()
{
return
umsMember
;
}
}
mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberService.java
View file @
575eb0a8
...
...
@@ -30,4 +30,6 @@ public interface UmsMemberService {
*/
@Transactional
CommonResult
updatePassword
(
String
telephone
,
String
password
,
String
authCode
);
UmsMember
getCurrentMember
();
}
mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberServiceImpl.java
View file @
575eb0a8
...
...
@@ -7,9 +7,13 @@ import com.macro.mall.model.UmsMemberExample;
import
com.macro.mall.model.UmsMemberLevel
;
import
com.macro.mall.model.UmsMemberLevelExample
;
import
com.macro.mall.portal.domain.CommonResult
;
import
com.macro.mall.portal.domain.MemberDetails
;
import
com.macro.mall.portal.service.UmsMemberService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.authentication.encoding.PasswordEncoder
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -96,4 +100,12 @@ public class UmsMemberServiceImpl implements UmsMemberService {
return
new
CommonResult
().
success
(
"密码修改成功"
,
null
);
}
@Override
public
UmsMember
getCurrentMember
()
{
SecurityContext
ctx
=
SecurityContextHolder
.
getContext
();
Authentication
auth
=
ctx
.
getAuthentication
();
MemberDetails
memberDetails
=
(
MemberDetails
)
auth
.
getPrincipal
();
return
memberDetails
.
getUmsMember
();
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
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 comment