Skip to content

Commit cadf9d0

Browse files
committed
Fixing db readmes
1 parent f5622ff commit cadf9d0

File tree

9 files changed

+405
-20
lines changed

9 files changed

+405
-20
lines changed

03-database-joins/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JOIN query exercises
22

3-
This repository contains several exercises to practice SQL join queries against a simple E-commerce database.
3+
The exercises in this project are designed to help you review your knowledge of SQL JOIN statements.
44

55
## Creating the database
66

04-database-subqueries/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Subquery exercises
22

3-
This repository contains several exercises to practice SQL subqueries against a simple E-commerce database.
3+
The exercises in this project are designed to help you review your knowledge of SQL subqueries.
44

55
## Creating the database
66

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Testing APIs with Postman
2+
3+
The exercises in this project are designed to help you understand using Postman
4+
to test REST APIs.
5+
6+
## Getting Started
7+
8+
To get started, open the project file located in `spring-boot-and-mvc/pom.xml`
9+
in IntelliJ, and open Postman on your desktop.
10+
11+
## Project Overview
12+
13+
This project contains a simple Spring Boot application. You will not need to
14+
modify the code in this project, you will just be using Postman to test the
15+
REST endpoints.
16+
17+
## Exercise
18+
19+
20+
21+
## Testing / Verification
22+
23+
There are no tests for this exercise. You can verify that your work is correct
24+
based on the end points returning the expected results.
25+

12-testing-rest-apis-with-postman/testing-rest-apis-with-postman/.idea/uiDesigner.xml

+124
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,53 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
54
<modelVersion>4.0.0</modelVersion>
6-
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>3.3.5</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
711
<groupId>org.example</groupId>
8-
<artifactId>testing-rest-apis-with-postman</artifactId>
9-
<version>1.0-SNAPSHOT</version>
10-
12+
<artifactId>spring-boot</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>spring-boot</name>
15+
<description>Demo project for Spring Boot</description>
16+
<url/>
17+
<licenses>
18+
<license/>
19+
</licenses>
20+
<developers>
21+
<developer/>
22+
</developers>
23+
<scm>
24+
<connection/>
25+
<developerConnection/>
26+
<tag/>
27+
<url/>
28+
</scm>
1129
<properties>
12-
<maven.compiler.source>23</maven.compiler.source>
13-
<maven.compiler.target>23</maven.compiler.target>
14-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
30+
<java.version>17</java.version>
1531
</properties>
32+
<dependencies>
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-test</artifactId>
36+
<scope>test</scope>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.springframework.boot</groupId>
40+
<artifactId>spring-boot-starter-web</artifactId>
41+
</dependency>
42+
</dependencies>
43+
44+
<build>
45+
<plugins>
46+
<plugin>
47+
<groupId>org.springframework.boot</groupId>
48+
<artifactId>spring-boot-maven-plugin</artifactId>
49+
</plugin>
50+
</plugins>
51+
</build>
1652

17-
</project>
53+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package org.example.Controllers;
2+
3+
4+
import org.example.Models.ShoppingListItem;
5+
import org.springframework.web.bind.annotation.*;
6+
7+
import java.util.ArrayList;
8+
import java.util.List;
9+
10+
/**
11+
* Represents a controller for the shopping list.
12+
*/
13+
@RestController
14+
public class ShoppingListController {
15+
/**
16+
* The shopping list.
17+
*/
18+
private List<ShoppingListItem> shoppingList = new ArrayList<>();
19+
20+
/**
21+
* Gets all the items in the shopping list.
22+
*
23+
* @return All the items in the shopping list.
24+
*/
25+
@GetMapping
26+
public List<ShoppingListItem> getShoppingList() {
27+
return shoppingList;
28+
}
29+
30+
/**
31+
* Gets a shopping list item by its id.
32+
*
33+
* @param id The id of the item.
34+
* @return The item with the specified id, or null if no item was found.
35+
*/
36+
@GetMapping("/{id}")
37+
public ShoppingListItem getShoppingListItemById(@PathVariable int id) {
38+
return shoppingList.stream()
39+
.filter(item -> item.getId() == id)
40+
.findFirst()
41+
.orElse(null);
42+
}
43+
44+
/**
45+
* Adds a shopping list item to the shopping list.
46+
*
47+
* @param item The item to add.
48+
*/
49+
@PostMapping
50+
public void addShoppingListItem(@RequestBody ShoppingListItem item) {
51+
shoppingList.add(item);
52+
}
53+
54+
/**
55+
* Updates a shopping list item in the shopping list.
56+
*
57+
* @param id The id of the item.
58+
* @param item The item to update.
59+
*/
60+
@PutMapping("/{id}")
61+
public void updateShoppingListItem(@PathVariable int id, @RequestBody ShoppingListItem item) {
62+
ShoppingListItem existingItem = getShoppingListItemById(id);
63+
if (existingItem != null) {
64+
existingItem.setTitle(item.getTitle());
65+
existingItem.setPrice(item.getPrice());
66+
existingItem.setQuantity(item.getQuantity());
67+
}
68+
}
69+
70+
/**
71+
* Deletes a shopping list item from the shopping list.
72+
*
73+
* @param id The id of the item.
74+
*/
75+
@DeleteMapping("/{id}")
76+
public void deleteShoppingListItem(@PathVariable int id) {
77+
shoppingList.removeIf(item -> item.getId() == id);
78+
}
79+
}

12-testing-rest-apis-with-postman/testing-rest-apis-with-postman/src/main/java/org/example/Main.java

-7
This file was deleted.

0 commit comments

Comments
 (0)