Skip to content

Commit

Permalink
adding feature -2 files
Browse files Browse the repository at this point in the history
  • Loading branch information
vikas0105 committed Dec 22, 2023
1 parent 61dcc5d commit 6195045
Show file tree
Hide file tree
Showing 20 changed files with 237 additions and 0 deletions.
49 changes: 49 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>simple-parcel-service-app</artifactId>
<version>1.0-SNAPSHOT</version>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.4</version>
<relativePath/>
</parent>

<properties>
<java.version>8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

12 changes: 12 additions & 0 deletions src/main/java/com/example/SimpleParcelServiceApp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SimpleParcelServiceApp {
public static void main(String[] args) {
SpringApplication.run(SimpleParcelServiceApp.class, args);
}
}

38 changes: 38 additions & 0 deletions src/main/java/com/example/controller/ParcelController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.example.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping("/")
public class ParcelController {

@GetMapping
public String index() {
return "index";
}

@PostMapping("/sendParcel")
public String sendParcel(
@RequestParam("recipientName") String recipientName,
@RequestParam("recipientAddress") String recipientAddress,
@RequestParam("senderName") String senderName,
@RequestParam("senderAddress") String senderAddress,
@RequestParam("parcelContent") String parcelContent,
Model model
) {
// You can do something with the data, e.g., save it to a database
// For now, let's just add it to the model and display a confirmation
model.addAttribute("recipientName", recipientName);
model.addAttribute("recipientAddress", recipientAddress);
model.addAttribute("senderName", senderName);
model.addAttribute("senderAddress", senderAddress);
model.addAttribute("parcelContent", parcelContent);
return "confirmation";
}
}

6 changes: 6 additions & 0 deletions src/main/java/com/example/model/Parcel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.model;

public class Parcel {
// Add fields as needed
}

9 changes: 9 additions & 0 deletions src/main/java/com/example/service/ParcelService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.service;

import org.springframework.stereotype.Service;

@Service
public class ParcelService {
// Add service methods as needed
}

5 changes: 5 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Thymeleaf Configuration
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.cache=false

16 changes: 16 additions & 0 deletions src/main/resources/templates/confirmation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Parcel Service App - Confirmation</title>
</head>
<body>
<h1>Parcel Sent Successfully!</h1>
<p>Recipient's Name: <span th:text="${recipientName}"></span></p>
<p>Recipient's Address: <span th:text="${recipientAddress}"></span></p>
<p>Sender's Name: <span th:text="${senderName}"></span></p>
<p>Sender's Address: <span th:text="${senderAddress}"></span></p>
<p>Parcel Content: <span th:text="${parcelContent}"></span></p>
</body>
</html>

35 changes: 35 additions & 0 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Parcel Service App</title>
</head>
<body>
<h1>Welcome to the Parcel Service App!</h1>

<form action="/sendParcel" method="post">
<label for="recipientName">Recipient's Name:</label>
<input type="text" id="recipientName" name="recipientName" required>
<br>

<label for="recipientAddress">Recipient's Address:</label>
<input type="text" id="recipientAddress" name="recipientAddress" required>
<br>

<label for="senderName">Sender's Name:</label>
<input type="text" id="senderName" name="senderName" required>
<br>

<label for="senderAddress">Sender's Address:</label>
<input type="text" id="senderAddress" name="senderAddress" required>
<br>

<label for="parcelContent">Parcel Content:</label>
<input type="text" id="parcelContent" name="parcelContent" required>
<br>

<button type="submit">Send Parcel</button>
</form>
</body>
</html>

5 changes: 5 additions & 0 deletions target/classes/application.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Thymeleaf Configuration
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.cache=false

Binary file not shown.
Binary file not shown.
Binary file added target/classes/com/example/model/Parcel.class
Binary file not shown.
Binary file not shown.
16 changes: 16 additions & 0 deletions target/classes/templates/confirmation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Parcel Service App - Confirmation</title>
</head>
<body>
<h1>Parcel Sent Successfully!</h1>
<p>Recipient's Name: <span th:text="${recipientName}"></span></p>
<p>Recipient's Address: <span th:text="${recipientAddress}"></span></p>
<p>Sender's Name: <span th:text="${senderName}"></span></p>
<p>Sender's Address: <span th:text="${senderAddress}"></span></p>
<p>Parcel Content: <span th:text="${parcelContent}"></span></p>
</body>
</html>

35 changes: 35 additions & 0 deletions target/classes/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<title>Parcel Service App</title>
</head>
<body>
<h1>Welcome to the Parcel Service App!</h1>

<form action="/sendParcel" method="post">
<label for="recipientName">Recipient's Name:</label>
<input type="text" id="recipientName" name="recipientName" required>
<br>

<label for="recipientAddress">Recipient's Address:</label>
<input type="text" id="recipientAddress" name="recipientAddress" required>
<br>

<label for="senderName">Sender's Name:</label>
<input type="text" id="senderName" name="senderName" required>
<br>

<label for="senderAddress">Sender's Address:</label>
<input type="text" id="senderAddress" name="senderAddress" required>
<br>

<label for="parcelContent">Parcel Content:</label>
<input type="text" id="parcelContent" name="parcelContent" required>
<br>

<button type="submit">Send Parcel</button>
</form>
</body>
</html>

3 changes: 3 additions & 0 deletions target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
artifactId=simple-parcel-service-app
groupId=com.example
version=1.0-SNAPSHOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
com\example\controller\ParcelController.class
com\example\SimpleParcelServiceApp.class
com\example\service\ParcelService.class
com\example\model\Parcel.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
C:\Users\POOJA\e-commerce\src\main\java\com\example\SimpleParcelServiceApp.java
C:\Users\POOJA\e-commerce\src\main\java\com\example\model\Parcel.java
C:\Users\POOJA\e-commerce\src\main\java\com\example\service\ParcelService.java
C:\Users\POOJA\e-commerce\src\main\java\com\example\controller\ParcelController.java
Binary file not shown.
Binary file not shown.

0 comments on commit 6195045

Please sign in to comment.