|
@@ -4,17 +4,17 @@ package com.example.xiaoshiweixinback.controller;
|
|
import com.example.xiaoshiweixinback.business.common.Constants;
|
|
import com.example.xiaoshiweixinback.business.common.Constants;
|
|
import com.example.xiaoshiweixinback.business.common.Response;
|
|
import com.example.xiaoshiweixinback.business.common.Response;
|
|
import com.example.xiaoshiweixinback.business.common.base.Records;
|
|
import com.example.xiaoshiweixinback.business.common.base.Records;
|
|
|
|
+import com.example.xiaoshiweixinback.domain.AssoPersonProduct;
|
|
|
|
+import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
|
|
import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
|
|
import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
|
|
import com.example.xiaoshiweixinback.entity.product.ProductDTO;
|
|
import com.example.xiaoshiweixinback.entity.product.ProductDTO;
|
|
|
|
+import com.example.xiaoshiweixinback.service.AssoPersonProductService;
|
|
import com.example.xiaoshiweixinback.service.ProductService;
|
|
import com.example.xiaoshiweixinback.service.ProductService;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
@RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/product")
|
|
@RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/product")
|
|
@@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
public class ProductController {
|
|
public class ProductController {
|
|
private final ProductService productService;
|
|
private final ProductService productService;
|
|
|
|
+ private final AssoPersonProductService assoPersonProductService;
|
|
|
|
|
|
@Operation(summary = "查询爆款产品")
|
|
@Operation(summary = "查询爆款产品")
|
|
@PostMapping("/queryHotProduct")
|
|
@PostMapping("/queryHotProduct")
|
|
@@ -39,5 +40,30 @@ public class ProductController {
|
|
return Response.success(records);
|
|
return Response.success(records);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Operation(summary = "关注产品")
|
|
|
|
+ @PostMapping("/follow")
|
|
|
|
+ public Response follow(@RequestBody AssoPersonProductDTO assoPersonProductDTO){
|
|
|
|
+ Records records = new Records();
|
|
|
|
+ Integer id = assoPersonProductService.add(assoPersonProductDTO);
|
|
|
|
+ if (id.equals(-1)) {
|
|
|
|
+ return Response.error("未查询到登陆人");
|
|
|
|
+ }
|
|
|
|
+ records.setData(id);
|
|
|
|
+ return Response.success(records);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
+ @Operation(summary = "取消关注产品")
|
|
|
|
+ @GetMapping("/unFollow")
|
|
|
|
+ public Response unFollow(Integer productId){
|
|
|
|
+ Records records = new Records();
|
|
|
|
+ Integer id = assoPersonProductService.cancel(productId);
|
|
|
|
+ if (id.equals(-1)) {
|
|
|
|
+ return Response.error("取消失败");
|
|
|
|
+ } else if (id.equals(0)) {
|
|
|
|
+ return Response.error("没有权限");
|
|
|
|
+ }
|
|
|
|
+ records.setData(id);
|
|
|
|
+ return Response.success(records);
|
|
|
|
+ }
|
|
}
|
|
}
|