fixed code formatting issue
This commit is contained in:
parent
18894f5c03
commit
b59f4d32b4
@ -9,10 +9,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
*/
|
||||
|
||||
@SpringBootApplication
|
||||
public class App
|
||||
{
|
||||
public static void main( String[] args )
|
||||
{
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(App.class, args);
|
||||
}
|
||||
}
|
||||
|
@ -32,13 +32,15 @@ public class ConsoleApp implements CommandLineRunner {
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
String filePath = "";
|
||||
if (args != null && args.length == 2 && "Product".equalsIgnoreCase(args[0])
|
||||
&& (filePath = args[1]).length() > 0) {
|
||||
if (args != null && args.length == 2 && "Product".equalsIgnoreCase(args[0]) && (filePath = args[1]).length() > 0) {
|
||||
File sourceFile = new File(filePath);
|
||||
if (sourceFile.exists()) {
|
||||
CsvMapper mapper = new CsvMapper();
|
||||
List<Product> products = mapper.readerFor(Product.class).with(CsvSchema.emptySchema().withHeader())
|
||||
.<Product>readValues(sourceFile).readAll();
|
||||
List<Product> products = mapper.readerFor(Product.class)
|
||||
.with(CsvSchema.emptySchema()
|
||||
.withHeader())
|
||||
.<Product> readValues(sourceFile)
|
||||
.readAll();
|
||||
productService.saveAll(products);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,10 @@ public class ProductController {
|
||||
|
||||
@RequestMapping(value = "/all", method = RequestMethod.GET)
|
||||
public List<ProductDto> list() {
|
||||
return productService.findAll().stream().map(p -> new ProductDto(p)).collect(Collectors.toList());
|
||||
return productService.findAll()
|
||||
.stream()
|
||||
.map(p -> new ProductDto(p))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/{productId}", method = RequestMethod.GET)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.baeldung.hexagonal.architecture.dtos;
|
||||
|
||||
import com.baeldung.hexagonal.architecture.model.Product;
|
||||
|
||||
/**
|
||||
* @author AshwiniKeshri
|
||||
*
|
||||
@ -17,7 +18,8 @@ public class ProductDto {
|
||||
|
||||
private String description;
|
||||
|
||||
public ProductDto() {}
|
||||
public ProductDto() {
|
||||
}
|
||||
|
||||
public ProductDto(Product product) {
|
||||
this.description = product.getDescription();
|
||||
@ -67,5 +69,4 @@ public class ProductDto {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -82,6 +82,4 @@ public class Product implements Serializable{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user