|
@@ -1,10 +1,14 @@
|
|
|
package com.fjhx.xmhjc.service.product.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.fjhx.xmhjc.entity.product.po.ProductCategory;
|
|
|
+import com.fjhx.xmhjc.entity.product.po.ProductSubCategory;
|
|
|
+import com.fjhx.xmhjc.entity.product.vo.ProductSubCategoryVo;
|
|
|
import com.fjhx.xmhjc.mapper.product.ProductCategoryMapper;
|
|
|
import com.fjhx.xmhjc.service.product.ProductCategoryService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.fjhx.xmhjc.service.product.ProductSubCategoryService;
|
|
|
import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -13,7 +17,9 @@ import com.fjhx.xmhjc.entity.product.dto.ProductCategorySelectDto;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
import com.fjhx.xmhjc.entity.product.dto.ProductCategoryDto;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -26,6 +32,8 @@ import java.util.List;
|
|
|
*/
|
|
|
@Service
|
|
|
public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMapper, ProductCategory> implements ProductCategoryService {
|
|
|
+ @Resource
|
|
|
+ private ProductSubCategoryService productSubCategoryService;
|
|
|
|
|
|
@Override
|
|
|
public List<ProductCategoryVo> getList(ProductCategorySelectDto dto) {
|
|
@@ -51,17 +59,25 @@ public class ProductCategoryServiceImpl extends ServiceImpl<ProductCategoryMappe
|
|
|
public ProductCategoryVo detail(Long id) {
|
|
|
ProductCategory ProductCategory = this.getById(id);
|
|
|
ProductCategoryVo result = BeanUtil.toBean(ProductCategory, ProductCategoryVo.class);
|
|
|
+ List<ProductSubCategory> subCategoryList = productSubCategoryService.listByParentId(id);
|
|
|
+ List<ProductSubCategoryVo> subCategoryVos = BeanUtil.copyToList(subCategoryList, ProductSubCategoryVo.class);
|
|
|
+ result.setSubCategoryList(subCategoryVos);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void add(ProductCategoryDto productCategoryDto) {
|
|
|
this.save(productCategoryDto);
|
|
|
+ productSubCategoryService.dealSubCategory(productCategoryDto.getId(), productCategoryDto.getSubCategoryList());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void edit(ProductCategoryDto productCategoryDto) {
|
|
|
this.updateById(productCategoryDto);
|
|
|
+ productSubCategoryService.dealSubCategory(productCategoryDto.getId(), productCategoryDto.getSubCategoryList());
|
|
|
}
|
|
|
|
|
|
@Override
|