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