Commit e8c0a006 authored by Kutzner's avatar Kutzner 🤸
Browse files

delete item

parent 2d8f3574
......@@ -8,11 +8,11 @@
<version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>de.hft-stuttgart</groupId>
<artifactId>middleware</artifactId>
<groupId>de.kebidge.middleware</groupId>
<artifactId>shopping-app</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>middleware</name>
<description>Demo project for Spring Boot</description>
<name>ShoppingApp</name>
<description>Shopping List Application</description>
<properties>
<java.version>11</java.version>
</properties>
......
package de.hftstuttgart.middleware;
package de.kebidge.middleware;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class MiddlewareApplication {
......@@ -12,25 +9,4 @@ public class MiddlewareApplication {
public static void main(String[] args) {
SpringApplication.run(MiddlewareApplication.class, args);
}
/*
@RestController
class Hello {
@GetMapping("/")
public String sayHello() {
return "Hello Kevin";
}
@GetMapping("/hello")
public String sayHelloAgain() {
return "Hello Kevin, from another REST Endpoint";
}
@GetMapping("/hello/{parameter}")
public String sayHelloWithParameter(@PathVariable String parameter) {
return "Hello Kevin, from another REST Endpoint " + parameter;
}
}
*/
}
\ No newline at end of file
package de.hftstuttgart.middleware;
package de.kebidge.middleware;
import java.util.ArrayList;
import java.util.Iterator;
......@@ -24,11 +24,6 @@ public class ShoppingAPI {
Logger logger = LoggerFactory.getLogger(ShoppingAPI.class);
/*public ShoppingAPI(ShoppingItemRepository shoppingItemRepository) {
this.shoppingItemRepository = shoppingItemRepository;
}*/
@GetMapping("/shoppingItem")
public ArrayList<Optional<ShoppingItem>> getShoppingItems() {
......@@ -40,9 +35,6 @@ public class ShoppingAPI {
Iterator<ShoppingItem> itemTerator = iterableItems.iterator();
// TODO: That should be work
//Iterator<Optional<ShoppingItem>> optionalItemTerator = optionalItemList.iterator();
logger.info("----- GET Item -----");
while(itemTerator.hasNext()){
......@@ -187,11 +179,17 @@ public class ShoppingAPI {
if(itemAmount > 1) {
/****************************************************
* ID bring nix da automatisch generiert !!!!!!!
* is aber nich schlimm
* amount ist ja richtig
*/
ShoppingItem newItem = new ShoppingItem(item);
newItem.setAmount(itemAmount - 1);
newItem.setId(itemId);
shoppingItemRepository.delete(tempItem);
//shoppingItemRepository.delete(tempItem);
logger.info("----- DELETE Item (Amount) -----");
logger.info("id = {}", newItem.id);
......
package de.hftstuttgart.middleware;
package de.kebidge.middleware;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
......
package de.hftstuttgart.middleware;
package de.kebidge.middleware;
import org.springframework.data.repository.CrudRepository;
......
spring.datasource.url=jdbc:postgresql://localhost:5432/kevindb
spring.datasource.username=kevin
spring.datasource.url=jdbc:postgresql://localhost:5432/kebidgedata
spring.datasource.username=kebidge
spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=update
server.port = 8181
logging.level.de.hftstuttgart=INFO
\ No newline at end of file
logging.level.de.kebidge=INFO
\ No newline at end of file
package de.hftstuttgart.middleware;
package de.kebidge.middleware;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment