parent
ee8f860b13
commit
ebbf0ba08d
|
|
@ -4,6 +4,7 @@ import cn.ysk.cashier.utils.FastJsonUtils;
|
|||
import cn.ysk.cashier.utils.SpringContextHolder;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
|
|
@ -61,10 +62,17 @@ public class AppApiMethodAspect {
|
|||
FastJsonUtils.toJSONString(result)
|
||||
);
|
||||
} catch (Throwable e) {
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e.getMessage());
|
||||
if(StringUtils.isBlank(e.getMessage())){
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e);
|
||||
}else{
|
||||
log.error("\n>>>>>>{} {}\n>>>>>>{}\n>>>>>>Request: {}\n>>>>>>Exception: {}"
|
||||
, req.getMethod(), req.getRequestURL(), req.getRemoteAddr(),
|
||||
FastJsonUtils.toJSONString(params),
|
||||
e.getMessage());
|
||||
}
|
||||
ResponseEntity<String> body = ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage());
|
||||
return body;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import java.io.IOException;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @website https://eladmin.vip
|
||||
|
|
@ -58,11 +59,8 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
|||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(TbShopCategoryQueryCriteria criteria, Pageable pageable){
|
||||
|
||||
// Page<TbShopCategory> page = tbShopCategoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), Sort.by("sort"));
|
||||
Page<TbShopCategory> page = tbShopCategoryRepository.findAllBy(criteria.getShopId(), pageable);
|
||||
// tbShopCategoryRepository.findAllBy(criteria.getShopId(),pageable);
|
||||
|
||||
List<Integer> treeId = new ArrayList<>();
|
||||
for (TbShopCategory category : page.getContent()) {
|
||||
|
|
@ -88,8 +86,11 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
|||
BeanUtils.copyProperties(category, tbShopCategoryDto);
|
||||
dto.add(tbShopCategoryDto);
|
||||
}
|
||||
List<TbShopCategoryDto> result = dto.stream()
|
||||
.filter(d -> d.getTree()==null || d.getId().equals(d.getTree()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return PageUtil.toPage(dto, dto.size());
|
||||
return PageUtil.toPage(result, page.getTotalElements()-children.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -111,7 +112,7 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
|||
resources.setCreatedAt(Instant.now().toEpochMilli());
|
||||
resources.setUpdatedAt(Instant.now().toEpochMilli());
|
||||
TbShopCategory byName = tbShopCategoryRepository.findByName(resources.getName(), resources.getShopId());
|
||||
if (byName.getName() != null){
|
||||
if (byName != null){
|
||||
throw new BadRequestException("分类名称重复");
|
||||
}
|
||||
if (resources.getPid() == null || "".equals(resources.getPid())){
|
||||
|
|
@ -119,7 +120,6 @@ public class TbShopCategoryServiceImpl implements TbShopCategoryService {
|
|||
}else {
|
||||
resources.setTree(Integer.valueOf(resources.getPid().trim()));
|
||||
}
|
||||
ValidationUtil.isNull(resources.getId(),"TbShopCategory","id",resources.getId());
|
||||
return tbShopCategoryRepository.save(resources);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue