订单分类 注解
This commit is contained in:
parent
cdf85e3940
commit
2c96f2835a
|
|
@ -40,5 +40,8 @@ public class TbShopCategoryQueryCriteria{
|
||||||
|
|
||||||
|
|
||||||
private String tree;
|
private String tree;
|
||||||
|
private String sort;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -15,33 +15,31 @@
|
||||||
*/
|
*/
|
||||||
package cn.ysk.cashier.service.impl.productimpl;
|
package cn.ysk.cashier.service.impl.productimpl;
|
||||||
|
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
|
||||||
import cn.ysk.cashier.pojo.product.TbShopCategory;
|
|
||||||
import cn.ysk.cashier.utils.ValidationUtil;
|
|
||||||
import cn.ysk.cashier.utils.FileUtil;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import cn.ysk.cashier.repository.product.TbShopCategoryRepository;
|
|
||||||
import cn.ysk.cashier.service.product.TbShopCategoryService;
|
|
||||||
import cn.ysk.cashier.dto.product.TbShopCategoryDto;
|
import cn.ysk.cashier.dto.product.TbShopCategoryDto;
|
||||||
import cn.ysk.cashier.dto.product.TbShopCategoryQueryCriteria;
|
import cn.ysk.cashier.dto.product.TbShopCategoryQueryCriteria;
|
||||||
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.mapper.product.TbShopCategoryMapper;
|
import cn.ysk.cashier.mapper.product.TbShopCategoryMapper;
|
||||||
|
import cn.ysk.cashier.pojo.product.TbShopCategory;
|
||||||
|
import cn.ysk.cashier.repository.product.TbShopCategoryRepository;
|
||||||
|
import cn.ysk.cashier.service.product.TbShopCategoryService;
|
||||||
|
import cn.ysk.cashier.utils.*;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
import cn.ysk.cashier.utils.PageUtil;
|
|
||||||
import cn.ysk.cashier.utils.QueryHelp;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.io.IOException;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -50,6 +48,7 @@ import java.util.stream.Collectors;
|
||||||
* @author lyf
|
* @author lyf
|
||||||
* @date 2024-01-08
|
* @date 2024-01-08
|
||||||
**/
|
**/
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||||
|
|
@ -70,6 +69,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||||
//找到子分类
|
//找到子分类
|
||||||
List<TbShopCategory> children = tbShopCategoryRepository.findChildren(treeId);
|
List<TbShopCategory> children = tbShopCategoryRepository.findChildren(treeId);
|
||||||
if (children.isEmpty()){
|
if (children.isEmpty()){
|
||||||
|
log.info("子类为空,{}", FastJsonUtils.toJSONString(treeId));
|
||||||
return PageUtil.toPage(page.map(tbShopCategoryMapper::toDto));
|
return PageUtil.toPage(page.map(tbShopCategoryMapper::toDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,10 +86,11 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
||||||
BeanUtils.copyProperties(category, tbShopCategoryDto);
|
BeanUtils.copyProperties(category, tbShopCategoryDto);
|
||||||
dto.add(tbShopCategoryDto);
|
dto.add(tbShopCategoryDto);
|
||||||
}
|
}
|
||||||
|
log.info("过滤前,{}", FastJsonUtils.toJSONString(dto));
|
||||||
List<TbShopCategoryDto> result = dto.stream()
|
List<TbShopCategoryDto> result = dto.stream()
|
||||||
.filter(d -> d.getTree()==null || d.getId().equals(d.getTree()))
|
.filter(d -> d.getTree()==null || d.getId().equals(d.getTree()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
log.info("过滤后,{}", FastJsonUtils.toJSONString(result));
|
||||||
return PageUtil.toPage(result, page.getTotalElements()-children.size());
|
return PageUtil.toPage(result, page.getTotalElements()-children.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue