|
@@ -1,11 +1,14 @@
|
|
|
package com.backendsys.modules.material.service.impl;
|
|
|
|
|
|
+import com.backendsys.modules.material.dao.MaterialDao;
|
|
|
import com.backendsys.modules.material.dao.MaterialTagDao;
|
|
|
+import com.backendsys.modules.material.entity.Material;
|
|
|
import com.backendsys.modules.material.entity.MaterialTag;
|
|
|
import com.backendsys.modules.material.service.MaterialTagService;
|
|
|
import com.backendsys.utils.response.PageEntity;
|
|
|
import com.backendsys.utils.response.PageInfoResult;
|
|
|
import com.backendsys.utils.v2.PageUtils;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -14,6 +17,9 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class MaterialTagImpl implements MaterialTagService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MaterialDao materialDao;
|
|
|
+
|
|
|
@Autowired
|
|
|
private MaterialTagDao materialTagDao;
|
|
|
|
|
@@ -34,13 +40,18 @@ public class MaterialTagImpl implements MaterialTagService {
|
|
|
public List<MaterialTag> selectMaterialTagPopover(MaterialTag materialTag) {
|
|
|
List<MaterialTag> list = materialTagDao.selectMaterialTagList(materialTag);
|
|
|
|
|
|
- // 筛选出列表中,所有 material_count 的总和
|
|
|
- Integer all_material_count = list.stream().mapToInt(MaterialTag::getMaterial_count).sum();
|
|
|
+ // [DB] 查询全部素材的数量 (该分类下的)
|
|
|
+ LambdaQueryWrapper<Material> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(Material::getCategory_id, materialTag.getCategory_id());
|
|
|
+ Long count = materialDao.selectCount(wrapper);
|
|
|
+
|
|
|
+// // 筛选出列表中,所有 material_count 的总和
|
|
|
+// Long count = list.stream().mapToLong(MaterialTag::getMaterial_count).sum();
|
|
|
|
|
|
MaterialTag all = new MaterialTag();
|
|
|
all.setTag_name("全部");
|
|
|
all.setTag_id(null);
|
|
|
- all.setMaterial_count(all_material_count);
|
|
|
+ all.setMaterial_count(count);
|
|
|
list.add(0, all);
|
|
|
|
|
|
return list;
|