产品类别

pull/451/head
starrysky 2019-08-14 18:55:17 +08:00
parent ff47bd95b5
commit 7952a76969
4 changed files with 31 additions and 7 deletions

View File

@ -49,8 +49,8 @@ public class MaterialCategoryController {
}
@Log("查询物料类别")
@GetMapping(value = "/materialCategory")
public ResponseEntity getDicts(MaterialCategoryDTO resources, Pageable pageable){
@GetMapping(value = "/queryMaterialCategoryPage")
public ResponseEntity queryMaterialCategoryPage(MaterialCategoryDTO resources, Pageable pageable){
return new ResponseEntity(materialCategoryService.queryAll(resources,pageable),HttpStatus.OK);
}
}

View File

@ -28,7 +28,7 @@ public class MaterialInfoController {
@Log("分页查询物料资料")
@ApiOperation(value = "分页查询物料资料")
@GetMapping(value = "/materialInfo")
public ResponseEntity getBdMaterialInfos(MaterialInfoQueryCriteria criteria, Pageable pageable){
public ResponseEntity queryMaterialInfoPage(MaterialInfoQueryCriteria criteria, Pageable pageable){
return new ResponseEntity(materialInfoService.queryAll(criteria,pageable),HttpStatus.OK);
}
@ -64,7 +64,7 @@ public class MaterialInfoController {
@Log("查看物料资料详情")
@GetMapping(value = "/materialInfo/{id}")
public ResponseEntity getMessureUnit(@PathVariable Long id){
public ResponseEntity getMaterialInfo(@PathVariable Long id){
return new ResponseEntity(materialInfoService.findById(id), HttpStatus.OK);
}
}

View File

@ -1,6 +1,7 @@
package me.zhengjie.modules.wms.bd.service.impl;
import me.zhengjie.modules.wms.bd.domain.IncomeCategory;
import me.zhengjie.modules.wms.bd.domain.ProductCategory;
import me.zhengjie.modules.wms.bd.repository.IncomeCategoryRepository;
import me.zhengjie.modules.wms.bd.service.IncomeCategoryService;
import me.zhengjie.modules.wms.bd.service.dto.IncomeCategoryDTO;
@ -11,10 +12,18 @@ import me.zhengjie.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
@ -53,7 +62,24 @@ public class IncomeCategoryServiceImpl implements IncomeCategoryService {
@Override
public Object queryAll(IncomeCategoryDTO incomeCategory, Pageable pageable) {
Page<IncomeCategory> page = incomeCategoryRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, incomeCategory, cb), pageable);
Specification<IncomeCategory> specification = new Specification<IncomeCategory>() {
@Override
public Predicate toPredicate(Root<IncomeCategory> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> targetPredicateList = new ArrayList<>();
//状态
Predicate statusPredicate = criteriaBuilder.equal(root.get("status"), 1);
targetPredicateList.add(statusPredicate);
if(CollectionUtils.isEmpty(targetPredicateList)){
return null;
}else{
return criteriaBuilder.and(targetPredicateList.toArray(new Predicate[targetPredicateList.size()]));
}
}
};
Page<IncomeCategory> page = incomeCategoryRepository.findAll(specification, pageable);
return PageUtil.toPage(page.map(incomeCategoryMapper::toDto));
}

View File

@ -1,14 +1,12 @@
package me.zhengjie.modules.wms.bd.service.impl;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.wms.bd.domain.MeasureUnit;
import me.zhengjie.modules.wms.bd.domain.ProductCategory;
import me.zhengjie.modules.wms.bd.repository.ProductCategoryRepository;
import me.zhengjie.modules.wms.bd.service.ProductCategoryService;
import me.zhengjie.modules.wms.bd.service.dto.ProductCategoryDTO;
import me.zhengjie.modules.wms.bd.service.mapper.ProductCategoryMapper;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
import me.zhengjie.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;