Skip to content
Snippets Groups Projects
Commit 8e8af969 authored by Gabriel Copat's avatar Gabriel Copat
Browse files

Merge branch 'businesses' into...

Merge branch 'businesses' into 74-as-a-user-i-want-to-see-a-page-of-local-authorities-so-that-i-can-easily-source-contact-details

# Conflicts:
#	src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java
#	src/main/resources/data.sql
#	src/main/resources/schema.sql
#	src/main/resources/templates/fragments/Templating.html
#	src/main/resources/templates/local-authorities.html
#	src/test/java/Team5/SmartTownsOld/DataSourceConfig.java
parents 589c6099 6ecf6e86
No related branches found
No related tags found
1 merge request!31Resolve "As a user, I want to see a page of local authorities so that I can easily source contact details for a variety of different local authorities."
package Team5.SmartTowns.Organisation;
import Team5.SmartTowns.localauthority.localAuthority;
import Team5.SmartTowns.localauthority.localAuthorityRepository;
import Team5.SmartTowns.business.business;
import Team5.SmartTowns.business.businessRepository;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.stereotype.Controller;
......@@ -17,17 +17,22 @@ import java.util.List;
@Controller
public class organisationControllers {
@GetMapping("/local-authorities")
@GetMapping("/localauthorities")
public ModelAndView getLocalAuthoritiesPage(){
ModelAndView mav = new ModelAndView("local-authorities");
List<localAuthority> localAuthority = localAuthorityRepository.getAllLocalAuthority();
mav.addObject("localAuth", localAuthority);
return mav;
ModelAndView modelAndView = new ModelAndView("local-authorities");
return modelAndView;
}
@GetMapping("/localForm")
public ModelAndView getLocalAuthForm(){
ModelAndView modelAndView = new ModelAndView("local-auth-data");
modelAndView.addObject("localAuthority",new localAuthority());
@GetMapping("/businesses")
public ModelAndView getBusinessPage(){
ModelAndView modelAndView = new ModelAndView("businesses");
List<business> business = businessRepository.getAllBusinesses();
modelAndView.addObject("busiSub", business);
return modelAndView;
}
@GetMapping("/businessSub")
public ModelAndView getBusinessSubPage(){
ModelAndView modelAndView = new ModelAndView("business-data");
modelAndView.addObject("business", new business());
return modelAndView;
}
@Autowired
......@@ -42,6 +47,11 @@ public class organisationControllers {
ModelAndView modelAndView = new ModelAndView("local-authorities");
List<localAuthority> localAuthorities = localAuthorityRepository.getAllLocalAuthority();
modelAndView.addObject("localAuth", localAuthorities);
private businessRepository businessRepository;
@PostMapping("/business-data")
public ModelAndView businessSent(@Valid @ModelAttribute("business-data")business business, BindingResult bindingResult, Model model ) {
if (bindingResult.hasErrors()) {
ModelAndView modelAndView = new ModelAndView("business-data", model.asMap());
return modelAndView;
}else{// converts user input using the organisation constructor into a submittable format to the sql table
localAuthority loc = new localAuthority(localAuthority.getLocalAuthorityName(), localAuthority.getAddress1(), localAuthority.getAddress2(), localAuthority.getCity(), localAuthority.getCounty(), localAuthority.getPostcode(), localAuthority.getWebsite());
......@@ -50,26 +60,23 @@ public class organisationControllers {
ModelAndView modelAndView = new ModelAndView("local-authorities");
List<localAuthority> localAuthorities = localAuthorityRepository.getAllLocalAuthority();
modelAndView.addObject("localAuth", localAuthorities);
} else {// converts user input using the organisation constructor into a submittable format to the sql table
business bus = new business(business.getBusinessName(), business.getAddress1(), business.getAddress2(), business.getCity(), business.getCounty(), business.getPostcode(), business.getWebsite());
System.out.println(bus);
businessRepository.addBusiness(bus); //add local authority to local authority table
ModelAndView modelAndView = new ModelAndView("redirect:/businesses");
return modelAndView;
}
}
@GetMapping("/businesses")
public ModelAndView getBusinessesPage(){
ModelAndView mav1 = new ModelAndView("Businesses");
return mav1;
@GetMapping("/consumers")
public ModelAndView getConsumersPage(){
ModelAndView modelAndView = new ModelAndView("WorkWith/consumers.html");
return modelAndView;
}
@GetMapping("/towns")
public ModelAndView getTownsPage(){
ModelAndView mav2 = new ModelAndView("towns");
return mav2;
}
@GetMapping("/consumers")
public ModelAndView getConsumersPage(){
ModelAndView mav3 = new ModelAndView("consumers");
return mav3;
ModelAndView modelAndView = new ModelAndView("WorkWith/towns.html");
return modelAndView;
}
}
package Team5.SmartTowns.business;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class business {
private String businessName;
private String address1;
private String address2;
private String city;
private String county;
private String postcode;
private String website;
@Override
public String toString(){
return "Business:" + " " +
businessName + '\'' + " " +
address1 + '\'' + " " +
address2 + '\'' + " " +
city + '\'' + " " +
county + '\'' + " " +
postcode + '\'' + " " +
website +
" ";
}
public String getBusinessName() {
return businessName;
}
public String getAddress1() {
return address1;
}
public String getAddress2() {
return address2;
}
public String getCity() {
return city;
}
public String getCounty() {
return county;
}
public String getPostcode() {
return postcode;
}
public String getWebsite() {
return website;
}
}
package Team5.SmartTowns.business;
import java.util.List;
public interface businessRepository {
List<business> getAllBusinesses();
void addBusiness(business bus);
}
package Team5.SmartTowns.business;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class businessRepositoryJDBC implements businessRepository{
private JdbcTemplate jdbc;
private RowMapper<business> businessMapper;
public businessRepositoryJDBC(JdbcTemplate ajdbc){
this.jdbc = ajdbc;
setbusinessMapper();
}
private void setbusinessMapper(){
businessMapper = (rs, i) -> new business(
rs.getString("businessName"),
rs.getString("address1"),
rs.getString("address2"),
rs.getString("city"),
rs.getString("county"),
rs.getString("postcode"),
rs.getString("website")
);
}
public List<business> getAllBusinesses(){
String sql = "SELECT * FROM businesses";
return jdbc.query(sql, businessMapper);
}
@Override
public void addBusiness(business bus) {
String sql = "INSERT INTO businesses( businessName, address1, address2, city, county, postcode, website) values (?, ?, ?, ?, ?, ?, ?)";
jdbc.update(sql, bus.getBusinessName(),bus.getAddress1(),bus.getAddress2(),bus.getCity(),bus.getCounty(),bus.getPostcode(),bus.getWebsite());
}
}
body{
background-color: rgb(41, 41, 41)
}
h3{
color: wheat;
}
ul{
list-style: none;
}
ul li{
color: wheat;
list-style: none;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Local Authorities</title>
<link rel="stylesheet" href="../../static/css/templatingstyle.css">
</head>
<header th:insert="~{/fragments/Templating.html::header}"></header>
<body>
<h1>Local Authorities</h1>
<div id="councils">
<p>Caerphilly County Borough Council,<br>Tredomen Park,<br> Ystrad Mynach,<br> Hengoed,<br> CF82 7PG</p>
<a href="https://www.caerphilly.gov.uk/main.aspx?lang=en-GB">Caerphilly County Borough Council Website</a>
<p>Risca Town Council,<br>Risca Palace Library,<br>Unit B,<br>75 Tredegar Street,<br>Risca,<br>NP11 6BW</p>
<a href="https://www.riscatowncouncil.org.uk/">Risca Town Council Website</a>
<p>Penarth Town Council West House,<br>Stanwell Road,<br>Penarth,<br> CF64 2YG</p>
<a href="https://www.penarthtowncouncil.gov.uk/your-council/">Penarth Town Council Website</a>
</div>
<footer th:insert="~{/fragments/Templating.html::footer}"></footer>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Businesses</title>
<link rel="stylesheet" th:href="@{css/landmarkFormStyle.css}">
<link rel="stylesheet" th:href="@{css/templatingstyle.css}">
</head>
<header th:insert="fragments/Templating.html :: header"></header>
<body>
<div id="container1">
<h2>Enter your Business information</h2>
<form action="/business-data" id="data" name="data" method="post" th:object="${business}">
<br>
<label>Enter your business
<input type="text" th:field="*{businessName}">
</label><br><br>
<label>Please enter first line of your address
<input type="text" th:field="*{address1}">
</label><br><br>
<label>Please enter second line of your address (optional)
<input type="text" th:field="*{address2}">
</label><br><br>
<label>Please enter the City/Town
<input type="text" th:field="*{city}">
</label><br><br>
<label>Please enter you county (optional)
<input type="text" th:field="*{county}">
</label><br><br>
<label>Please enter your postcode
<input type="text" th:field="*{postcode}">
</label><br><br>
<label>Please enter your website address
<input type="text" th:field="*{website}">
</label><br><br>
<input type="submit">
</form>
</div>
</body>
<div th:insert="fragments/Templating.html :: footer"></div>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Businesses</title>
<link rel="stylesheet" th:href="@{css/landmarkFormStyle.css}">
<link rel="stylesheet" th:href="@{css/templatingstyle.css}">
</head>
<header th:insert="fragments/Templating.html :: header"></header>
<body>
<p>A business is an organised establishment in a professional manner in order to achieve your particular aim for owning a business.</p>
<h3>Future Proof Businesses</h3>
<h3>Compete with Online Retailers</h3>
<h3>Drive Footfall to the high street</h3>
<h3>Increase Sales</h3>
<ul th:each="businesses:${busiSub}">
<li th:text="${businesses}"></li>
</ul>
<button><a href="/businessSub" id="business">Businesses please enter here</a></button>
</body>
<div th:insert="fragments/Templating.html :: footer"></div>
</html>
\ No newline at end of file
......@@ -2,31 +2,22 @@
<link rel="stylesheet" href="../../static/css/templatingstyle.css">
<header class="headerBar" th:fragment="header">
<div class="Logo">
<img src="/images/VZTA.png" height="97" width="400" alt="VZTA Logo"/>
<img src="/images/icons/VZTA.png" height="97" width="400" alt="VZTA Logo"/>
</div>
<nav class="navBar">
<ul>
<li><a id="homeHead" href="/home">Home</a></li>
<li>FAQs</li>
<li>Contact us</li>
<li th:if="${#authentication.principal}!=anonymousUser"><a href="/logout">Log Out</a></li>
<li th:if="${#authentication.principal}==anonymousUser"><a href="/login">Log In</a></li>
</ul>
<<<<<<< HEAD
<label class="work">Who we Work with:</label>
<select>
<ul>
<option value="localauthorities"><a href="/local-authorities">Local Authorities</a></option>
<option value="towns">Towns</option>
<option value="businesses">Businesses</option>
<option value="consumers">Consumers</option>
</ul>
=======
<label for="stakeholders" class="work">Who we Work with:</label>
<select id="stakeholders">
<option value="localauthorities">Local Authorities</option>
<option value="towns">Towns</option>
<option value="businesses">Businesses</option>
<option value="consumers">Consumers</option>
>>>>>>> 6464aaa8419c280b353cd943e44f8b09d831da64
</select>
</nav>
</header>
......@@ -50,10 +41,10 @@
<div class="centerFooter">
<span class="footerText">
<h3>Follow Us</h3>
<a href="https://www.facebook.com/VZTAsmarttowns/" class="icon"><img src="/images/Facebook.png" height="25" width="25" alt="Facebook Logo" class="icon"/></a>
<a href="https://www.twitter.com/VZTAsmarttowns/" class="icon"><img src="/images/Twitter.jpg" height="25" width="25" alt="X (formally Twitter) Logo" class="icon"/></a>
<a href="https://www.instagram.com/vztasmarttowns/" class="icon"><img src="/images/Instagram.jpg" height="25" width="25" alt="Instagram Logo" class="icon"/></a>
<a href="https://www.linkin.com/company/vztasmarttowns/" class="icon"><img src="/images/Linkedin.png" height="25" width="25" alt="Linkedin Logo" class="icon"/></a><br>
<a href="https://www.facebook.com/VZTAsmarttowns/" class="icon"><img src="/images/icons/Facebook.png" height="25" width="25" alt="Facebook Logo" class="icon"/></a>
<a href="https://www.twitter.com/VZTAsmarttowns/" class="icon"><img src="/images/icons/Twitter.jpg" height="25" width="25" alt="X (formally Twitter) Logo" class="icon"/></a>
<a href="https://www.instagram.com/vztasmarttowns/" class="icon"><img src="/images/icons/Instagram.jpg" height="25" width="25" alt="Instagram Logo" class="icon"/></a>
<a href="https://www.linkin.com/company/vztasmarttowns/" class="icon"><img src="/images/icons/Linkedin.png" height="25" width="25" alt="Linkedin Logo" class="icon"/></a><br>
</span>
</div>
<div class="copyright" style="text-align: left">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment