Commit e8c0a006 authored by Kutzner's avatar Kutzner :cartwheel:
Browse files

delete item

1 merge request!1Dev
Showing with 30 additions and 20 deletions
+30 -20
...@@ -8,11 +8,11 @@ ...@@ -8,11 +8,11 @@
<version>2.5.6</version> <version>2.5.6</version>
<relativePath/> <!-- lookup parent from repository --> <relativePath/> <!-- lookup parent from repository -->
</parent> </parent>
<groupId>de.hft-stuttgart</groupId> <groupId>de.kebidge.middleware</groupId>
<artifactId>middleware</artifactId> <artifactId>shopping-app</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<name>middleware</name> <name>ShoppingApp</name>
<description>Demo project for Spring Boot</description> <description>Shopping List Application</description>
<properties> <properties>
<java.version>11</java.version> <java.version>11</java.version>
</properties> </properties>
......
package de.hftstuttgart.middleware; package de.kebidge.middleware;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; 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 @SpringBootApplication
public class MiddlewareApplication { public class MiddlewareApplication {
...@@ -12,25 +9,4 @@ public class MiddlewareApplication { ...@@ -12,25 +9,4 @@ public class MiddlewareApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(MiddlewareApplication.class, 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.ArrayList;
import java.util.Iterator; import java.util.Iterator;
...@@ -24,11 +24,6 @@ public class ShoppingAPI { ...@@ -24,11 +24,6 @@ public class ShoppingAPI {
Logger logger = LoggerFactory.getLogger(ShoppingAPI.class); Logger logger = LoggerFactory.getLogger(ShoppingAPI.class);
/*public ShoppingAPI(ShoppingItemRepository shoppingItemRepository) {
this.shoppingItemRepository = shoppingItemRepository;
}*/
@GetMapping("/shoppingItem") @GetMapping("/shoppingItem")
public ArrayList<Optional<ShoppingItem>> getShoppingItems() { public ArrayList<Optional<ShoppingItem>> getShoppingItems() {
...@@ -40,9 +35,6 @@ public class ShoppingAPI { ...@@ -40,9 +35,6 @@ public class ShoppingAPI {
Iterator<ShoppingItem> itemTerator = iterableItems.iterator(); Iterator<ShoppingItem> itemTerator = iterableItems.iterator();
// TODO: That should be work
//Iterator<Optional<ShoppingItem>> optionalItemTerator = optionalItemList.iterator();
logger.info("----- GET Item -----"); logger.info("----- GET Item -----");
while(itemTerator.hasNext()){ while(itemTerator.hasNext()){
...@@ -187,11 +179,17 @@ public class ShoppingAPI { ...@@ -187,11 +179,17 @@ public class ShoppingAPI {
if(itemAmount > 1) { if(itemAmount > 1) {
/****************************************************
* ID bring nix da automatisch generiert !!!!!!!
* is aber nich schlimm
* amount ist ja richtig
*/
ShoppingItem newItem = new ShoppingItem(item); ShoppingItem newItem = new ShoppingItem(item);
newItem.setAmount(itemAmount - 1); newItem.setAmount(itemAmount - 1);
newItem.setId(itemId); newItem.setId(itemId);
shoppingItemRepository.delete(tempItem); //shoppingItemRepository.delete(tempItem);
logger.info("----- DELETE Item (Amount) -----"); logger.info("----- DELETE Item (Amount) -----");
logger.info("id = {}", newItem.id); logger.info("id = {}", newItem.id);
......
package de.hftstuttgart.middleware; package de.kebidge.middleware;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.GeneratedValue; import javax.persistence.GeneratedValue;
......
package de.hftstuttgart.middleware; package de.kebidge.middleware;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
......
spring.datasource.url=jdbc:postgresql://localhost:5432/kevindb spring.datasource.url=jdbc:postgresql://localhost:5432/kebidgedata
spring.datasource.username=kevin spring.datasource.username=kebidge
spring.datasource.password=password spring.datasource.password=password
spring.jpa.hibernate.ddl-auto=update spring.jpa.hibernate.ddl-auto=update
server.port = 8181 server.port = 8181
logging.level.de.hftstuttgart=INFO logging.level.de.kebidge=INFO
\ No newline at end of file \ No newline at end of file
package de.hftstuttgart.middleware; package de.kebidge.middleware;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
......
Supports Markdown
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