浏览代码

4/23 工单修改

lwhhszx 1 年之前
父节点
当前提交
b7d3763cb8

+ 23 - 2
src/main/java/com/example/xiaoshiweixinback/controller/ProductController.java

@@ -8,8 +8,10 @@ import com.example.xiaoshiweixinback.business.exception.BusinessException;
 import com.example.xiaoshiweixinback.checkLogin.checkLogin;
 import com.example.xiaoshiweixinback.domain.AssoPersonProduct;
 import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
+import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
 import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
 import com.example.xiaoshiweixinback.entity.product.ProductDTO;
+import com.example.xiaoshiweixinback.entity.vo.ProductVO;
 import com.example.xiaoshiweixinback.service.AssoPersonProductService;
 import com.example.xiaoshiweixinback.service.ProductService;
 import io.swagger.v3.oas.annotations.Operation;
@@ -90,10 +92,29 @@ public class ProductController {
     @checkLogin
     @Operation(summary = "添加或更新爆款产品")
     @PostMapping("/addOrUpdateHotProduct")
-    public Response addOrUpdateHotProduct(@RequestBody ProductDTO productDTO) {
-        Records records = productService.queryConcernProduct(productDTO);
+    public Response addOrUpdateHotProduct(@RequestBody HotProductAddDTO hotProductAddDTO) {
+        Integer id = productService.addOrUpdateHotProduct(hotProductAddDTO);
+        return Response.success(id);
+    }
+
+    @checkLogin
+    @Operation(summary = "查看单个产品详情")
+    @PostMapping("/queryHotProductDetail")
+    public Response queryHotProductDetail(Integer id) {
+        ProductVO productVO = productService.queryHotProductDetail(id);
+        Records records =new Records();
+        records.setData(productVO);
         return Response.success(records);
     }
 
 
+    @checkLogin
+    @Operation(summary = "查看单个产品详情")
+    @PostMapping("/updateProductIfShow")
+    public Response updateProductIfShow(Integer id) {
+        ProductVO productVO = productService.updateProductIfShow(id);
+        Records records =new Records();
+        records.setData(productVO);
+        return Response.success(records);
+    }
 }

+ 10 - 6
src/main/java/com/example/xiaoshiweixinback/entity/dto/GetProductDTO.java

@@ -6,10 +6,14 @@ import java.util.List;
 
 @Data
 public class GetProductDTO {
-private List<Integer> categoryIds;
-private String name;
-private Long size;
-private Long current;
-private String personUuid;
-private List<Integer> concernTypes;
+    private List<Integer> categoryIds;
+    private String name;
+    private Long size;
+    private Long current;
+    private String personUuid;
+    private List<Integer> concernTypes;
+    private Boolean ifShow;
+    List<Integer> productCategoryIds;
+    private String sourceFrom;
+    private String bestSellingBrand;
 }

+ 55 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/HotProductAddDTO.java

@@ -0,0 +1,55 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class HotProductAddDTO {
+
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     *
+     */
+    private String name;
+
+    /**
+     *
+     */
+    private String description;
+
+    /**
+     * 检索条件
+     */
+    private String searchCondition;
+
+    /**
+     * 来源
+     */
+    private String sourceFrom;
+
+    /**
+     * 售卖平台
+     */
+    private String sellPlatform;
+
+    /**
+     * 平台链接
+     */
+    private String platformLink;
+    /**
+     * 价格
+     */
+    private  Double price;
+    /**
+     * 品牌
+     */
+    private String bestSellingBrand;
+    private List<String> fileGuids;
+    private Boolean ifShow;
+    private Integer productCategoryId;
+}

+ 4 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/ProductDTO.java

@@ -10,4 +10,8 @@ public class ProductDTO {
     private Long current;
     private Long size;
     private List<Integer> concernTypes;
+    private  Boolean ifShow;
+   List<Integer> productCategoryIds;
+    private String sourceFrom;
+    private  String bestSellingBrand;
 }

+ 12 - 0
src/main/java/com/example/xiaoshiweixinback/entity/product/UpdateProductShowDTO.java

@@ -0,0 +1,12 @@
+package com.example.xiaoshiweixinback.entity.product;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class UpdateProductShowDTO {
+    private List<Integer> ids;
+    private Boolean ifShow;
+
+}

+ 6 - 5
src/main/java/com/example/xiaoshiweixinback/service/AssoProductFileService.java

@@ -2,10 +2,13 @@ package com.example.xiaoshiweixinback.service;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
+import com.example.xiaoshiweixinback.business.utils.LoginUtils;
 import com.example.xiaoshiweixinback.domain.AssoPersonCategory;
 import com.example.xiaoshiweixinback.domain.AssoProductFile;
 import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
 import com.example.xiaoshiweixinback.mapper.AssoProductFileMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -20,16 +23,14 @@ import java.util.stream.Collectors;
  */
 @Service
 public class AssoProductFileService extends ServiceImpl<AssoProductFileMapper, AssoProductFile> {
+
+   @Autowired
+    private CacheUtil cacheUtil;
     @Transactional
     public void addOrUpdateProductFile(Integer productId, List<String> guids) {
         if(guids==null){
             guids=new ArrayList<>();
         }
-        //PersonnelVO personnelVO =cacheUtil.getLoginUser(loginUtils.getId());
-        PersonnelVO personnelVO = new PersonnelVO();
-        personnelVO.setId(1);
-        personnelVO.setUuid("123");
-
         LambdaQueryWrapper<AssoProductFile> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(AssoProductFile::getProductId, productId);
         List<AssoProductFile> assoProductFiles = this.list(queryWrapper);

+ 68 - 9
src/main/java/com/example/xiaoshiweixinback/service/ProductService.java

@@ -15,6 +15,7 @@ import com.example.xiaoshiweixinback.domain.AssoProductFile;
 import com.example.xiaoshiweixinback.domain.Product;
 import com.example.xiaoshiweixinback.entity.dto.AssoPersonProductDTO;
 import com.example.xiaoshiweixinback.entity.dto.GetProductDTO;
+import com.example.xiaoshiweixinback.entity.product.HotProductAddDTO;
 import com.example.xiaoshiweixinback.entity.product.ProductAddDTO;
 import com.example.xiaoshiweixinback.entity.product.ProductDTO;
 import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
@@ -66,6 +67,7 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         List<Integer> ids = assoPersonCategoryService.getChoosedProductCategoryIds();
 
         GetProductDTO getProductDTO = new GetProductDTO();
+        BeanUtils.copyProperties(productDTO,getProductDTO);
         getProductDTO.setName(name);
         getProductDTO.setCurrent(current);
         getProductDTO.setSize(size);
@@ -156,14 +158,14 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
             assoPersonProductDTO.setConcernType(productAddDTO.getConcernType());
             Integer flag = assoPersonProductService.addAsso(assoPersonProductDTO);
         } else {
-            product = this.updateProduct(productAddDTO);
+            product = this.updateProduct(productAddDTO,productAddDTO.getId());
         }
         assoProductFileService.addOrUpdateProductFile(product.getId(), productAddDTO.getFileGuids());
         return product.getId();
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public Product addProduct(ProductAddDTO productAddDTO) {
+    public Product addProduct(Object productAddDTO) {
         Product product = new Product();
         BeanUtils.copyProperties(productAddDTO, product);
         PersonnelVO personnelVO = cacheUtil.getLoginUser(LoginUtils.getToken());
@@ -174,14 +176,15 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public Product updateProduct(ProductAddDTO productAddDTO) {
+    public Product updateProduct(Object productAddDTO,Integer id) {
         Product product = new Product();
-        product = this.getById(productAddDTO.getId());
-        product.setName(productAddDTO.getName());
-        product.setDescription(productAddDTO.getDescription());
-        product.setSearchCondition(productAddDTO.getSearchCondition());
-        product.setSellPlatform(productAddDTO.getSellPlatform());
-        product.setSourceFrom(productAddDTO.getSourceFrom());
+        Product orgProduct = this.getById(id);
+        BeanUtils.copyProperties(productAddDTO, product);
+        product.setId(orgProduct.getId());
+        product.setIfHot(orgProduct.getIfHot());
+        product.setIfCustomized(orgProduct.getIfCustomized());
+        product.setCreateId(orgProduct.getCreateId());
+        product.setCreateTime(orgProduct.getCreateTime());
         product.updateById();
         return product;
     }
@@ -217,6 +220,62 @@ public class ProductService extends ServiceImpl<ProductMapper, Product> {
         records.setTotal(count);
         return records;
     }
+
+
+
+    @Transactional(rollbackFor = Exception.class)
+    public Integer addOrUpdateHotProduct(HotProductAddDTO hotProductAddDTO) {
+        Product product = new Product();
+        if (hotProductAddDTO.getId() == null) {
+            assoPersonProductService.checkAdmin();
+            product = this.addProduct(hotProductAddDTO);
+        } else {
+            product = this.updateProduct(hotProductAddDTO,hotProductAddDTO.getId());
+        }
+        assoProductFileService.addOrUpdateProductFile(product.getId(), hotProductAddDTO.getFileGuids());
+        return product.getId();
+    }
+
+
+
+    /**
+     * 根据id查询爆款专利
+     *
+     * @param id
+     * @return
+     */
+    public ProductVO queryHotProductDetail(Integer id) {
+        ProductVO productVO =new ProductVO();
+        Product product =this.getById(id);
+        if(product ==null){
+            return  productVO;
+        }
+        BeanUtils.copyProperties(product,productVO);
+        List<ProductVO> productVOS =new ArrayList<>();
+        productVOS.add(productVO);
+        this.loadProduct(productVOS);
+        return productVO;
+    }
+
+
+    /**
+     * 根据id查询爆款专利
+     *
+     * @param id
+     * @return
+     */
+    public ProductVO updateProductIfShow(Integer id) {
+        ProductVO productVO =new ProductVO();
+        Product product =this.getById(id);
+        if(product ==null){
+            return  productVO;
+        }
+        BeanUtils.copyProperties(product,productVO);
+        List<ProductVO> productVOS =new ArrayList<>();
+        productVOS.add(productVO);
+        this.loadProduct(productVOS);
+        return productVO;
+    }
 }
 
 

+ 20 - 0
src/main/resources/mapper/ProductMapper.xml

@@ -23,6 +23,26 @@
             <if test="getProductDTO.current!=null and getProductDTO.size!=null">
                 limit ${(getProductDTO.current -1)*getProductDTO.size},${getProductDTO.size}
             </if>
+            <if test="getProductDTO.ifShow!=null">
+                and p.if_show =#{getProductDTO.ifShow}
+            </if>
+            <if test="getProductDTO.ifShow!=null">
+                and p.if_show =#{getProductDTO.ifShow}
+            </if>
+
+            <if test="getProductDTO.productCategoryIds!=null and getProductDTO.productCategoryIds.size()>0">
+                and apc.product_category_id in
+                <foreach collection="getProductDTO.productCategoryIds" item="item" open="(" close=")" separator=",">
+                    #{item}
+                </foreach>
+            </if>
+            <if test="getProductDTO.sourceFrom!=null and getProductDTO.sourceFrom!=''">
+                and p.source_from like CONCAT('%',#{getProductDTO.sourceFrom},'%')
+            </if>
+            <if test="getProductDTO.bestSellingBrand!=null and getProductDTO.bestSellingBrand!=''">
+                and p.best_selling_brand like CONCAT('%',#{getProductDTO.bestSellingBrand},'%')
+            </if>
+
         </where>
 
     </select>