Преглед на файлове

Merge remote-tracking branch 'origin/master'

41235 преди 1 година
родител
ревизия
de06187994

+ 40 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/open/OpenProductController.java

@@ -0,0 +1,40 @@
+package com.fjhx.xmhjc.controller.open;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.fjhx.xmhjc.entity.about.vo.AboutUsHonorVo;
+import com.fjhx.xmhjc.entity.product.dto.ProductInfoSelectDto;
+import com.fjhx.xmhjc.entity.product.vo.ProductCategoryVo;
+import com.fjhx.xmhjc.entity.product.vo.ProductInfoVo;
+import com.fjhx.xmhjc.service.product.ProductCategoryService;
+import com.fjhx.xmhjc.service.product.ProductInfoService;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping("/open/product")
+public class OpenProductController {
+    @Resource
+    private ProductCategoryService productCategoryService;
+    @Resource
+    private ProductInfoService productInfoService;
+
+    @PostMapping("/categoryList")
+    public List<ProductCategoryVo> categoryList() {
+        List<ProductCategoryVo> list = productCategoryService.listByOpen();
+        return list;
+    }
+
+    @PostMapping("/info/{categoryId}")
+    public Page<ProductInfoVo> productInfoList(@PathVariable Long categoryId, @RequestBody ProductInfoSelectDto dto) {
+        Page<ProductInfoVo> list = productInfoService.pageByOpen(categoryId, dto);
+        return list;
+    }
+
+    @PostMapping("/info/detail/{id}")
+    public ProductInfoVo productInfoList(@PathVariable Long id) {
+        ProductInfoVo detail = productInfoService.detail(id);
+        return detail;
+    }
+}

+ 14 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/controller/product/ProductCategoryController.java

@@ -1,5 +1,10 @@
 package com.fjhx.xmhjc.controller.product;
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.fjhx.xmhjc.entity.product.dto.ProductInfoSelectDto;
+import com.fjhx.xmhjc.entity.product.po.ProductInfo;
+import com.fjhx.xmhjc.entity.product.vo.ProductInfoVo;
+import com.fjhx.xmhjc.service.product.ProductInfoService;
 import org.springframework.web.bind.annotation.*;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.xmhjc.entity.product.vo.ProductCategoryVo;
@@ -9,6 +14,7 @@ import com.ruoyi.common.core.domain.BaseSelectDto;
 import com.fjhx.xmhjc.service.product.ProductCategoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import javax.annotation.Resource;
 import java.util.List;
 
 /**
@@ -25,6 +31,8 @@ public class ProductCategoryController {
 
     @Autowired
     private ProductCategoryService productCategoryService;
+    @Resource
+    private ProductInfoService productInfoService;
 
     /**
      * 产品类目表列表
@@ -71,6 +79,12 @@ public class ProductCategoryController {
      */
     @PostMapping("/delete")
     public void delete(@RequestBody BaseSelectDto dto) {
+        ProductInfoSelectDto productInfoSelectDto = new ProductInfoSelectDto();
+        productInfoSelectDto.setCategoryId(dto.getId());
+        List<ProductInfoVo> productInfoVos = productInfoService.getList(productInfoSelectDto);
+        if(CollectionUtil.isNotEmpty(productInfoVos)){
+            throw new RuntimeException("该类目下有产品,不能删除");
+        }
         productCategoryService.delete(dto.getId());
     }
 

+ 1 - 1
hx-xmhjc/src/main/java/com/fjhx/xmhjc/entity/product/dto/ProductCategorySelectDto.java

@@ -13,5 +13,5 @@ import lombok.Setter;
 @Getter
 @Setter
 public class ProductCategorySelectDto extends BaseSelectDto {
-
+    private String status;
 }

+ 2 - 1
hx-xmhjc/src/main/java/com/fjhx/xmhjc/entity/product/dto/ProductInfoSelectDto.java

@@ -13,5 +13,6 @@ import lombok.Setter;
 @Getter
 @Setter
 public class ProductInfoSelectDto extends BaseSelectDto {
-
+    private Long categoryId;
+    private String status;
 }

+ 1 - 1
hx-xmhjc/src/main/java/com/fjhx/xmhjc/entity/product/po/ProductInfo.java

@@ -22,7 +22,7 @@ public class ProductInfo extends BasePo {
     /**
      * 类目id
      */
-    private Integer categoryId;
+    private Long categoryId;
 
     /**
      * 标题

+ 1 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/ProductCategoryService.java

@@ -49,4 +49,5 @@ public interface ProductCategoryService extends BaseService<ProductCategory> {
      */
     void delete(Long id);
 
+    List<ProductCategoryVo> listByOpen();
 }

+ 1 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/ProductInfoService.java

