diff --git a/Backoffice/pom.xml b/Backoffice/pom.xml index bc7640d..035f601 100644 --- a/Backoffice/pom.xml +++ b/Backoffice/pom.xml @@ -49,6 +49,10 @@ javax.xml.bind jaxb-api + + org.springframework.boot + spring-boot-starter-thymeleaf + mysql diff --git a/Backoffice/src/main/java/com/kharkitecture/backoffice/controller/BuildingController.java b/Backoffice/src/main/java/com/kharkitecture/backoffice/controller/BuildingController.java index 3a5242a..fdbc952 100644 --- a/Backoffice/src/main/java/com/kharkitecture/backoffice/controller/BuildingController.java +++ b/Backoffice/src/main/java/com/kharkitecture/backoffice/controller/BuildingController.java @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -14,7 +15,7 @@ @Controller @RequestMapping("/building") public class BuildingController { - private static final String BUILDING_PAGE = "/building"; + private static final String BUILDING_PAGE = "addObject"; private static final Marker DB_MARKER = MarkerManager.getMarker("DATABASE"); private BuildingService buildingService; private Logger logger; @@ -26,6 +27,12 @@ public BuildingController(BuildingService buildingService) { } @RequestMapping(value = "/", method = GET) + public String getBuildingPage(Model model) { + model.addAttribute("building", new Building()); + return BUILDING_PAGE; + } + + @RequestMapping(value = "/all", method = GET) public String getBuildingsList(Model model) { model.addAttribute("buildings", buildingService.getBuildings()); return BUILDING_PAGE; @@ -42,21 +49,21 @@ public String getBuilding(@PathVariable long id, Model model) { } @RequestMapping(value = "/", method = POST) - public String addBuilding(Building newBuilding) { - buildingService.save(newBuilding); - return "redirect:" + BUILDING_PAGE; + public String addBuilding(@ModelAttribute("building") Building building) { + buildingService.save(building); + return "redirect:/" + BUILDING_PAGE; } @RequestMapping(value = "/", method = PUT) public String updateBuilding(Building editedBuilding) { buildingService.update(editedBuilding); - return "redirect:" + BUILDING_PAGE; + return "redirect:/" + BUILDING_PAGE; } @RequestMapping(value = "/{id}", method = DELETE) public String removeBuilding(@PathVariable long id) { buildingService.remove(id); - return "redirect:" + BUILDING_PAGE; + return "redirect:/" + BUILDING_PAGE; } diff --git a/Backoffice/src/main/java/com/kharkitecture/backoffice/entity/Building.java b/Backoffice/src/main/java/com/kharkitecture/backoffice/entity/Building.java index 468e615..f0e5915 100644 --- a/Backoffice/src/main/java/com/kharkitecture/backoffice/entity/Building.java +++ b/Backoffice/src/main/java/com/kharkitecture/backoffice/entity/Building.java @@ -11,7 +11,7 @@ public class Building { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) - private long id; + private Long id; private String name; private String description; @OneToMany(fetch = FetchType.LAZY, targetEntity = Photo.class) @@ -54,11 +54,11 @@ public boolean addCategory(Category category) { return categories.add(category); } - public long getId() { + public Long getId() { return id; } - public void setId(long id) { + public void setId(Long id) { this.id = id; } @@ -99,7 +99,7 @@ public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Building)) return false; Building building = (Building) o; - return id == building.id && + return id.equals(building.id) && Objects.equals(name, building.name); } diff --git a/Backoffice/src/main/resources/frontend/css/addObject.css b/Backoffice/src/main/resources/static/css/addObject.css similarity index 100% rename from Backoffice/src/main/resources/frontend/css/addObject.css rename to Backoffice/src/main/resources/static/css/addObject.css diff --git a/Backoffice/src/main/resources/frontend/css/main.css b/Backoffice/src/main/resources/static/css/main.css similarity index 100% rename from Backoffice/src/main/resources/frontend/css/main.css rename to Backoffice/src/main/resources/static/css/main.css diff --git a/Backoffice/src/main/resources/frontend/js/addObject.js b/Backoffice/src/main/resources/static/js/addObject.js similarity index 100% rename from Backoffice/src/main/resources/frontend/js/addObject.js rename to Backoffice/src/main/resources/static/js/addObject.js diff --git a/Backoffice/src/main/resources/frontend/addObject.html b/Backoffice/src/main/resources/templates/addObject.html similarity index 87% rename from Backoffice/src/main/resources/frontend/addObject.html rename to Backoffice/src/main/resources/templates/addObject.html index 1cbd1b9..553eb09 100644 --- a/Backoffice/src/main/resources/frontend/addObject.html +++ b/Backoffice/src/main/resources/templates/addObject.html @@ -1,15 +1,15 @@ - + - Adminka + AddBuilding Page - + - - + + @@ -88,15 +88,15 @@ - + - Название - + Название + Описание - + diff --git a/Backoffice/src/main/resources/frontend/admin.html b/Backoffice/src/main/resources/templates/index.html similarity index 95% rename from Backoffice/src/main/resources/frontend/admin.html rename to Backoffice/src/main/resources/templates/index.html index adf2f14..c717a96 100644 --- a/Backoffice/src/main/resources/frontend/admin.html +++ b/Backoffice/src/main/resources/templates/index.html @@ -4,7 +4,7 @@ - Adminka + BackOffice Homepage @@ -25,7 +25,7 @@ - + @@ -50,7 +50,7 @@ View - Add + Add Edit Something else here diff --git a/Backoffice/src/main/resources/frontend/index.html b/Backoffice/src/main/resources/templates/login.html similarity index 95% rename from Backoffice/src/main/resources/frontend/index.html rename to Backoffice/src/main/resources/templates/login.html index 4e16353..1895f65 100644 --- a/Backoffice/src/main/resources/frontend/index.html +++ b/Backoffice/src/main/resources/templates/login.html @@ -25,7 +25,7 @@ - + @@ -35,7 +35,7 @@ - + Email address + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +