|
@@ -0,0 +1,66 @@
|
|
|
+package com.caimei365.commodity.controller;
|
|
|
+
|
|
|
+import com.caimei365.commodity.model.ResponseJson;
|
|
|
+import com.caimei365.commodity.model.vo.PaginationVo;
|
|
|
+import com.caimei365.commodity.model.vo.ProductItemVo;
|
|
|
+import com.caimei365.commodity.service.UserLikeService;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author zzj 2021/9/17
|
|
|
+ */
|
|
|
+@Api(tags = "用户收藏API")
|
|
|
+@RestController
|
|
|
+@RequiredArgsConstructor
|
|
|
+@RequestMapping("/commodity/userLike")
|
|
|
+public class UserLikeApi {
|
|
|
+
|
|
|
+ private final UserLikeService userLikeService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品收藏(单个商品)
|
|
|
+ */
|
|
|
+ @ApiOperation("单个商品收藏/取消收藏")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(required = true, name = "userID", value = "当前用户id"),
|
|
|
+ @ApiImplicitParam(required = true, name = "productID", value = "收藏商品id"),
|
|
|
+ })
|
|
|
+ @GetMapping("/likeOne")
|
|
|
+ public ResponseJson<String> like(Integer userID, Integer productID) {
|
|
|
+ if (userID == null || productID == null) {
|
|
|
+ return ResponseJson.error("非法参数");
|
|
|
+ }
|
|
|
+ return userLikeService.likeOne(userID, productID);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 个人中心收藏商品列表
|
|
|
+ *
|
|
|
+ * @param userID 用户Id
|
|
|
+ */
|
|
|
+ @ApiOperation("收藏商品列表")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(required = false, name = "userId", value = "用户Id"),
|
|
|
+ @ApiImplicitParam(required = false, name = "pageNum", value = "页码"),
|
|
|
+ @ApiImplicitParam(required = false, name = "pageSize", value = "每页数量")
|
|
|
+ })
|
|
|
+ @GetMapping("/likeList")
|
|
|
+ public ResponseJson<PaginationVo<ProductItemVo>> likes(Integer userID,
|
|
|
+ @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "10") int pageSize) {
|
|
|
+ if(userID==null){
|
|
|
+ return ResponseJson.error("非法参数");
|
|
|
+ }
|
|
|
+ return userLikeService.findLikeList(userID, pageNum, pageSize);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|