@@ -49,4 +49,5 @@ public interface ProductInfoService extends BaseService<ProductInfo> {
      */
     void delete(Long id);
 
+    Page<ProductInfoVo> pageByOpen(Long categoryId, ProductInfoSelectDto dto);
 }

+ 13 - 0
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/impl/ProductCategoryServiceImpl.java

@@ -1,5 +1,6 @@
 package com.fjhx.xmhjc.service.product.impl;
 
+import cn.hutool.core.util.StrUtil;
 import com.fjhx.xmhjc.entity.product.po.ProductCategory;
 import com.fjhx.xmhjc.mapper.product.ProductCategoryMapper;
 import com.fjhx.xmhjc.service.product.ProductCategoryService;
@@ -38,6 +39,9 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
     public Page<ProductCategoryVo> getPage(ProductCategorySelectDto dto) {
         IWrapper<ProductCategory> wrapper = getWrapper();
         wrapper.keyword(dto, new SqlField("pc", ProductCategory::getName));
+        if(StrUtil.isNotBlank(dto.getStatus())){
+            wrapper.eq("pc", ProductCategory::getStatus, dto.getStatus());
+        }
         wrapper.orderByAsc("pc", ProductCategory::getSort);
         Page<ProductCategoryVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
         return page;
@@ -65,4 +69,13 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
         this.removeById(id);
     }
 
+
+    @Override
+    public List<ProductCategoryVo> listByOpen() {
+        IWrapper<ProductCategory> wrapper = getWrapper();
+        wrapper.orderByDesc("pc", ProductCategory::getId);
+        wrapper.eq("pc", ProductCategory::getStatus, "1");
+        List<ProductCategoryVo> list = this.baseMapper.getList(wrapper);
+        return list;
+    }
 }

+ 30 - 1
hx-xmhjc/src/main/java/com/fjhx/xmhjc/service/product/impl/ProductInfoServiceImpl.java

@@ -1,12 +1,19 @@
 package com.fjhx.xmhjc.service.product.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.fjhx.file.utils.ObsFileUtil;
+import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
+import com.fjhx.tenant.entity.dict.vo.DictTenantDataVo;
+import com.fjhx.tenant.service.dict.DictTenantDataService;
+import com.fjhx.tenant.utils.DictUtils;
 import com.fjhx.xmhjc.entity.product.po.ProductInfo;
 import com.fjhx.xmhjc.mapper.product.ProductInfoMapper;
 import com.fjhx.xmhjc.service.product.ProductInfoService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.common.core.domain.entity.SysDictData;
 import com.ruoyi.common.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fjhx.xmhjc.entity.product.vo.ProductInfoVo;
@@ -17,6 +24,7 @@ import cn.hutool.core.bean.BeanUtil;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -32,11 +40,14 @@ import java.util.stream.Collectors;
  */
 @Service
 public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, ProductInfo> implements ProductInfoService {
+    @Autowired
+    private DictTenantDataService dictTenantDataService;
 
     @Override
     public List<ProductInfoVo> getList(ProductInfoSelectDto dto) {
         IWrapper<ProductInfo> wrapper = getWrapper();
         wrapper.orderByDesc("pi", ProductInfo::getId);
+        wrapper.eq(ObjectUtil.isNotEmpty(dto.getCategoryId()),"category_id", dto.getCategoryId());
         List<ProductInfoVo> list = this.baseMapper.getList(wrapper);
         return list;
     }
@@ -44,8 +55,17 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
     @Override
     public Page<ProductInfoVo> getPage(ProductInfoSelectDto dto) {
         IWrapper<ProductInfo> wrapper = getWrapper();
-        wrapper.orderByDesc("pi", ProductInfo::getId);
+        wrapper.orderByAsc("pi", ProductInfo::getSort);
         Page<ProductInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        List<ProductInfoVo> records = page.getRecords();
+//        DictTenantDataSelectDto dictTenantDataSelectDto = new DictTenantDataSelectDto();
+//        dictTenantDataSelectDto.setDictCode("product_content_type");
+//        List<DictTenantDataVo> dictList = dictTenantDataService.getList(dictTenantDataSelectDto);
+        records.forEach(item -> {
+            if(StringUtils.isNotBlank(item.getSpec())){
+                List<String> list = Arrays.asList(item.getSpec().split(","));
+            }
+        });
         return page;
     }
 
@@ -92,4 +112,13 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
         this.removeById(id);
     }
 
+    @Override
+    public Page<ProductInfoVo> pageByOpen(Long categoryId, ProductInfoSelectDto dto) {
+        IWrapper<ProductInfo> wrapper = getWrapper();
+        wrapper.orderByAsc("pi", ProductInfo::getSort);
+        wrapper.eq("pi", ProductInfo::getStatus, "1");
+        wrapper.eq("pi", ProductInfo::getCategoryId, categoryId);
+        Page<ProductInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
+        return page;
+    }
 }