1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| @Service public class ProductServiceImpl implements ProductService{
@Autowired ProductMapper productMapper;
@Override public ResponseJsonResult getProduct() {
PageHelper.startPage(1,20); ProductExample productExample = new ProductExample(); List<Product> products = productMapper.selectByExample(productExample);
List<Res_Product> res_products = new ArrayList<>();
for (int i = 0; i < products.size() ; i++) { Res_Product res_product = new Res_Product(); Product product = products.get(i); res_product.setPrice(product.getPrice()); res_product.setId(product.getId()); res_product.setName(product.getName()); res_product.setImgUrl(product.getImage()); res_products.add(res_product); }
ResponseJsonResult responseJsonResult = new ResponseJsonResult(); responseJsonResult.setList(res_products);
return responseJsonResult; } }
|