ProductController.java 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package com.example.xiaoshiweixinback.controller;
  2. import com.example.xiaoshiweixinback.business.common.Constants;
  3. import com.example.xiaoshiweixinback.business.common.Response;
  4. import com.example.xiaoshiweixinback.business.common.base.Records;
  5. import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
  6. import com.example.xiaoshiweixinback.entity.product.ProductDTO;
  7. import com.example.xiaoshiweixinback.service.ProductService;
  8. import io.swagger.v3.oas.annotations.Operation;
  9. import io.swagger.v3.oas.models.security.SecurityScheme;
  10. import lombok.RequiredArgsConstructor;
  11. import lombok.extern.slf4j.Slf4j;
  12. import org.springframework.web.bind.annotation.PostMapping;
  13. import org.springframework.web.bind.annotation.RequestBody;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. @Slf4j
  17. @RequestMapping(Constants.XIAOSHI_WEIXINBACK + "/product")
  18. @RestController
  19. @RequiredArgsConstructor
  20. public class ProductController {
  21. private final ProductService productService;
  22. @Operation(summary = "查询爆款产品")
  23. @PostMapping("/queryHotProduct")
  24. public Response queryHotProduct(@RequestBody ProductDTO productDTO) {
  25. Records records = productService.queryHotProduct(productDTO);
  26. return Response.success(records);
  27. }
  28. @Operation(summary = "添加或更新产品")
  29. @PostMapping("/addOrUpdateProduct")
  30. public Response addOrUpdateProduct(@RequestBody ProductAddDTO productAddDTO) {
  31. Records records = new Records();
  32. Integer id = productService.addOrUpdateProduct(productAddDTO);
  33. records.setData(id);
  34. return Response.success(records);
  35. }
  36. }