商品关注、收藏接口完善
This commit is contained in:
parent
ddcf961e87
commit
3056a0aa75
@ -3,6 +3,7 @@ package com.macro.mall.portal.controller;
|
|||||||
import com.macro.mall.common.api.CommonPage;
|
import com.macro.mall.common.api.CommonPage;
|
||||||
import com.macro.mall.common.api.CommonResult;
|
import com.macro.mall.common.api.CommonResult;
|
||||||
import com.macro.mall.portal.domain.MemberBrandAttention;
|
import com.macro.mall.portal.domain.MemberBrandAttention;
|
||||||
|
import com.macro.mall.portal.domain.MemberProductCollection;
|
||||||
import com.macro.mall.portal.service.MemberAttentionService;
|
import com.macro.mall.portal.service.MemberAttentionService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
@ -55,4 +56,20 @@ public class MemberAttentionController {
|
|||||||
Page<MemberBrandAttention> page = memberAttentionService.list(pageNum,pageSize);
|
Page<MemberBrandAttention> page = memberAttentionService.list(pageNum,pageSize);
|
||||||
return CommonResult.success(CommonPage.restPage(page));
|
return CommonResult.success(CommonPage.restPage(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("显示关注品牌详情")
|
||||||
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonResult<MemberBrandAttention> detail(@RequestParam Long brandId) {
|
||||||
|
MemberBrandAttention memberBrandAttention = memberAttentionService.detail(brandId);
|
||||||
|
return CommonResult.success(memberBrandAttention);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("清空关注列表")
|
||||||
|
@RequestMapping(value = "/clear", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonResult clear() {
|
||||||
|
memberAttentionService.clear();
|
||||||
|
return CommonResult.success(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class MemberProductCollectionController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("显示关注列表")
|
@ApiOperation("显示收藏列表")
|
||||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public CommonResult<CommonPage<MemberProductCollection>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
public CommonResult<CommonPage<MemberProductCollection>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||||
@ -56,4 +56,20 @@ public class MemberProductCollectionController {
|
|||||||
Page<MemberProductCollection> page = memberCollectionService.list(pageNum,pageSize);
|
Page<MemberProductCollection> page = memberCollectionService.list(pageNum,pageSize);
|
||||||
return CommonResult.success(CommonPage.restPage(page));
|
return CommonResult.success(CommonPage.restPage(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("显示收藏商品详情")
|
||||||
|
@RequestMapping(value = "/detail", method = RequestMethod.GET)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonResult<MemberProductCollection> detail(@RequestParam Long productId) {
|
||||||
|
MemberProductCollection memberProductCollection = memberCollectionService.detail(productId);
|
||||||
|
return CommonResult.success(memberProductCollection);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("清空收藏列表")
|
||||||
|
@RequestMapping(value = "/clear", method = RequestMethod.POST)
|
||||||
|
@ResponseBody
|
||||||
|
public CommonResult clear() {
|
||||||
|
memberCollectionService.clear();
|
||||||
|
return CommonResult.success(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,5 @@ public interface MemberBrandAttentionRepository extends MongoRepository<MemberBr
|
|||||||
MemberBrandAttention findByMemberIdAndBrandId(Long memberId, Long brandId);
|
MemberBrandAttention findByMemberIdAndBrandId(Long memberId, Long brandId);
|
||||||
int deleteByMemberIdAndBrandId(Long memberId,Long brandId);
|
int deleteByMemberIdAndBrandId(Long memberId,Long brandId);
|
||||||
Page<MemberBrandAttention> findByMemberId(Long memberId, Pageable pageable);
|
Page<MemberBrandAttention> findByMemberId(Long memberId, Pageable pageable);
|
||||||
|
void deleteAllByMemberId(Long memberId);
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,5 @@ public interface MemberProductCollectionRepository extends MongoRepository<Membe
|
|||||||
MemberProductCollection findByMemberIdAndProductId(Long memberId, Long productId);
|
MemberProductCollection findByMemberIdAndProductId(Long memberId, Long productId);
|
||||||
int deleteByMemberIdAndProductId(Long memberId,Long productId);
|
int deleteByMemberIdAndProductId(Long memberId,Long productId);
|
||||||
Page<MemberProductCollection> findByMemberId(Long memberId, Pageable pageable);
|
Page<MemberProductCollection> findByMemberId(Long memberId, Pageable pageable);
|
||||||
|
void deleteAllByMemberId(Long memberId);
|
||||||
}
|
}
|
||||||
|
@ -23,5 +23,15 @@ public interface MemberAttentionService {
|
|||||||
/**
|
/**
|
||||||
* 获取用户关注列表
|
* 获取用户关注列表
|
||||||
*/
|
*/
|
||||||
Page<MemberBrandAttention> list(Integer pageNum,Integer pageSize);
|
Page<MemberBrandAttention> list(Integer pageNum, Integer pageSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取用户关注详情
|
||||||
|
*/
|
||||||
|
MemberBrandAttention detail(Long brandId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清空关注列表
|
||||||
|
*/
|
||||||
|
void clear();
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,8 @@ public interface MemberCollectionService {
|
|||||||
int delete(Long productId);
|
int delete(Long productId);
|
||||||
|
|
||||||
Page<MemberProductCollection> list(Integer pageNum, Integer pageSize);
|
Page<MemberProductCollection> list(Integer pageNum, Integer pageSize);
|
||||||
|
|
||||||
|
MemberProductCollection detail(Long productId);
|
||||||
|
|
||||||
|
void clear();
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import org.springframework.data.domain.PageRequest;
|
|||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,6 +32,7 @@ public class MemberAttentionServiceImpl implements MemberAttentionService {
|
|||||||
memberBrandAttention.setMemberId(member.getId());
|
memberBrandAttention.setMemberId(member.getId());
|
||||||
memberBrandAttention.setMemberNickname(member.getNickname());
|
memberBrandAttention.setMemberNickname(member.getNickname());
|
||||||
memberBrandAttention.setMemberIcon(member.getIcon());
|
memberBrandAttention.setMemberIcon(member.getIcon());
|
||||||
|
memberBrandAttention.setCreateTime(new Date());
|
||||||
MemberBrandAttention findAttention = memberBrandAttentionRepository.findByMemberIdAndBrandId(memberBrandAttention.getMemberId(), memberBrandAttention.getBrandId());
|
MemberBrandAttention findAttention = memberBrandAttentionRepository.findByMemberIdAndBrandId(memberBrandAttention.getMemberId(), memberBrandAttention.getBrandId());
|
||||||
if (findAttention == null) {
|
if (findAttention == null) {
|
||||||
memberBrandAttentionRepository.save(memberBrandAttention);
|
memberBrandAttentionRepository.save(memberBrandAttention);
|
||||||
@ -51,4 +53,16 @@ public class MemberAttentionServiceImpl implements MemberAttentionService {
|
|||||||
Pageable pageable = PageRequest.of(pageNum-1,pageSize);
|
Pageable pageable = PageRequest.of(pageNum-1,pageSize);
|
||||||
return memberBrandAttentionRepository.findByMemberId(member.getId(),pageable);
|
return memberBrandAttentionRepository.findByMemberId(member.getId(),pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MemberBrandAttention detail(Long brandId) {
|
||||||
|
UmsMember member = memberService.getCurrentMember();
|
||||||
|
return memberBrandAttentionRepository.findByMemberIdAndBrandId(member.getId(), brandId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
UmsMember member = memberService.getCurrentMember();
|
||||||
|
memberBrandAttentionRepository.deleteAllByMemberId(member.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,19 @@ public class MemberCollectionServiceImpl implements MemberCollectionService {
|
|||||||
@Override
|
@Override
|
||||||
public Page<MemberProductCollection> list(Integer pageNum, Integer pageSize) {
|
public Page<MemberProductCollection> list(Integer pageNum, Integer pageSize) {
|
||||||
UmsMember member = memberService.getCurrentMember();
|
UmsMember member = memberService.getCurrentMember();
|
||||||
Pageable pageable = PageRequest.of(pageNum-1,pageSize);
|
Pageable pageable = PageRequest.of(pageNum - 1, pageSize);
|
||||||
return productCollectionRepository.findByMemberId(member.getId(),pageable);
|
return productCollectionRepository.findByMemberId(member.getId(), pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MemberProductCollection detail(Long productId) {
|
||||||
|
UmsMember member = memberService.getCurrentMember();
|
||||||
|
return productCollectionRepository.findByMemberIdAndProductId(member.getId(), productId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void clear() {
|
||||||
|
UmsMember member = memberService.getCurrentMember();
|
||||||
|
productCollectionRepository.deleteAllByMemberId(member.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user