产品类别

pull/451/head
starrysky 2019-08-20 11:06:37 +08:00
parent 5b5e494524
commit b27df38006
7 changed files with 86 additions and 6 deletions

View File

@ -58,9 +58,16 @@ public class MeasureUnitController {
return new ResponseEntity(HttpStatus.OK);
}
@Log("查询计量单位")
@GetMapping(value = "/measureUnit")
public ResponseEntity getMessureUnits(MeasureUnitDTO resources, Pageable pageable){
@Log("分页查询计量单位")
@GetMapping(value = "/queryMeasureUnitPage")
public ResponseEntity queryMeasureUnitPage(MeasureUnitDTO resources, Pageable pageable){
return new ResponseEntity(measureUnitService.queryAll(resources,pageable),HttpStatus.OK);
}
@Log("查询所有计量单位")
@GetMapping(value = "/queryMeasureUnitList")
public ResponseEntity queryMeasureUnitList(MeasureUnitDTO resources){
return new ResponseEntity(measureUnitService.queryAll(resources),HttpStatus.OK);
}
}

View File

@ -48,9 +48,15 @@ public class ProductCategoryController {
return new ResponseEntity(HttpStatus.OK);
}
@Log("查询产品类别")
@GetMapping(value = "/productCategory")
public ResponseEntity getDicts(ProductCategoryDTO resources, Pageable pageable){
@Log("查询产品类别列表")
@GetMapping(value = "/queryProductCategoryList")
public ResponseEntity queryProductCategoryList(ProductCategoryDTO resources, Pageable pageable){
return new ResponseEntity(productCategoryService.queryAll(resources,pageable),HttpStatus.OK);
}
@Log("分页查询产品类别")
@GetMapping(value = "/queryProductCategoryPage")
public ResponseEntity queryProductCategoryPage(ProductCategoryDTO resources, Pageable pageable){
return new ResponseEntity(productCategoryService.queryAll(resources,pageable),HttpStatus.OK);
}
}

View File

@ -13,6 +13,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* @author
* @date 2019-07-27
@ -25,6 +28,19 @@ public class ProductInfoController {
@Autowired
private ProductInfoService productInfoService;
@Log("初始化产品编号")
@ApiOperation(value = "初始化产品编号")
@GetMapping(value = "/initProductInfoCode")
@PreAuthorize("hasAnyRole('ADMIN','BDSUPPLIERINFO_ALL','BDSUPPLIERINFO_SELECT')")
public ResponseEntity initProductInfoCode(){
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");//设置日期格式
String supplierCode = "CP"+ LocalDateTime.now().format(fmt);
return new ResponseEntity(supplierCode,HttpStatus.OK);
}
@Log("分页查询产品资料")
@ApiOperation(value = "分页查询产品资料")
@GetMapping(value = "/productInfo")

View File

@ -19,4 +19,6 @@ public interface MeasureUnitService {
void delete(Long id);
Object queryAll(MeasureUnitDTO measureUnit, Pageable pageable);
Object queryAll(MeasureUnitDTO measureUnit);
}

View File

@ -17,4 +17,6 @@ public interface ProductCategoryService {
void delete(Long id);
Object queryAll(ProductCategoryDTO productCategory, Pageable pageable);
Object queryAll(ProductCategoryDTO productCategory);
}

View File

@ -134,4 +134,28 @@ public class MeasureUnitServiceImpl implements MeasureUnitService {
return PageUtil.toPage(page.map(measureUnitMapper::toDto));
}
@Override
public Object queryAll(MeasureUnitDTO measureUnit) {
Specification<MeasureUnit> specification = new Specification<MeasureUnit>() {
@Override
public Predicate toPredicate(Root<MeasureUnit> 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()]));
}
}
};
List<MeasureUnit> measureUnitList = measureUnitRepository.findAll(specification);
return measureUnitMapper.toDto(measureUnitList);
}
}

View File

@ -103,4 +103,27 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
return PageUtil.toPage(page.map(productCategoryMapper::toDto));
}
@Override
public Object queryAll(ProductCategoryDTO productCategory) {
Specification<ProductCategory> specification = new Specification<ProductCategory>() {
@Override
public Predicate toPredicate(Root<ProductCategory> 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()]));
}
}
};
List<ProductCategory> productCategoryList = productCategoryRepository.findAll(specification);
return productCategoryMapper.toDto(productCategoryList);
}
}