|
@@ -9,10 +9,7 @@ import com.example.xiaoshiweixinback.business.common.base.Records;
|
|
|
import com.example.xiaoshiweixinback.business.common.base.SystemFile;
|
|
|
import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
import com.example.xiaoshiweixinback.business.utils.LoginUtils;
|
|
|
-import com.example.xiaoshiweixinback.domain.AssoCategoryFile;
|
|
|
-import com.example.xiaoshiweixinback.domain.AssoProductFile;
|
|
|
-import com.example.xiaoshiweixinback.domain.Person;
|
|
|
-import com.example.xiaoshiweixinback.domain.ProductCategory;
|
|
|
+import com.example.xiaoshiweixinback.domain.*;
|
|
|
import com.example.xiaoshiweixinback.entity.dto.ProductCategoryDTO;
|
|
|
import com.example.xiaoshiweixinback.entity.vo.PersonnelVO;
|
|
|
import com.example.xiaoshiweixinback.entity.vo.ProductCategoryVO;
|
|
@@ -21,6 +18,7 @@ import com.example.xiaoshiweixinback.mapper.ProductCategoryMapper;
|
|
|
import com.example.xiaoshiweixinback.service.common.FileManagerService;
|
|
|
import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
@@ -50,15 +48,21 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
Records records = new Records();
|
|
|
Long size = productCategoryDTO.getSize();
|
|
|
Long current = productCategoryDTO.getCurrent();
|
|
|
+ String name = productCategoryDTO.getName();
|
|
|
+ Integer parentId = productCategoryDTO.getParentId();
|
|
|
records.setCurrent(current);
|
|
|
records.setSize(size);
|
|
|
- String name = productCategoryDTO.getName();
|
|
|
+
|
|
|
|
|
|
LambdaQueryWrapper<ProductCategory> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
if (name != null && !name.trim().equals("")) {
|
|
|
queryWrapper.like(ProductCategory::getName, name);
|
|
|
}
|
|
|
-
|
|
|
+ if (parentId == null) {
|
|
|
+ queryWrapper.isNull(ProductCategory::getParentId);
|
|
|
+ } else {
|
|
|
+ queryWrapper.eq(ProductCategory::getParentId, parentId);
|
|
|
+ }
|
|
|
List<ProductCategory> productCategoryList = new ArrayList<>();
|
|
|
if (size != null && current != null) {
|
|
|
IPage<ProductCategory> productCategoryIPage = this.page(new Page<>(current, size), queryWrapper);
|
|
@@ -68,19 +72,20 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
productCategoryList = this.list(queryWrapper);
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- records.setData(productCategoryList);
|
|
|
+ List<ProductCategoryVO> productCategoryVOS = this.loadProductCategory(productCategoryList);
|
|
|
+ records.setData(productCategoryVOS);
|
|
|
return records;
|
|
|
}
|
|
|
|
|
|
- private void loadProductCategory(List<ProductCategoryVO> productCategoryVOS) {
|
|
|
+ private List<ProductCategoryVO> loadProductCategory(List<ProductCategory> productCategorys) {
|
|
|
+ List<ProductCategoryVO> productCategoryVOS = new ArrayList<>();
|
|
|
List<AssoCategoryFile> assoCategoryFiles = new ArrayList<>();
|
|
|
List<String> createIds = new ArrayList<>();
|
|
|
List<String> guids = new ArrayList<>();
|
|
|
- if (productCategoryVOS == null || productCategoryVOS.size() == 0) {
|
|
|
- return;
|
|
|
+ if (productCategorys == null || productCategorys.size() == 0) {
|
|
|
+ return productCategoryVOS;
|
|
|
}
|
|
|
- List<Integer> ids = productCategoryVOS.stream().map(ProductCategoryVO::getId).collect(Collectors.toList());
|
|
|
+ List<Integer> ids = productCategorys.stream().map(ProductCategory::getId).collect(Collectors.toList());
|
|
|
List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
List<Person> personList = new ArrayList<>();
|
|
|
if (ids.size() != 0) {
|
|
@@ -112,7 +117,9 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
}
|
|
|
|
|
|
//装载登录人信息,装载
|
|
|
- for (ProductCategoryVO productCategoryVO : productCategoryVOS) {
|
|
|
+ for (ProductCategory productCategory : productCategorys) {
|
|
|
+ ProductCategoryVO productCategoryVO = new ProductCategoryVO();
|
|
|
+ BeanUtils.copyProperties(productCategory, productCategoryVO);
|
|
|
Person personnel = personList.stream().filter(item -> item.getUuid().toString().equals(productCategoryVO.getCreateId())).findFirst().orElse(null);
|
|
|
if (personnel != null) {
|
|
|
productCategoryVO.setCreateName(personnel.getName());
|
|
@@ -128,7 +135,9 @@ public class ProductCategoryService extends ServiceImpl<ProductCategoryMapper, P
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ productCategoryVOS.add(productCategoryVO);
|
|
|
}
|
|
|
+ return productCategoryVOS;
|
|
|
}
|
|
|
|
|
|
}
|