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.*;

import java.util.List;

/**
 * 会员收藏管理Controller
 * Created by macro on 2018/8/2.
 */
@Controller
@Api(tags = "MemberCollectionController", description = "会员收藏管理")
@RequestMapping("/member/productCollection")
public class MemberProductCollectionController {
    @Autowired
    private MemberCollectionService memberCollectionService;

    @ApiOperation("添加商品收藏")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult add(@RequestBody MemberProductCollection productCollection) {
        int count = memberCollectionService.add(productCollection);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

    @ApiOperation("删除收藏商品")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult delete(Long productId) {
        int count = memberCollectionService.delete(productId);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

    @ApiOperation("显示收藏列表")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    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));
    }

    @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);
    }
}

@@ -572,16 +572,18 @@
 **%0A * %E4%BC%9A%E5%91%98
+%E5%95%86%E5%93%81
 %E6%94%B6%E8%97%8F%E7%AE%A1%E7%90%86Cont
@@ -589,16 +589,16 @@
 troller%0A
-
  * Creat
@@ -1310,20 +1310,20 @@
 tion(%22%E5%88%A0%E9%99%A4
-%E6%94%B6%E8%97%8F
 %E5%95%86%E5%93%81
+%E6%94%B6%E8%97%8F
 %22)%0A    @
@@ -1685,16 +1685,18 @@
 tion(%22%E6%98%BE%E7%A4%BA
+%E5%95%86%E5%93%81
 %E6%94%B6%E8%97%8F%E5%88%97%E8%A1%A8%22)%0A 
@@ -2242,12 +2242,12 @@
 (%22%E6%98%BE%E7%A4%BA
-%E6%94%B6%E8%97%8F
 %E5%95%86%E5%93%81
+%E6%94%B6%E8%97%8F
 %E8%AF%A6%E6%83%85%22)
@@ -2582,32 +2582,32 @@
 ection);%0A    %7D%0A%0A
-
     @ApiOperatio
@@ -2611,16 +2611,18 @@
 tion(%22%E6%B8%85%E7%A9%BA
+%E5%95%86%E5%93%81
 %E6%94%B6%E8%97%8F%E5%88%97%E8%A1%A8%22)%0A 

Update MemberProductCollectionController.java