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
02b555c5
Commit
02b555c5
authored
Aug 02, 2018
by
zhh
Browse files
添加品牌关注和商品收藏功能
parent
cfe5c0fe
Changes
10
Hide whitespace changes
Inline
Side-by-side
mall-portal/src/main/java/com/macro/mall/portal/controller/MemberAttentionController.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.controller
;
import
com.macro.mall.portal.domain.CommonResult
;
import
com.macro.mall.portal.domain.MemberBrandAttention
;
import
com.macro.mall.portal.service.MemberAttentionService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 会员关注品牌管理Controller
* Created by macro on 2018/8/2.
*/
@Controller
@Api
(
tags
=
"MemberAttentionController"
,
description
=
"会员关注品牌管理"
)
@RequestMapping
(
"/member/attention"
)
public
class
MemberAttentionController
{
@Autowired
private
MemberAttentionService
memberAttentionService
;
@ApiOperation
(
"添加品牌关注"
)
@RequestMapping
(
value
=
"/add"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
add
(
@RequestBody
MemberBrandAttention
memberBrandAttention
)
{
int
count
=
memberAttentionService
.
add
(
memberBrandAttention
);
if
(
count
>
0
){
return
new
CommonResult
().
success
(
count
);
}
else
{
return
new
CommonResult
().
failed
();
}
}
@ApiOperation
(
"取消关注"
)
@RequestMapping
(
value
=
"/delete"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
delete
(
Long
memberId
,
Long
brandId
)
{
int
count
=
memberAttentionService
.
delete
(
memberId
,
brandId
);
if
(
count
>
0
){
return
new
CommonResult
().
success
(
count
);
}
else
{
return
new
CommonResult
().
failed
();
}
}
@ApiOperation
(
"显示关注列表"
)
@RequestMapping
(
value
=
"/list/{memberId}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
list
(
@PathVariable
Long
memberId
)
{
List
<
MemberBrandAttention
>
memberBrandAttentionList
=
memberAttentionService
.
list
(
memberId
);
return
new
CommonResult
().
success
(
memberBrandAttentionList
);
}
}
mall-portal/src/main/java/com/macro/mall/portal/controller/MemberCollectionController.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.controller
;
import
com.macro.mall.portal.domain.CommonResult
;
import
com.macro.mall.portal.domain.MemberProductCollection
;
import
com.macro.mall.portal.service.MemberCollectionService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
/**
* 会员收藏管理Controller
* Created by macro on 2018/8/2.
*/
@Controller
@Api
(
tags
=
"MemberCollectionController"
,
description
=
"会员收藏管理"
)
@RequestMapping
(
"/member/collection"
)
public
class
MemberCollectionController
{
@Autowired
private
MemberCollectionService
memberCollectionService
;
@ApiOperation
(
"添加商品收藏"
)
@RequestMapping
(
value
=
"/addProduct"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
addProduct
(
@RequestBody
MemberProductCollection
productCollection
)
{
int
count
=
memberCollectionService
.
addProduct
(
productCollection
);
if
(
count
>
0
){
return
new
CommonResult
().
success
(
count
);
}
else
{
return
new
CommonResult
().
failed
();
}
}
@ApiOperation
(
"删除收藏商品"
)
@RequestMapping
(
value
=
"/deleteProduct"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
deleteProduct
(
Long
memberId
,
Long
productId
)
{
int
count
=
memberCollectionService
.
deleteProduct
(
memberId
,
productId
);
if
(
count
>
0
){
return
new
CommonResult
().
success
(
count
);
}
else
{
return
new
CommonResult
().
failed
();
}
}
@ApiOperation
(
"显示关注列表"
)
@RequestMapping
(
value
=
"/listProduct/{memberId}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
list
(
@PathVariable
Long
memberId
)
{
List
<
MemberProductCollection
>
memberProductCollectionList
=
memberCollectionService
.
listProduct
(
memberId
);
return
new
CommonResult
().
success
(
memberProductCollectionList
);
}
}
mall-portal/src/main/java/com/macro/mall/portal/domain/MemberBrandAttention.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.domain
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.util.Date
;
/**
* 会员关注的品牌
* Created by macro on 2018/8/2.
*/
@Document
public
class
MemberBrandAttention
{
@Id
private
String
id
;
@Indexed
private
Long
memberId
;
private
String
memberNickname
;
private
String
memberIcon
;
@Indexed
private
Long
brandId
;
private
String
brandName
;
private
String
brandLogo
;
private
String
brandCity
;
private
Integer
brandAttentionCount
;
private
Date
createTime
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
Long
getMemberId
()
{
return
memberId
;
}
public
void
setMemberId
(
Long
memberId
)
{
this
.
memberId
=
memberId
;
}
public
String
getMemberNickname
()
{
return
memberNickname
;
}
public
void
setMemberNickname
(
String
memberNickname
)
{
this
.
memberNickname
=
memberNickname
;
}
public
String
getMemberIcon
()
{
return
memberIcon
;
}
public
void
setMemberIcon
(
String
memberIcon
)
{
this
.
memberIcon
=
memberIcon
;
}
public
Long
getBrandId
()
{
return
brandId
;
}
public
void
setBrandId
(
Long
brandId
)
{
this
.
brandId
=
brandId
;
}
public
String
getBrandName
()
{
return
brandName
;
}
public
void
setBrandName
(
String
brandName
)
{
this
.
brandName
=
brandName
;
}
public
String
getBrandLogo
()
{
return
brandLogo
;
}
public
void
setBrandLogo
(
String
brandLogo
)
{
this
.
brandLogo
=
brandLogo
;
}
public
String
getBrandCity
()
{
return
brandCity
;
}
public
void
setBrandCity
(
String
brandCity
)
{
this
.
brandCity
=
brandCity
;
}
public
Integer
getBrandAttentionCount
()
{
return
brandAttentionCount
;
}
public
void
setBrandAttentionCount
(
Integer
brandAttentionCount
)
{
this
.
brandAttentionCount
=
brandAttentionCount
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
}
mall-portal/src/main/java/com/macro/mall/portal/domain/MemberProductCollection.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.domain
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
java.util.Date
;
/**
* 用户收藏的商品
* Created by macro on 2018/8/2.
*/
public
class
MemberProductCollection
{
@Id
private
String
id
;
@Indexed
private
Long
memberId
;
private
String
memberNickname
;
private
String
memberIcon
;
@Indexed
private
Long
productId
;
private
String
productName
;
private
String
productPic
;
private
String
productSubTitle
;
private
String
productPrice
;
private
Date
createTime
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
Long
getMemberId
()
{
return
memberId
;
}
public
void
setMemberId
(
Long
memberId
)
{
this
.
memberId
=
memberId
;
}
public
String
getMemberNickname
()
{
return
memberNickname
;
}
public
void
setMemberNickname
(
String
memberNickname
)
{
this
.
memberNickname
=
memberNickname
;
}
public
String
getMemberIcon
()
{
return
memberIcon
;
}
public
void
setMemberIcon
(
String
memberIcon
)
{
this
.
memberIcon
=
memberIcon
;
}
public
Long
getProductId
()
{
return
productId
;
}
public
void
setProductId
(
Long
productId
)
{
this
.
productId
=
productId
;
}
public
String
getProductName
()
{
return
productName
;
}
public
void
setProductName
(
String
productName
)
{
this
.
productName
=
productName
;
}
public
String
getProductPic
()
{
return
productPic
;
}
public
void
setProductPic
(
String
productPic
)
{
this
.
productPic
=
productPic
;
}
public
String
getProductSubTitle
()
{
return
productSubTitle
;
}
public
void
setProductSubTitle
(
String
productSubTitle
)
{
this
.
productSubTitle
=
productSubTitle
;
}
public
String
getProductPrice
()
{
return
productPrice
;
}
public
void
setProductPrice
(
String
productPrice
)
{
this
.
productPrice
=
productPrice
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
}
mall-portal/src/main/java/com/macro/mall/portal/repository/MemberBrandAttentionRepository.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.repository
;
import
com.macro.mall.portal.domain.MemberBrandAttention
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
java.util.List
;
/**
* 会员关注Repository
* Created by macro on 2018/8/2.
*/
public
interface
MemberBrandAttentionRepository
extends
MongoRepository
<
MemberBrandAttention
,
String
>
{
MemberBrandAttention
findByMemberIdAndBrandId
(
Long
memberId
,
Long
brandId
);
int
deleteByMemberIdAndBrandId
(
Long
memberId
,
Long
brandId
);
List
<
MemberBrandAttention
>
findByMemberId
(
Long
memberId
);
}
mall-portal/src/main/java/com/macro/mall/portal/repository/MemberProductCollectionRepository.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.repository
;
import
com.macro.mall.portal.domain.MemberProductCollection
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
java.util.List
;
/**
* 商品收藏Repository
* Created by macro on 2018/8/2.
*/
public
interface
MemberProductCollectionRepository
extends
MongoRepository
<
MemberProductCollection
,
String
>
{
MemberProductCollection
findByMemberIdAndProductId
(
Long
memberId
,
Long
productId
);
int
deleteByMemberIdAndProductId
(
Long
memberId
,
Long
productId
);
List
<
MemberProductCollection
>
findByMemberId
(
Long
memberId
);
}
mall-portal/src/main/java/com/macro/mall/portal/service/MemberAttentionService.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.service
;
import
com.macro.mall.portal.domain.MemberBrandAttention
;
import
java.util.List
;
/**
* 会员关注Service
* Created by macro on 2018/8/2.
*/
public
interface
MemberAttentionService
{
/**
* 添加关注
*/
int
add
(
MemberBrandAttention
memberBrandAttention
);
/**
* 取消关注
*/
int
delete
(
Long
memberId
,
Long
brandId
);
/**
* 获取用户关注列表
*/
List
<
MemberBrandAttention
>
list
(
Long
memberId
);
}
mall-portal/src/main/java/com/macro/mall/portal/service/MemberCollectionService.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.service
;
import
com.macro.mall.portal.domain.MemberProductCollection
;
import
java.util.List
;
/**
* 会员收藏Service
* Created by macro on 2018/8/2.
*/
public
interface
MemberCollectionService
{
int
addProduct
(
MemberProductCollection
productCollection
);
int
deleteProduct
(
Long
memberId
,
Long
productId
);
List
<
MemberProductCollection
>
listProduct
(
Long
memberId
);
}
mall-portal/src/main/java/com/macro/mall/portal/service/impl/MemberAttentionServiceImpl.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.service.impl
;
import
com.macro.mall.portal.domain.MemberBrandAttention
;
import
com.macro.mall.portal.repository.MemberBrandAttentionRepository
;
import
com.macro.mall.portal.service.MemberAttentionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* 会员关注Service实现类
* Created by macro on 2018/8/2.
*/
@Service
public
class
MemberAttentionServiceImpl
implements
MemberAttentionService
{
@Autowired
private
MemberBrandAttentionRepository
memberBrandAttentionRepository
;
@Override
public
int
add
(
MemberBrandAttention
memberBrandAttention
)
{
int
count
=
0
;
MemberBrandAttention
findAttention
=
memberBrandAttentionRepository
.
findByMemberIdAndBrandId
(
memberBrandAttention
.
getMemberId
(),
memberBrandAttention
.
getBrandId
());
if
(
findAttention
==
null
)
{
memberBrandAttentionRepository
.
save
(
memberBrandAttention
);
count
=
1
;
}
return
count
;
}
@Override
public
int
delete
(
Long
memberId
,
Long
brandId
)
{
return
memberBrandAttentionRepository
.
deleteByMemberIdAndBrandId
(
memberId
,
brandId
);
}
@Override
public
List
<
MemberBrandAttention
>
list
(
Long
memberId
)
{
return
memberBrandAttentionRepository
.
findByMemberId
(
memberId
);
}
}
mall-portal/src/main/java/com/macro/mall/portal/service/impl/MemberCollectionServiceImpl.java
0 → 100644
View file @
02b555c5
package
com.macro.mall.portal.service.impl
;
import
com.macro.mall.portal.domain.MemberProductCollection
;
import
com.macro.mall.portal.repository.MemberProductCollectionRepository
;
import
com.macro.mall.portal.service.MemberCollectionService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* 会员收藏Service实现类
* Created by macro on 2018/8/2.
*/
@Service
public
class
MemberCollectionServiceImpl
implements
MemberCollectionService
{
@Autowired
private
MemberProductCollectionRepository
productCollectionRepository
;
@Override
public
int
addProduct
(
MemberProductCollection
productCollection
)
{
int
count
=
0
;
MemberProductCollection
findCollection
=
productCollectionRepository
.
findByMemberIdAndProductId
(
productCollection
.
getMemberId
(),
productCollection
.
getProductId
());
if
(
findCollection
==
null
)
{
productCollectionRepository
.
save
(
productCollection
);
count
=
1
;
}
return
count
;
}
@Override
public
int
deleteProduct
(
Long
memberId
,
Long
productId
)
{
return
productCollectionRepository
.
deleteByMemberIdAndProductId
(
memberId
,
productId
);
}
@Override
public
List
<
MemberProductCollection
>
listProduct
(
Long
memberId
)
{
return
productCollectionRepository
.
findByMemberId
(
memberId
);
}
}
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