Parcourir la source

添加浏览记录功能

zhh il y a 6 ans
Parent
commit
cc11296120

+ 9 - 7
README.md

@@ -60,13 +60,13 @@ RestTemplate服务间调用 |
 
 ### 后台功能
 
-#### 后台登录功能(完成)
+#### 后台登录功能
 
 - 后台用户注册功能
 - 后台用户登录后获取token
 - 刷新token功能
 
-#### 商品管理(完成)
+#### 商品管理
 
 > **商品分类管理**
 
@@ -134,12 +134,12 @@ RestTemplate服务间调用 |
 - 查看记录:审核记录,操作日志
 - sku:根据产品及sku编号获取sku信息,批量修改sku信息
 
-> **商品回收管理(暂无)**
+> **商品回收管理**
 
 - 分页展示回收商品列表
 - 回收商品还原功能
 
-> **商品评价管理(暂无)**
+> **商品评价管理**
 
 #### 促销管理
 
@@ -232,7 +232,7 @@ RestTemplate服务间调用 |
 
 ### 前台功能
 
-#### 商品搜索
+#### 商品搜索
 
 > **综合搜索功能**
 
@@ -252,13 +252,13 @@ RestTemplate服务间调用 |
 
 - 根据用户搜索记录聚合生成热搜词
 
-> **商品搜索联想功能**
+> **商品搜索联想功能**
 
 - 根据用户搜索记录聚合生成热搜词
 
 #### 购物流程
 
-> **购物车**
+> **购物车**
 
 - 添加商品到购物车
 - 购物车商品列表(商品主图、商品名称、商品数量、商品规格)
@@ -289,6 +289,7 @@ RestTemplate服务间调用 |
 
 - 关注品牌列表:品牌logo、名称、地址、关注数量
 - 取消关注功能
+- 关注列表展示
 
 > **我的收藏**
 
@@ -300,6 +301,7 @@ RestTemplate服务间调用 |
 
 - 浏览过的商品:商品主图、名称、卖点、价格、找相似
 - 删除记录功能
+- 浏览列表展示
 
 > **会员登录**
 

+ 1 - 1
mall-portal/src/main/java/com/macro/mall/portal/controller/MemberCollectionController.java

@@ -48,7 +48,7 @@ public class MemberCollectionController {
     @ApiOperation("显示关注列表")
     @RequestMapping(value = "/listProduct/{memberId}", method = RequestMethod.GET)
     @ResponseBody
-    public Object list(@PathVariable Long memberId) {
+    public Object listProduct(@PathVariable Long memberId) {
         List<MemberProductCollection> memberProductCollectionList = memberCollectionService.listProduct(memberId);
         return new CommonResult().success(memberProductCollectionList);
     }

+ 56 - 0
mall-portal/src/main/java/com/macro/mall/portal/controller/MemberReadHistoryController.java

@@ -0,0 +1,56 @@
+package com.macro.mall.portal.controller;
+
+import com.macro.mall.portal.domain.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.stereotype.Controller;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 会员商品浏览记录管理Controller
+ * Created by macro on 2018/8/3.
+ */
+@Controller
+@Api(tags = "MemberReadHistoryController", description = "会员商品浏览记录管理")
+@RequestMapping("/member/readHistory")
+public class MemberReadHistoryController {
+    @Autowired
+    private MemberReadHistoryService memberReadHistoryService;
+
+    @ApiOperation("创建浏览记录")
+    @RequestMapping(value = "/create", method = RequestMethod.POST)
+    @ResponseBody
+    public Object create(@RequestBody MemberReadHistory memberReadHistory) {
+        int count  = memberReadHistoryService.create(memberReadHistory);
+        if(count>0){
+            return new CommonResult().success(count);
+        }else{
+            return new CommonResult().failed();
+        }
+    }
+
+    @ApiOperation("删除浏览记录")
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    @ResponseBody
+    public Object delete(@RequestParam("ids") List<String> ids) {
+        int count  = memberReadHistoryService.delete(ids);
+        if(count>0){
+            return new CommonResult().success(count);
+        }else{
+            return new CommonResult().failed();
+        }
+    }
+
+    @ApiOperation("展示浏览记录")
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    @ResponseBody
+    public Object list(Long memberId) {
+        List<MemberReadHistory> memberReadHistoryList = memberReadHistoryService.list(memberId);
+        return new CommonResult().success(memberReadHistoryList);
+    }
+}

+ 108 - 0
mall-portal/src/main/java/com/macro/mall/portal/domain/MemberReadHistory.java

@@ -0,0 +1,108 @@
+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/3.
+ */
+@Document
+public class MemberReadHistory {
+    @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;
+    }
+}

+ 14 - 0
mall-portal/src/main/java/com/macro/mall/portal/repository/MemberReadHistoryRepository.java

@@ -0,0 +1,14 @@
+package com.macro.mall.portal.repository;
+
+import com.macro.mall.portal.domain.MemberReadHistory;
+import org.springframework.data.mongodb.repository.MongoRepository;
+
+import java.util.List;
+
+/**
+ * 会员商品浏览历史Repository
+ * Created by macro on 2018/8/3.
+ */
+public interface MemberReadHistoryRepository extends MongoRepository<MemberReadHistory,String> {
+    List<MemberReadHistory> findByMemberIdOrderByCreateTimeDesc(Long memberId);
+}

+ 26 - 0
mall-portal/src/main/java/com/macro/mall/portal/service/MemberReadHistoryService.java

@@ -0,0 +1,26 @@
+package com.macro.mall.portal.service;
+
+import com.macro.mall.portal.domain.MemberReadHistory;
+
+import java.util.List;
+
+/**
+ * 会员浏览记录管理Service
+ * Created by macro on 2018/8/3.
+ */
+public interface MemberReadHistoryService {
+    /**
+     * 生成浏览记录
+     */
+    int create(MemberReadHistory memberReadHistory);
+
+    /**
+     * 批量删除浏览记录
+     */
+    int delete(List<String> ids);
+
+    /**
+     * 获取用户浏览历史记录
+     */
+    List<MemberReadHistory> list(Long memberId);
+}

+ 45 - 0
mall-portal/src/main/java/com/macro/mall/portal/service/impl/MemberReadHistoryServiceImpl.java

@@ -0,0 +1,45 @@
+package com.macro.mall.portal.service.impl;
+
+import com.macro.mall.portal.domain.MemberReadHistory;
+import com.macro.mall.portal.repository.MemberReadHistoryRepository;
+import com.macro.mall.portal.service.MemberReadHistoryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 会员浏览记录管理Service实现类
+ * Created by macro on 2018/8/3.
+ */
+@Service
+public class MemberReadHistoryServiceImpl implements MemberReadHistoryService {
+    @Autowired
+    private MemberReadHistoryRepository memberReadHistoryRepository;
+    @Override
+    public int create(MemberReadHistory memberReadHistory) {
+        memberReadHistory.setId(null);
+        memberReadHistory.setCreateTime(new Date());
+        memberReadHistoryRepository.save(memberReadHistory);
+        return 1;
+    }
+
+    @Override
+    public int delete(List<String> ids) {
+        List<MemberReadHistory> deleteList = new ArrayList<>();
+        for(String id:ids){
+            MemberReadHistory memberReadHistory = new MemberReadHistory();
+            memberReadHistory.setId(id);
+            deleteList.add(memberReadHistory);
+        }
+        memberReadHistoryRepository.delete(deleteList);
+        return ids.size();
+    }
+
+    @Override
+    public List<MemberReadHistory> list(Long memberId) {
+        return memberReadHistoryRepository.findByMemberIdOrderByCreateTimeDesc(memberId);
+    }
+}