Skip to content
Snippets Groups Projects
Commit 222dbc5a authored by Rhys Nute's avatar Rhys Nute
Browse files

ready to merge

parent 9a7507d5
No related branches found
No related tags found
2 merge requests!38Draft: Businesses,!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."
...@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -13,6 +13,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import java.util.List;
@Controller @Controller
public class organisationControllers { public class organisationControllers {
@GetMapping("/localauthorities") @GetMapping("/localauthorities")
...@@ -23,6 +25,7 @@ public class organisationControllers { ...@@ -23,6 +25,7 @@ public class organisationControllers {
@GetMapping("/businesses") @GetMapping("/businesses")
public ModelAndView getBusinessPage(){ public ModelAndView getBusinessPage(){
ModelAndView modelAndView = new ModelAndView("businesses"); ModelAndView modelAndView = new ModelAndView("businesses");
List<business> business = businessRepository.getAllBusinesses();
modelAndView.addObject("busiSub", business); modelAndView.addObject("busiSub", business);
return modelAndView; return modelAndView;
} }
......
...@@ -18,15 +18,15 @@ public class business { ...@@ -18,15 +18,15 @@ public class business {
@Override @Override
public String toString(){ public String toString(){
return "business{" + return "Business:" + " " +
businessName + '\'' + businessName + '\'' + " " +
address1 + '\'' + address1 + '\'' + " " +
address2 + '\'' + address2 + '\'' + " " +
city + '\'' + city + '\'' + " " +
county + '\'' + county + '\'' + " " +
postcode + '\'' + postcode + '\'' + " " +
website + website +
'}'; " ";
} }
public String getBusinessName() { public String getBusinessName() {
......
...@@ -5,6 +5,4 @@ import java.util.List; ...@@ -5,6 +5,4 @@ import java.util.List;
public interface businessRepository { public interface businessRepository {
List<business> getAllBusinesses(); List<business> getAllBusinesses();
void addBusiness(business bus); void addBusiness(business bus);
void addLocalAuthority(business bus);
} }
...@@ -27,21 +27,15 @@ public class businessRepositoryJDBC implements businessRepository{ ...@@ -27,21 +27,15 @@ public class businessRepositoryJDBC implements businessRepository{
); );
} }
public List<business> getAllBusinesses(){ public List<business> getAllBusinesses(){
String sql = "SELECT * FROM localAuthority"; String sql = "SELECT * FROM businesses";
return jdbc.query(sql, businessMapper); return jdbc.query(sql, businessMapper);
} }
@Override @Override
public void addBusiness(business bus) { public void addBusiness(business bus) {
String sql = "INSERT INTO businesses( businessName, address1, address2, city, county, postcode, website) values (?, ?, ?, ?, ?, ?, ?)";
}
@Override
public void addLocalAuthority(business bus){
String sql = "INSERT INTO business( 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()); jdbc.update(sql, bus.getBusinessName(),bus.getAddress1(),bus.getAddress2(),bus.getCity(),bus.getCounty(),bus.getPostcode(),bus.getWebsite());
} }
}
}
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