Commit 318b7dd9 by fudahua

素材列表fix

parent 676e1a6c
...@@ -26,6 +26,8 @@ public interface TabHaobanMaterialMapper { ...@@ -26,6 +26,8 @@ public interface TabHaobanMaterialMapper {
Page<TabHaobanMaterial> listMaterial(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("keyword")String keyword, @Param("categoryId")String categoryId, @Param("materialType")Integer materialType); Page<TabHaobanMaterial> listMaterial(@Param("wxEnterpriseId")String wxEnterpriseId, @Param("keyword")String keyword, @Param("categoryId")String categoryId, @Param("materialType")Integer materialType);
Page<TabHaobanMaterial> listMaterialByCategoryIds(@Param("wxEnterpriseId") String wxEnterpriseId, @Param("keyword") String keyword, @Param("categoryIds") List<String> categoryIds, @Param("materialType") Integer materialType);
TabHaobanMaterial selectByfromMaterialId(@Param("fromMaterialId") String fromMaterialId, @Param("wxEnterpriseId") String wxEnterpriseId); TabHaobanMaterial selectByfromMaterialId(@Param("fromMaterialId") String fromMaterialId, @Param("wxEnterpriseId") String wxEnterpriseId);
List<TabHaobanMaterial> listByfromMaterialId(@Param("fromMaterialId") String fromMaterialId); List<TabHaobanMaterial> listByfromMaterialId(@Param("fromMaterialId") String fromMaterialId);
......
...@@ -19,6 +19,18 @@ public interface MaterialService { ...@@ -19,6 +19,18 @@ public interface MaterialService {
com.github.pagehelper.Page listMaterial(String wxEnterpriseId, String keyword, String categoryId, com.github.pagehelper.Page listMaterial(String wxEnterpriseId, String keyword, String categoryId,
Integer materialType); Integer materialType);
/**
* 查询素材
*
* @param wxEnterpriseId
* @param keyword
* @param categoryId
* @param materialType
* @return
*/
com.github.pagehelper.Page listMaterial(String wxEnterpriseId, String keyword, List<String> categoryId,
Integer materialType);
MaterialDTO getMaterialByFromMaterialId(String fromMaterialId, String wxEnterpriseId); MaterialDTO getMaterialByFromMaterialId(String fromMaterialId, String wxEnterpriseId);
/** /**
......
...@@ -65,6 +65,11 @@ public class MaterialServiceImpl implements MaterialService { ...@@ -65,6 +65,11 @@ public class MaterialServiceImpl implements MaterialService {
} }
@Override @Override
public Page<TabHaobanMaterial> listMaterial(String wxEnterpriseId, String keyword, List<String> categoryIds, Integer materialType) {
return mapper.listMaterialByCategoryIds(wxEnterpriseId, keyword, categoryIds, materialType);
}
@Override
public MaterialDTO getMaterialByFromMaterialId(String fromMaterialId, String wxEnterpriseId) { public MaterialDTO getMaterialByFromMaterialId(String fromMaterialId, String wxEnterpriseId) {
TabHaobanMaterial tabHaobanMaterial = mapper.selectByfromMaterialId(fromMaterialId, wxEnterpriseId); TabHaobanMaterial tabHaobanMaterial = mapper.selectByfromMaterialId(fromMaterialId, wxEnterpriseId);
return EntityUtil.changeEntityByJSON(MaterialDTO.class, tabHaobanMaterial); return EntityUtil.changeEntityByJSON(MaterialDTO.class, tabHaobanMaterial);
......
...@@ -2,10 +2,7 @@ package com.gic.haoban.manage.service.service.out.impl; ...@@ -2,10 +2,7 @@ package com.gic.haoban.manage.service.service.out.impl;
import java.io.InputStream; import java.io.InputStream;
import java.net.URL; import java.net.URL;
import java.util.Arrays; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.gic.haoban.base.api.common.ServiceResponse; import com.gic.haoban.base.api.common.ServiceResponse;
...@@ -266,11 +263,28 @@ public class MaterialApiServiceImpl implements MaterialApiService { ...@@ -266,11 +263,28 @@ public class MaterialApiServiceImpl implements MaterialApiService {
return old.getMediaId(); return old.getMediaId();
} }
private List<String> listSubCategoryIdsByParentId(String categoryId) {
List<String> categoryIds = new ArrayList<>();
categoryIds.add(categoryId);
if (StringUtils.isBlank(categoryId)) {
return categoryIds;
}
List<MaterialCategoryDTO> categoryDTOList = materialCategoryService.listByParentCategory(categoryId);
if (CollectionUtils.isEmpty(categoryDTOList)) {
return categoryIds;
}
for (MaterialCategoryDTO categoryDTO : categoryDTOList) {
categoryIds.addAll(this.listSubCategoryIdsByParentId(categoryDTO.getCategoryId()));
}
return categoryIds;
}
@Override @Override
public Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId, public Page<MaterialDTO> listMaterial(String wxEnterpriseId, String keyword, String categoryId,
Integer materialType,BasePageInfo pageInfo) { Integer materialType,BasePageInfo pageInfo) {
PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize()); PageHelper.startPage(pageInfo.getPageNum(), pageInfo.getPageSize());
com.github.pagehelper.Page<TabHaobanMaterial> page = materialService.listMaterial(wxEnterpriseId,keyword,categoryId,materialType); List<String> categoryIds = this.listSubCategoryIdsByParentId(categoryId);
com.github.pagehelper.Page<TabHaobanMaterial> page = materialService.listMaterial(wxEnterpriseId, keyword, categoryIds, materialType);
List<TabHaobanMaterial> result = page.getResult(); List<TabHaobanMaterial> result = page.getResult();
List<TabMiniprogramSetting> settings = miniprogramSettingService.listMiniprogram(wxEnterpriseId); List<TabMiniprogramSetting> settings = miniprogramSettingService.listMiniprogram(wxEnterpriseId);
if (CollectionUtils.isNotEmpty(result) && CollectionUtils.isNotEmpty(settings)) { if (CollectionUtils.isNotEmpty(result) && CollectionUtils.isNotEmpty(settings)) {
......
...@@ -279,6 +279,28 @@ ...@@ -279,6 +279,28 @@
order by update_time desc order by update_time desc
</select> </select>
<select id="listMaterialByCategoryIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from tab_haoban_material
where status_flag = 1
and wx_enterprise_id = #{wxEnterpriseId}
<if test="keyword != null and keyword != ''">
and material_title like CONCAT('%',#{keyword},'%')
</if>
<if test="materialType != null">
and material_type = #{materialType}
</if>
<if test="categoryIds != null and categoryIds.size>0">
and category_id in
<foreach collection="categoryIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by update_time desc
</select>
<select id="selectByfromMaterialId" resultMap="BaseResultMap" parameterType="java.lang.String"> <select id="selectByfromMaterialId" resultMap="BaseResultMap" parameterType="java.lang.String">
select select
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment