商品关注、收藏、浏览记录接口完善
This commit is contained in:
parent
ea2737396e
commit
4befc2f514
@ -1,11 +1,13 @@
|
||||
package com.macro.mall.portal.controller;
|
||||
|
||||
import com.macro.mall.common.api.CommonPage;
|
||||
import com.macro.mall.common.api.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.data.domain.Page;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -36,8 +38,8 @@ public class MemberAttentionController {
|
||||
@ApiOperation("取消关注")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult delete(Long memberId, Long brandId) {
|
||||
int count = memberAttentionService.delete(memberId,brandId);
|
||||
public CommonResult delete(Long brandId) {
|
||||
int count = memberAttentionService.delete(brandId);
|
||||
if(count>0){
|
||||
return CommonResult.success(count);
|
||||
}else{
|
||||
@ -46,10 +48,11 @@ public class MemberAttentionController {
|
||||
}
|
||||
|
||||
@ApiOperation("显示关注列表")
|
||||
@RequestMapping(value = "/list/{memberId}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<MemberBrandAttention>> list(@PathVariable Long memberId) {
|
||||
List<MemberBrandAttention> memberBrandAttentionList = memberAttentionService.list(memberId);
|
||||
return CommonResult.success(memberBrandAttentionList);
|
||||
public CommonResult<CommonPage<MemberBrandAttention>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
|
||||
Page<MemberBrandAttention> page = memberAttentionService.list(pageNum,pageSize);
|
||||
return CommonResult.success(CommonPage.restPage(page));
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package com.macro.mall.portal.controller;
|
||||
|
||||
import com.macro.mall.common.api.CommonPage;
|
||||
import com.macro.mall.common.api.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.data.domain.Page;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -17,16 +19,16 @@ import java.util.List;
|
||||
*/
|
||||
@Controller
|
||||
@Api(tags = "MemberCollectionController", description = "会员收藏管理")
|
||||
@RequestMapping("/member/collection")
|
||||
public class MemberCollectionController {
|
||||
@RequestMapping("/member/productCollection")
|
||||
public class MemberProductCollectionController {
|
||||
@Autowired
|
||||
private MemberCollectionService memberCollectionService;
|
||||
|
||||
@ApiOperation("添加商品收藏")
|
||||
@RequestMapping(value = "/addProduct", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult addProduct(@RequestBody MemberProductCollection productCollection) {
|
||||
int count = memberCollectionService.addProduct(productCollection);
|
||||
public CommonResult add(@RequestBody MemberProductCollection productCollection) {
|
||||
int count = memberCollectionService.add(productCollection);
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count);
|
||||
} else {
|
||||
@ -35,10 +37,10 @@ public class MemberCollectionController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除收藏商品")
|
||||
@RequestMapping(value = "/deleteProduct", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public CommonResult deleteProduct(Long memberId, Long productId) {
|
||||
int count = memberCollectionService.deleteProduct(memberId, productId);
|
||||
public CommonResult delete(Long productId) {
|
||||
int count = memberCollectionService.delete(productId);
|
||||
if (count > 0) {
|
||||
return CommonResult.success(count);
|
||||
} else {
|
||||
@ -47,10 +49,11 @@ public class MemberCollectionController {
|
||||
}
|
||||
|
||||
@ApiOperation("显示关注列表")
|
||||
@RequestMapping(value = "/listProduct/{memberId}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<MemberProductCollection>> listProduct(@PathVariable Long memberId) {
|
||||
List<MemberProductCollection> memberProductCollectionList = memberCollectionService.listProduct(memberId);
|
||||
return CommonResult.success(memberProductCollectionList);
|
||||
public CommonResult<CommonPage<MemberProductCollection>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
|
||||
Page<MemberProductCollection> page = memberCollectionService.list(pageNum,pageSize);
|
||||
return CommonResult.success(CommonPage.restPage(page));
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package com.macro.mall.portal.controller;
|
||||
|
||||
import com.macro.mall.common.api.CommonPage;
|
||||
import com.macro.mall.common.api.CommonResult;
|
||||
import com.macro.mall.portal.domain.MemberReadHistory;
|
||||
import com.macro.mall.portal.service.MemberReadHistoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -46,11 +48,12 @@ public class MemberReadHistoryController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("展示浏览记录")
|
||||
@ApiOperation("分页获取用户浏览记录")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public CommonResult<List<MemberReadHistory>> list(Long memberId) {
|
||||
List<MemberReadHistory> memberReadHistoryList = memberReadHistoryService.list(memberId);
|
||||
return CommonResult.success(memberReadHistoryList);
|
||||
public CommonResult<CommonPage<MemberReadHistory>> list(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
|
||||
Page<MemberReadHistory> page = memberReadHistoryService.list(pageNum, pageSize);
|
||||
return CommonResult.success(CommonPage.restPage(page));
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ public class MemberBrandAttention {
|
||||
private String brandName;
|
||||
private String brandLogo;
|
||||
private String brandCity;
|
||||
private Integer brandAttentionCount;
|
||||
private Date createTime;
|
||||
|
||||
public String getId() {
|
||||
@ -90,14 +89,6 @@ public class MemberBrandAttention {
|
||||
this.brandCity = brandCity;
|
||||
}
|
||||
|
||||
public Integer getBrandAttentionCount() {
|
||||
return brandAttentionCount;
|
||||
}
|
||||
|
||||
public void setBrandAttentionCount(Integer brandAttentionCount) {
|
||||
this.brandAttentionCount = brandAttentionCount;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.macro.mall.portal.repository;
|
||||
|
||||
import com.macro.mall.portal.domain.MemberBrandAttention;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
@ -12,5 +14,5 @@ import java.util.List;
|
||||
public interface MemberBrandAttentionRepository extends MongoRepository<MemberBrandAttention,String> {
|
||||
MemberBrandAttention findByMemberIdAndBrandId(Long memberId, Long brandId);
|
||||
int deleteByMemberIdAndBrandId(Long memberId,Long brandId);
|
||||
List<MemberBrandAttention> findByMemberId(Long memberId);
|
||||
Page<MemberBrandAttention> findByMemberId(Long memberId, Pageable pageable);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.macro.mall.portal.repository;
|
||||
|
||||
import com.macro.mall.portal.domain.MemberProductCollection;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
@ -12,5 +14,5 @@ import java.util.List;
|
||||
public interface MemberProductCollectionRepository extends MongoRepository<MemberProductCollection,String> {
|
||||
MemberProductCollection findByMemberIdAndProductId(Long memberId, Long productId);
|
||||
int deleteByMemberIdAndProductId(Long memberId,Long productId);
|
||||
List<MemberProductCollection> findByMemberId(Long memberId);
|
||||
Page<MemberProductCollection> findByMemberId(Long memberId, Pageable pageable);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.macro.mall.portal.repository;
|
||||
|
||||
import com.macro.mall.portal.domain.MemberReadHistory;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
import java.util.List;
|
||||
@ -10,5 +12,5 @@ import java.util.List;
|
||||
* Created by macro on 2018/8/3.
|
||||
*/
|
||||
public interface MemberReadHistoryRepository extends MongoRepository<MemberReadHistory,String> {
|
||||
List<MemberReadHistory> findByMemberIdOrderByCreateTimeDesc(Long memberId);
|
||||
Page<MemberReadHistory> findByMemberIdOrderByCreateTimeDesc(Long memberId, Pageable pageable);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.macro.mall.portal.service;
|
||||
|
||||
import com.macro.mall.portal.domain.MemberBrandAttention;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -17,10 +18,10 @@ public interface MemberAttentionService {
|
||||
/**
|
||||
* 取消关注
|
||||
*/
|
||||
int delete(Long memberId, Long brandId);
|
||||
int delete(Long brandId);
|
||||
|
||||
/**
|
||||
* 获取用户关注列表
|
||||
*/
|
||||
List<MemberBrandAttention> list(Long memberId);
|
||||
Page<MemberBrandAttention> list(Integer pageNum,Integer pageSize);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.macro.mall.portal.service;
|
||||
|
||||
import com.macro.mall.portal.domain.MemberProductCollection;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -9,9 +10,9 @@ import java.util.List;
|
||||
* Created by macro on 2018/8/2.
|
||||
*/
|
||||
public interface MemberCollectionService {
|
||||
int addProduct(MemberProductCollection productCollection);
|
||||
int add(MemberProductCollection productCollection);
|
||||
|
||||
int deleteProduct(Long memberId, Long productId);
|
||||
int delete(Long productId);
|
||||
|
||||
List<MemberProductCollection> listProduct(Long memberId);
|
||||
Page<MemberProductCollection> list(Integer pageNum, Integer pageSize);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.macro.mall.portal.service;
|
||||
|
||||
import com.macro.mall.portal.domain.MemberReadHistory;
|
||||
import org.springframework.data.domain.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -20,7 +21,7 @@ public interface MemberReadHistoryService {
|
||||
int delete(List<String> ids);
|
||||
|
||||
/**
|
||||
* 获取用户浏览历史记录
|
||||
* 分页获取用户浏览历史记录
|
||||
*/
|
||||
List<MemberReadHistory> list(Long memberId);
|
||||
Page<MemberReadHistory> list(Integer pageNum, Integer pageSize);
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.macro.mall.portal.service.impl;
|
||||
|
||||
import com.macro.mall.model.UmsMember;
|
||||
import com.macro.mall.portal.domain.MemberBrandAttention;
|
||||
import com.macro.mall.portal.repository.MemberBrandAttentionRepository;
|
||||
import com.macro.mall.portal.service.MemberAttentionService;
|
||||
import com.macro.mall.portal.service.UmsMemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,10 +21,16 @@ import java.util.List;
|
||||
public class MemberAttentionServiceImpl implements MemberAttentionService {
|
||||
@Autowired
|
||||
private MemberBrandAttentionRepository memberBrandAttentionRepository;
|
||||
@Autowired
|
||||
private UmsMemberService memberService;
|
||||
|
||||
@Override
|
||||
public int add(MemberBrandAttention memberBrandAttention) {
|
||||
int count = 0;
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
memberBrandAttention.setMemberId(member.getId());
|
||||
memberBrandAttention.setMemberNickname(member.getNickname());
|
||||
memberBrandAttention.setMemberIcon(member.getIcon());
|
||||
MemberBrandAttention findAttention = memberBrandAttentionRepository.findByMemberIdAndBrandId(memberBrandAttention.getMemberId(), memberBrandAttention.getBrandId());
|
||||
if (findAttention == null) {
|
||||
memberBrandAttentionRepository.save(memberBrandAttention);
|
||||
@ -29,12 +40,15 @@ public class MemberAttentionServiceImpl implements MemberAttentionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long memberId, Long brandId) {
|
||||
return memberBrandAttentionRepository.deleteByMemberIdAndBrandId(memberId,brandId);
|
||||
public int delete(Long brandId) {
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
return memberBrandAttentionRepository.deleteByMemberIdAndBrandId(member.getId(),brandId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberBrandAttention> list(Long memberId) {
|
||||
return memberBrandAttentionRepository.findByMemberId(memberId);
|
||||
public Page<MemberBrandAttention> list(Integer pageNum, Integer pageSize) {
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
Pageable pageable = PageRequest.of(pageNum-1,pageSize);
|
||||
return memberBrandAttentionRepository.findByMemberId(member.getId(),pageable);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.macro.mall.portal.service.impl;
|
||||
|
||||
import com.macro.mall.model.UmsMember;
|
||||
import com.macro.mall.portal.domain.MemberProductCollection;
|
||||
import com.macro.mall.portal.repository.MemberProductCollectionRepository;
|
||||
import com.macro.mall.portal.service.MemberCollectionService;
|
||||
import com.macro.mall.portal.service.UmsMemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
@ -16,10 +21,16 @@ import java.util.List;
|
||||
public class MemberCollectionServiceImpl implements MemberCollectionService {
|
||||
@Autowired
|
||||
private MemberProductCollectionRepository productCollectionRepository;
|
||||
@Autowired
|
||||
private UmsMemberService memberService;
|
||||
|
||||
@Override
|
||||
public int addProduct(MemberProductCollection productCollection) {
|
||||
public int add(MemberProductCollection productCollection) {
|
||||
int count = 0;
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
productCollection.setMemberId(member.getId());
|
||||
productCollection.setMemberNickname(member.getNickname());
|
||||
productCollection.setMemberIcon(member.getIcon());
|
||||
MemberProductCollection findCollection = productCollectionRepository.findByMemberIdAndProductId(productCollection.getMemberId(), productCollection.getProductId());
|
||||
if (findCollection == null) {
|
||||
productCollectionRepository.save(productCollection);
|
||||
@ -29,12 +40,15 @@ public class MemberCollectionServiceImpl implements MemberCollectionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteProduct(Long memberId, Long productId) {
|
||||
return productCollectionRepository.deleteByMemberIdAndProductId(memberId, productId);
|
||||
public int delete(Long productId) {
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
return productCollectionRepository.deleteByMemberIdAndProductId(member.getId(), productId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberProductCollection> listProduct(Long memberId) {
|
||||
return productCollectionRepository.findByMemberId(memberId);
|
||||
public Page<MemberProductCollection> list(Integer pageNum, Integer pageSize) {
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
Pageable pageable = PageRequest.of(pageNum-1,pageSize);
|
||||
return productCollectionRepository.findByMemberId(member.getId(),pageable);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,14 @@
|
||||
package com.macro.mall.portal.service.impl;
|
||||
|
||||
import com.macro.mall.model.UmsMember;
|
||||
import com.macro.mall.portal.domain.MemberReadHistory;
|
||||
import com.macro.mall.portal.repository.MemberReadHistoryRepository;
|
||||
import com.macro.mall.portal.service.MemberReadHistoryService;
|
||||
import com.macro.mall.portal.service.UmsMemberService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -18,8 +23,14 @@ import java.util.List;
|
||||
public class MemberReadHistoryServiceImpl implements MemberReadHistoryService {
|
||||
@Autowired
|
||||
private MemberReadHistoryRepository memberReadHistoryRepository;
|
||||
@Autowired
|
||||
private UmsMemberService memberService;
|
||||
@Override
|
||||
public int create(MemberReadHistory memberReadHistory) {
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
memberReadHistory.setMemberId(member.getId());
|
||||
memberReadHistory.setMemberNickname(member.getNickname());
|
||||
memberReadHistory.setMemberIcon(member.getIcon());
|
||||
memberReadHistory.setId(null);
|
||||
memberReadHistory.setCreateTime(new Date());
|
||||
memberReadHistoryRepository.save(memberReadHistory);
|
||||
@ -39,7 +50,9 @@ public class MemberReadHistoryServiceImpl implements MemberReadHistoryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MemberReadHistory> list(Long memberId) {
|
||||
return memberReadHistoryRepository.findByMemberIdOrderByCreateTimeDesc(memberId);
|
||||
public Page<MemberReadHistory> list(Integer pageNum, Integer pageSize) {
|
||||
UmsMember member = memberService.getCurrentMember();
|
||||
Pageable pageable = PageRequest.of(pageNum-1, pageSize);
|
||||
return memberReadHistoryRepository.findByMemberIdOrderByCreateTimeDesc(member.getId(),pageable);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user