查看所有仓库

pull/451/head
starrysky 2019-08-03 11:18:45 +08:00
parent 6466d75b6a
commit 9dfb94433f
3 changed files with 23 additions and 7 deletions

View File

@ -4,7 +4,7 @@ import me.zhengjie.aop.log.Log;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.wms.bd.domain.WareHouse;
import me.zhengjie.modules.wms.bd.service.WareHouseService;
import me.zhengjie.modules.wms.bd.service.dto.WareHouseDTO;
import me.zhengjie.modules.wms.bd.service.dto.WareHouseQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
@ -48,9 +48,15 @@ public class WareHouseController {
return new ResponseEntity(HttpStatus.OK);
}
@Log("查询仓库")
@Log("分页查询仓库")
@GetMapping(value = "/wareHouse")
public ResponseEntity getDicts(WareHouseDTO resources, Pageable pageable){
return new ResponseEntity(wareHouseService.queryAll(resources,pageable),HttpStatus.OK);
public ResponseEntity getWareHouses(WareHouseQueryCriteria wareHouseQueryCriteria, Pageable pageable){
return new ResponseEntity(wareHouseService.queryAll(wareHouseQueryCriteria,pageable),HttpStatus.OK);
}
@Log("查询仓库列表")
@GetMapping(value = "/wareHouse/all")
public ResponseEntity queryWareHouseList(WareHouseQueryCriteria wareHouseQueryCriteria){
return new ResponseEntity(wareHouseService.queryAll(wareHouseQueryCriteria),HttpStatus.OK);
}
}

View File

@ -2,6 +2,7 @@ package me.zhengjie.modules.wms.bd.service;
import me.zhengjie.modules.wms.bd.domain.WareHouse;
import me.zhengjie.modules.wms.bd.service.dto.WareHouseDTO;
import me.zhengjie.modules.wms.bd.service.dto.WareHouseQueryCriteria;
import org.springframework.data.domain.Pageable;
@ -17,6 +18,8 @@ public interface WareHouseService {
void delete(long id);
Object queryAll(WareHouseDTO wareHouse, Pageable pageable);
Object queryAll(WareHouseQueryCriteria wareHouseQueryCriteria, Pageable pageable);
Object queryAll(WareHouseQueryCriteria wareHouseQueryCriteria);
}

View File

@ -5,6 +5,7 @@ import me.zhengjie.modules.wms.bd.domain.WareHouse;
import me.zhengjie.modules.wms.bd.repository.WareHouseRepository;
import me.zhengjie.modules.wms.bd.service.WareHouseService;
import me.zhengjie.modules.wms.bd.service.dto.WareHouseDTO;
import me.zhengjie.modules.wms.bd.service.dto.WareHouseQueryCriteria;
import me.zhengjie.modules.wms.bd.service.mapper.WareHouseMapper;
import me.zhengjie.utils.PageUtil;
import me.zhengjie.utils.QueryHelp;
@ -71,9 +72,15 @@ public class WareHouseServiceImpl implements WareHouseService {
}
@Override
public Object queryAll(WareHouseDTO wareHouse, Pageable pageable) {
Page<WareHouse> page = wareHouseRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, wareHouse, cb), pageable);
public Object queryAll(WareHouseQueryCriteria wareHouseQueryCriteria, Pageable pageable) {
Page<WareHouse> page = wareHouseRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, wareHouseQueryCriteria, cb), pageable);
return PageUtil.toPage(page.map(wareHouseMapper::toDto));
}
@Override
public Object queryAll(WareHouseQueryCriteria wareHouseQueryCriteria) {
List<WareHouse> wareHouseList = wareHouseRepository.findAll((root, query, cb) -> QueryHelp.getPredicate(root, wareHouseQueryCriteria, cb));
return wareHouseList;
}
}