增加‘商品类别’的筛选功能

This commit is contained in:
季圣华
2019-06-23 23:47:40 +08:00
parent 83be4dca33
commit a9874a4928
9 changed files with 88 additions and 69 deletions

View File

@@ -34,11 +34,10 @@ public class MaterialComponent implements ICommonQuery {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String model = StringUtil.getInfo(search, "model");
Long categoryId = Long.parseLong(StringUtil.getInfo(search, "categoryId"));
String categoryIds = StringUtil.getInfo(search, "categoryIds");
String mpList = StringUtil.getInfo(search, "mpList");
String order = QueryUtils.order(map);
return materialService.select(name, model,categoryId,categoryIds,mpList, QueryUtils.offset(map), QueryUtils.rows(map));
return materialService.select(name, model,categoryIds,mpList, QueryUtils.offset(map), QueryUtils.rows(map));
}
@Override
@@ -46,10 +45,9 @@ public class MaterialComponent implements ICommonQuery {
String search = map.get(Constants.SEARCH);
String name = StringUtil.getInfo(search, "name");
String model = StringUtil.getInfo(search, "model");
Long categoryId = Long.parseLong(StringUtil.getInfo(search, "categoryId"));
String categoryIds = StringUtil.getInfo(search, "categoryIds");
String mpList = StringUtil.getInfo(search, "mpList");
return materialService.countMaterial(name, model,categoryId,categoryIds,mpList);
return materialService.countMaterial(name, model,categoryIds,mpList);
}
@Override

View File

@@ -70,13 +70,13 @@ public class MaterialService {
return list;
}
public List<MaterialVo4Unit> select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows)
public List<MaterialVo4Unit> select(String name, String model, String categoryIds,String mpList, int offset, int rows)
throws Exception{
String[] mpArr = mpList.split(",");
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
List<MaterialVo4Unit> list =null;
try{
list= materialMapperEx.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows);
list= materialMapperEx.selectByConditionMaterial(name, model,categoryIds,mpList, offset, rows);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
@@ -117,10 +117,10 @@ public class MaterialService {
return resList;
}
public Long countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList)throws Exception {
public Long countMaterial(String name, String model, String categoryIds,String mpList)throws Exception {
Long result =null;
try{
result= materialMapperEx.countsByMaterial(name, model,categoryId,categoryIds,mpList);
result= materialMapperEx.countsByMaterial(name, model,categoryIds,mpList);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
@@ -320,11 +320,11 @@ public class MaterialService {
return list;
}
public List<MaterialVo4Unit> findByAll(String name, String model, Long categoryId, String categoryIds)throws Exception {
public List<MaterialVo4Unit> findByAll(String name, String model, String categoryIds)throws Exception {
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
List<MaterialVo4Unit> list =null;
try{
list= materialMapperEx.findByAll(name, model, categoryId, categoryIds);
list= materialMapperEx.findByAll(name, model, categoryIds);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);

View File

@@ -22,6 +22,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -68,12 +69,9 @@ public class MaterialCategoryService {
}
public List<MaterialCategory> getAllList(Long parentId)throws Exception {
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
example.setOrderByClause("id");
List<MaterialCategory> list=null;
try{
list=materialCategoryMapper.selectByExample(example);
list = getMCList(parentId);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
@@ -83,6 +81,25 @@ public class MaterialCategoryService {
return list;
}
public List<MaterialCategory> getMCList(Long parentId)throws Exception {
List<MaterialCategory> res= new ArrayList<MaterialCategory>();
List<MaterialCategory> list=null;
MaterialCategoryExample example = new MaterialCategoryExample();
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
example.setOrderByClause("id");
list=materialCategoryMapper.selectByExample(example);
if(list!=null && list.size()>0) {
res.addAll(list);
for(MaterialCategory mc : list) {
List<MaterialCategory> mcList = getMCList(mc.getId());
if(mcList!=null && mcList.size()>0) {
res.addAll(mcList);
}
}
}
return res;
}
public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) throws Exception{
List<MaterialCategory> list=null;
try{