diff --git a/build.gradle b/build.gradle index 36226f9..92f3afb 100644 --- a/build.gradle +++ b/build.gradle @@ -14,10 +14,21 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-devtools' + implementation 'nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect' + + implementation 'org.webjars:bootstrap:5.1.3' + implementation 'org.webjars:jquery:3.6.0' + implementation 'org.webjars:font-awesome:6.1.0' implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'com.h2database:h2:2.1.210' + implementation 'org.hibernate.validator:hibernate-validator' + + implementation 'org.springdoc:springdoc-openapi-ui:1.6.5' + testImplementation 'org.springframework.boot:spring-boot-starter-test' } diff --git a/front/src/components/ReportStudentCategory.jsx b/front/src/components/ReportStudentCategory.jsx new file mode 100644 index 0000000..d496dc6 --- /dev/null +++ b/front/src/components/ReportStudentCategory.jsx @@ -0,0 +1,72 @@ +import DataService from '../services/DataService'; +import Student from '../models/Student'; +import Category from '../models/Category'; +import { useState, useEffect } from 'react'; +import Form from 'react-bootstrap/Form'; +import Button from 'react-bootstrap/Button'; +import DrivingSchool from '../models/DrivingSchool'; +import { Link} from "react-router-dom"; +export default function ReportStudentCategory(props) { + const headersEmp = [ + {name: 'surname', label: "Фамилия"}, + {name: 'name', label: "Имя"}, + {name: 'categoriesString', label: 'Категории'}, + {name: 'phoneNumber', label: "Номер телефона"}, + ]; + + + const url = "/student/category?cat=id" + const urlCat = '/category'; + + const [itemsCat, setItemsCat] = useState([]); + + const [itemsStud, setItemsStud] = useState([]); + + useEffect(() => { + loadItemsCtegories(); + }); + + function loadItemsCtegories() { + DataService.readAll(urlCat, (data) => new Category(data)) + .then(data => setItemsCat(data)); + } + + function loadItemsStudents(selectedCategory) { + DataService.readAll(url.replace("id", selectedCategory), (data) => new Student(data)) + .then(data => setItemsStud(data)); + } + + return
+

Отчет

+ + {loadItemsStudents(e.target.value)}} aria-label="Default select example"> + + { + itemsCat.map((e) => ) + } + + +
+ + + + { + headersStud.map((header) => ) + } + + + + + { + itemsStud.map((item) => + { + headersStud.map((header) => ) + } + + ) + } + +
{header.label}Автошкола
{item[header.name]}{item['drivingSchool'].name}
+
+
+} \ No newline at end of file diff --git a/front/src/services/DataService.js b/front/src/services/DataService.js index 01e0093..84c3858 100644 --- a/front/src/services/DataService.js +++ b/front/src/services/DataService.js @@ -13,7 +13,7 @@ function toJSON(data) { } export default class DataService { - static dataUrlPrefix = 'http://localhost:8080'; + static dataUrlPrefix = 'http://localhost:8080/api'; static async readAll(url, transformer) { const response = await axios.get(this.dataUrlPrefix + url); diff --git a/src/main/java/ru/ulstu/is/cbapp/WebConfiguration.java b/src/main/java/ru/ulstu/is/cbapp/WebConfiguration.java index aaf94d7..f5229a0 100644 --- a/src/main/java/ru/ulstu/is/cbapp/WebConfiguration.java +++ b/src/main/java/ru/ulstu/is/cbapp/WebConfiguration.java @@ -1,10 +1,13 @@ package ru.ulstu.is.cbapp; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration public class WebConfiguration implements WebMvcConfigurer { + public static final String REST_API = "/api"; + @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**").allowedMethods("*"); diff --git a/src/main/java/ru/ulstu/is/cbapp/controller/CategoryController.java b/src/main/java/ru/ulstu/is/cbapp/controller/CategoryController.java index 4b6b2db..a903d22 100644 --- a/src/main/java/ru/ulstu/is/cbapp/controller/CategoryController.java +++ b/src/main/java/ru/ulstu/is/cbapp/controller/CategoryController.java @@ -1,5 +1,7 @@ package ru.ulstu.is.cbapp.controller; +import jakarta.validation.Valid; +import ru.ulstu.is.cbapp.WebConfiguration; import ru.ulstu.is.cbapp.dto.CategoryDto; import ru.ulstu.is.cbapp.service.CategoryService; import org.springframework.web.bind.annotation.*; @@ -7,7 +9,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; @RestController -@RequestMapping("/category") +@RequestMapping(WebConfiguration.REST_API + "/category") public class CategoryController { private final CategoryService categoryService; @@ -28,14 +30,14 @@ public class CategoryController { } @PostMapping - public CategoryDto create(@RequestParam("name") String name) { - return new CategoryDto(categoryService.addCategory(name)); + public CategoryDto create(@RequestBody @Valid CategoryDto categoryDto) { + return new CategoryDto(categoryService.addCategory(categoryDto.getName())); } @PutMapping("/{id}") public CategoryDto update(@PathVariable Long id, - @RequestParam("name") String name) { - return new CategoryDto(categoryService.updateCategory(id, name)); + @RequestBody @Valid CategoryDto categoryDto) { + return new CategoryDto(categoryService.updateCategory(id, categoryDto.getName())); } @DeleteMapping("/{id}") diff --git a/src/main/java/ru/ulstu/is/cbapp/controller/CategoryStudentController.java b/src/main/java/ru/ulstu/is/cbapp/controller/CategoryStudentController.java index b140bc8..0331ac0 100644 --- a/src/main/java/ru/ulstu/is/cbapp/controller/CategoryStudentController.java +++ b/src/main/java/ru/ulstu/is/cbapp/controller/CategoryStudentController.java @@ -3,6 +3,7 @@ package ru.ulstu.is.cbapp.controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import ru.ulstu.is.cbapp.WebConfiguration; import ru.ulstu.is.cbapp.dto.GroupedStudAndCategoryDto; import ru.ulstu.is.cbapp.service.CategoryService; import ru.ulstu.is.cbapp.service.CategoryStudentService; @@ -10,7 +11,7 @@ import ru.ulstu.is.cbapp.service.CategoryStudentService; import java.util.List; @RestController -@RequestMapping("/categoryStudent") +@RequestMapping(WebConfiguration.REST_API+"/categoryStudent") public class CategoryStudentController { private CategoryStudentService categoryStudentService; diff --git a/src/main/java/ru/ulstu/is/cbapp/controller/DrivingSchoolController.java b/src/main/java/ru/ulstu/is/cbapp/controller/DrivingSchoolController.java index fbfe491..8450ce9 100644 --- a/src/main/java/ru/ulstu/is/cbapp/controller/DrivingSchoolController.java +++ b/src/main/java/ru/ulstu/is/cbapp/controller/DrivingSchoolController.java @@ -1,5 +1,7 @@ package ru.ulstu.is.cbapp.controller; +import jakarta.validation.Valid; +import ru.ulstu.is.cbapp.WebConfiguration; import ru.ulstu.is.cbapp.dto.DrivingSchoolDto; import ru.ulstu.is.cbapp.dto.StudentDto; import ru.ulstu.is.cbapp.models.Student; @@ -10,7 +12,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; @RestController -@RequestMapping("/drivingSchool") +@RequestMapping(WebConfiguration.REST_API + "/drivingSchool") public class DrivingSchoolController { private final DrivingSchoolService drivingSchoolService; private final StudentService studentService; @@ -38,14 +40,14 @@ public class DrivingSchoolController { } @PostMapping - public DrivingSchoolDto create(@RequestParam("name") String name) { - return new DrivingSchoolDto(drivingSchoolService.addDrivingSchool(name)); + public DrivingSchoolDto create(@RequestBody @Valid DrivingSchoolDto drivingSchoolDto) { + return new DrivingSchoolDto(drivingSchoolService.addDrivingSchool(drivingSchoolDto.getName())); } @PutMapping("/{id}") public DrivingSchoolDto update(@PathVariable Long id, - @RequestParam("name") String name) { - return new DrivingSchoolDto(drivingSchoolService.updateDrivingSchool(id, name)); + @RequestBody @Valid DrivingSchoolDto drivingSchoolDto) { + return new DrivingSchoolDto(drivingSchoolService.updateDrivingSchool(id, drivingSchoolDto.getName())); } @DeleteMapping("/{id}") diff --git a/src/main/java/ru/ulstu/is/cbapp/controller/StudentController.java b/src/main/java/ru/ulstu/is/cbapp/controller/StudentController.java index d7fe246..a62b8ff 100644 --- a/src/main/java/ru/ulstu/is/cbapp/controller/StudentController.java +++ b/src/main/java/ru/ulstu/is/cbapp/controller/StudentController.java @@ -1,5 +1,7 @@ package ru.ulstu.is.cbapp.controller; +import jakarta.validation.Valid; +import ru.ulstu.is.cbapp.WebConfiguration; import ru.ulstu.is.cbapp.dto.StudentDto; import ru.ulstu.is.cbapp.models.Category; import ru.ulstu.is.cbapp.service.StudentService; @@ -9,7 +11,7 @@ import org.springframework.web.bind.annotation.*; import java.util.List; @RestController -@RequestMapping("/student") +@RequestMapping(WebConfiguration.REST_API + "/student") public class StudentController { private final StudentService studentService; private final CategoryService categoryService; @@ -32,21 +34,17 @@ public class StudentController { } @PostMapping - public StudentDto createStudent(@RequestParam("name") String name, - @RequestParam("surname") String surname, - @RequestParam("phoneNumber") String phoneNumber) { + public StudentDto createStudent(@RequestBody @Valid StudentDto studentDto) { return new StudentDto(studentService.addStudent( - surname, - name, - phoneNumber)); + studentDto.getSurname(), + studentDto.getName(), + studentDto.getPhoneNumber())); } @PutMapping("/{id}") public StudentDto updateStudent(@PathVariable Long id, - @RequestParam("name") String name, - @RequestParam("surname") String surname, - @RequestParam("phoneNumber") String phoneNumber) { - return new StudentDto(studentService.updateStudent(id, surname, name, phoneNumber)); + @RequestBody @Valid StudentDto studentDto) { + return new StudentDto(studentService.updateStudent(id, studentDto.getSurname(), studentDto.getName(), studentDto.getPhoneNumber())); } @DeleteMapping("/{id}") diff --git a/src/main/java/ru/ulstu/is/cbapp/dto/CategoryDto.java b/src/main/java/ru/ulstu/is/cbapp/dto/CategoryDto.java index 1741193..4fe2390 100644 --- a/src/main/java/ru/ulstu/is/cbapp/dto/CategoryDto.java +++ b/src/main/java/ru/ulstu/is/cbapp/dto/CategoryDto.java @@ -3,14 +3,21 @@ package ru.ulstu.is.cbapp.dto; import ru.ulstu.is.cbapp.models.Category; public class CategoryDto { - private final Long Id; - private final String name; + private Long Id; + private String name; public CategoryDto(Category category) { Id = category.getId(); this.name = category.getName(); } + public CategoryDto() { + } + + public void setName(String name) { + this.name = name; + } + public Long getId() { return Id; } diff --git a/src/main/java/ru/ulstu/is/cbapp/dto/DrivingSchoolDto.java b/src/main/java/ru/ulstu/is/cbapp/dto/DrivingSchoolDto.java index d0cf490..72c33a8 100644 --- a/src/main/java/ru/ulstu/is/cbapp/dto/DrivingSchoolDto.java +++ b/src/main/java/ru/ulstu/is/cbapp/dto/DrivingSchoolDto.java @@ -1,13 +1,14 @@ package ru.ulstu.is.cbapp.dto; +import com.fasterxml.jackson.annotation.JsonProperty; import ru.ulstu.is.cbapp.models.DrivingSchool; import java.util.List; public class DrivingSchoolDto { - private final Long Id; - private final String name; - private final List students; + private Long Id; + private String name; + private List students; public DrivingSchoolDto(DrivingSchool drivingSchool) { Id = drivingSchool.getId(); @@ -15,6 +16,11 @@ public class DrivingSchoolDto { this.students = drivingSchool.getStudents().stream().map(StudentDto::new).toList(); } + public DrivingSchoolDto() { + + } + + @JsonProperty(access = JsonProperty.Access.READ_ONLY) public Long getId() { return Id; } diff --git a/src/main/java/ru/ulstu/is/cbapp/dto/StudentDto.java b/src/main/java/ru/ulstu/is/cbapp/dto/StudentDto.java index 5f61378..38ccb14 100644 --- a/src/main/java/ru/ulstu/is/cbapp/dto/StudentDto.java +++ b/src/main/java/ru/ulstu/is/cbapp/dto/StudentDto.java @@ -5,13 +5,13 @@ import ru.ulstu.is.cbapp.models.Student; import java.util.List; public class StudentDto { - private final Long Id; - private final String name; - private final String phoneNumber; - private final String surname; - private final List categories; + private Long Id; + private String name; + private String phoneNumber; + private String surname; + private List categories; - private final DrivingSchoolWithoutStudDto drivingSchool; + private DrivingSchoolWithoutStudDto drivingSchool; public StudentDto(Student student) { Id = student.getId(); @@ -22,10 +22,25 @@ public class StudentDto { this.drivingSchool = student.getDrivingSchool() != null ? new DrivingSchoolWithoutStudDto(student.getDrivingSchool()) : null; } + public StudentDto() { + } + public Long getId() { return Id; } + public void setName(String name) { + this.name = name; + } + + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public void setSurname(String surname) { + this.surname = surname; + } + public String getName() { return name; } diff --git a/src/main/java/ru/ulstu/is/cbapp/mvc/CategoryMvcController.java b/src/main/java/ru/ulstu/is/cbapp/mvc/CategoryMvcController.java new file mode 100644 index 0000000..01bd103 --- /dev/null +++ b/src/main/java/ru/ulstu/is/cbapp/mvc/CategoryMvcController.java @@ -0,0 +1,64 @@ +package ru.ulstu.is.cbapp.mvc; + +import jakarta.validation.Valid; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import ru.ulstu.is.cbapp.dto.CategoryDto; +import ru.ulstu.is.cbapp.service.CategoryService; + +@Controller +@RequestMapping("/category") +public class CategoryMvcController { + + private final CategoryService categoryService; + + public CategoryMvcController(CategoryService categoryService) { + this.categoryService = categoryService; + } + + @GetMapping + public String getCategories(Model model) { + model.addAttribute("categories", + categoryService.findAllCategories().stream() + .map(CategoryDto::new) + .toList()); + return "category"; + } + + @GetMapping(value = {"/edit/", "/edit/{id}"}) + public String editCategory(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + model.addAttribute("categoryDto", new CategoryDto()); + } else { + model.addAttribute("categoryId", id); + model.addAttribute("categoryDto", new CategoryDto(categoryService.findCategory(id))); + } + return "category-edit"; + } + + @PostMapping(value = {"/", "/{id}"}) + public String saveCategory(@PathVariable(required = false) Long id, + @ModelAttribute @Valid CategoryDto categoryDto, + BindingResult bindingResult, + Model model) { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", bindingResult.getAllErrors()); + return "category-edit"; + } + if (id == null || id <= 0) { + categoryService.addCategory(categoryDto.getName()); + } else { + categoryService.updateCategory(id, categoryDto.getName()); + } + return "redirect:/category"; + } + + @PostMapping("/delete/{id}") + public String deleteStudent(@PathVariable Long id) { + categoryService.deleteCategory(id); + return "redirect:/category"; + } +} \ No newline at end of file diff --git a/src/main/java/ru/ulstu/is/cbapp/mvc/CategoryStudentMvcController.java b/src/main/java/ru/ulstu/is/cbapp/mvc/CategoryStudentMvcController.java new file mode 100644 index 0000000..e55cc87 --- /dev/null +++ b/src/main/java/ru/ulstu/is/cbapp/mvc/CategoryStudentMvcController.java @@ -0,0 +1,27 @@ +package ru.ulstu.is.cbapp.mvc; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import ru.ulstu.is.cbapp.dto.GroupedStudAndCategoryDto; +import ru.ulstu.is.cbapp.service.CategoryStudentService; +import org.springframework.ui.Model; + +import java.util.List; + +@Controller +@RequestMapping("/categoryStudent") +public class CategoryStudentMvcController { + private final CategoryStudentService categoryStudentService; + + public CategoryStudentMvcController(CategoryStudentService categoryStudentService) { + this.categoryStudentService = categoryStudentService; + } + + @GetMapping("/groupbycategory") + public String getGroupedStudAndCategory(Model model) { + List GroupedStudAndCategoryDtos = categoryStudentService.getGroupedStudAndCategory(); + model.addAttribute("GroupedStudAndCategoryDtos", GroupedStudAndCategoryDtos); + return "groupbycategory"; + } +} diff --git a/src/main/java/ru/ulstu/is/cbapp/mvc/DrivingSchoolMvcController.java b/src/main/java/ru/ulstu/is/cbapp/mvc/DrivingSchoolMvcController.java new file mode 100644 index 0000000..6a7f1bc --- /dev/null +++ b/src/main/java/ru/ulstu/is/cbapp/mvc/DrivingSchoolMvcController.java @@ -0,0 +1,85 @@ +package ru.ulstu.is.cbapp.mvc; + +import jakarta.validation.Valid; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import ru.ulstu.is.cbapp.dto.CategoryDto; +import ru.ulstu.is.cbapp.dto.DrivingSchoolDto; +import ru.ulstu.is.cbapp.dto.StudentDto; +import ru.ulstu.is.cbapp.service.CategoryService; +import ru.ulstu.is.cbapp.service.DrivingSchoolService; +import ru.ulstu.is.cbapp.service.StudentService; + +@Controller +@RequestMapping("/drivingSchool") +public class DrivingSchoolMvcController { + private final DrivingSchoolService drivingSchoolService; + private final StudentService studentService; + private final CategoryService categoryService; + + public DrivingSchoolMvcController(DrivingSchoolService drivingSchoolService, StudentService studentService, CategoryService categoryService) { + this.drivingSchoolService = drivingSchoolService; + this.studentService = studentService; + this.categoryService = categoryService; + } + + @GetMapping + public String getDrivingSchools(Model model) { + model.addAttribute("drivingSchools", + drivingSchoolService.findAllDrivingSchools().stream() + .map(DrivingSchoolDto::new) + .toList()); + return "drivingSchool"; + } + + @GetMapping("/one/{id}") + public String getDrivingSchool(@PathVariable(required = false) Long id, Model model) { + model.addAttribute("drivingSchool", + new DrivingSchoolDto(drivingSchoolService.findDrivingSchool(id))); + model.addAttribute("freeStudents", studentService.findAllFreeStudents().stream().map(StudentDto::new).toList()); + model.addAttribute("categories", categoryService.findAllCategories().stream().map(CategoryDto::new).toList()); + return "drivingSchool-one"; + } + + @PostMapping(value = "/redirect") + public String redirectToDrivingSchoolPage(@RequestParam("drivingSchoolId") Long drivingSchoolId) { + return "redirect:/drivingSchool/one/" + drivingSchoolId; + } + + @GetMapping(value = {"/edit", "/edit/{id}"}) + public String editDrivingSchool(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + model.addAttribute("drivingSchoolDto", new DrivingSchoolDto()); + } else { + model.addAttribute("drivingSchoolId", id); + model.addAttribute("drivingSchoolDto", new DrivingSchoolDto(drivingSchoolService.findDrivingSchool(id))); + } + return "drivingSchool-edit"; + } + + @PostMapping(value = {"/", "/{id}"}) + public String saveDrivingSchool(@PathVariable(required = false) Long id, + @ModelAttribute @Valid DrivingSchoolDto drivingSchoolDto, + BindingResult bindingResult, + Model model) { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", bindingResult.getAllErrors()); + return "drivingSchool-edit"; + } + if (id == null || id <= 0) { + drivingSchoolService.addDrivingSchool(drivingSchoolDto.getName()); + } else { + drivingSchoolService.updateDrivingSchool(id, drivingSchoolDto.getName()); + } + return "redirect:/drivingSchool"; + } + + @PostMapping("/delete/{id}") + public String deleteDrivingSchool(@PathVariable Long id) { + drivingSchoolService.deleteDrivingSchool(id); + return "redirect:/drivingSchool"; + } +} \ No newline at end of file diff --git a/src/main/java/ru/ulstu/is/cbapp/mvc/HomeController.java b/src/main/java/ru/ulstu/is/cbapp/mvc/HomeController.java new file mode 100644 index 0000000..89aa57d --- /dev/null +++ b/src/main/java/ru/ulstu/is/cbapp/mvc/HomeController.java @@ -0,0 +1,16 @@ +package ru.ulstu.is.cbapp.mvc; + +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; + +@Controller +public class HomeController { + + @ModelAttribute("requestURI") + public String requestURI(final HttpServletRequest request) { + return request.getRequestURI(); + } +} \ No newline at end of file diff --git a/src/main/java/ru/ulstu/is/cbapp/mvc/StudentMvcController.java b/src/main/java/ru/ulstu/is/cbapp/mvc/StudentMvcController.java new file mode 100644 index 0000000..f44a5b4 --- /dev/null +++ b/src/main/java/ru/ulstu/is/cbapp/mvc/StudentMvcController.java @@ -0,0 +1,69 @@ +package ru.ulstu.is.cbapp.mvc; + +import jakarta.validation.Valid; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; +import ru.ulstu.is.cbapp.dto.CategoryDto; +import ru.ulstu.is.cbapp.dto.StudentDto; +import ru.ulstu.is.cbapp.service.CategoryService; +import ru.ulstu.is.cbapp.service.StudentService; + +@Controller +@RequestMapping("/student") +public class StudentMvcController { + private final StudentService studentService; + private final CategoryService categoryService; + + public StudentMvcController(StudentService studentService, CategoryService categoryService) { + this.studentService = studentService; + this.categoryService = categoryService; + } + + @GetMapping + public String getStudents(Model model) { + model.addAttribute("students", + studentService.findAllStudents().stream() + .map(StudentDto::new) + .toList()); + return "student"; + } + + @GetMapping(value = {"/edit/", "/edit/{id}"}) + public String editDrivingSchool(@PathVariable(required = false) Long id, + Model model) { + if (id == null || id <= 0) { + model.addAttribute("studentDto", new StudentDto()); + } else { + model.addAttribute("studentId", id); + model.addAttribute("studentDto", new StudentDto(studentService.findStudent(id))); + } + return "student-edit"; + } + + @PostMapping(value = {"/", "/{id}"}) + public String saveDrivingSchool(@PathVariable(required = false) Long id, + @ModelAttribute @Valid StudentDto studentDto, + BindingResult bindingResult, + Model model) { + if (bindingResult.hasErrors()) { + model.addAttribute("errors", bindingResult.getAllErrors()); + return "student-edit"; + } + if (id == null || id <= 0) { + studentService.addStudent(studentDto.getSurname(), studentDto.getName(), studentDto.getPhoneNumber()); + } else { + studentService.updateStudent(id, studentDto.getSurname(), studentDto.getName(), studentDto.getPhoneNumber()); + } + return "redirect:/student"; + } + + + @PostMapping("/delete/{id}") + public String deleteStudent(@PathVariable Long id) { + studentService.deleteStudent(id); + return "redirect:/student"; + } + +} \ No newline at end of file diff --git a/src/main/resources/static/styles/drivingSchool.css b/src/main/resources/static/styles/drivingSchool.css new file mode 100644 index 0000000..141ff2d --- /dev/null +++ b/src/main/resources/static/styles/drivingSchool.css @@ -0,0 +1,9 @@ +.prokrutka { + background: #fff; /* цвет фона, белый */ + border: 1px solid #C1C1C1; /* размер и цвет границы блока */ + overflow: auto; + width:230px; + height:100px; + display: flex; + flex-direction: column; +} \ No newline at end of file diff --git a/src/main/resources/templates/category.html b/src/main/resources/templates/category.html new file mode 100644 index 0000000..a7efd99 --- /dev/null +++ b/src/main/resources/templates/category.html @@ -0,0 +1,115 @@ + + + + + +
+
Категории
+ +
+ + + + + + + + + + + + + + +
#IDНазваниеЭлементы управления
+ + + +
+ Изменить + +
+
+ +
+
+
+ +
+ + + + + diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html new file mode 100644 index 0000000..7fa40a1 --- /dev/null +++ b/src/main/resources/templates/default.html @@ -0,0 +1,46 @@ + + + + + Автошколы, студенты и категории + + + + + + + + + +
+
+
+
+ + + + \ No newline at end of file diff --git a/src/main/resources/templates/drivingSchool-one.html b/src/main/resources/templates/drivingSchool-one.html new file mode 100644 index 0000000..43c81ea --- /dev/null +++ b/src/main/resources/templates/drivingSchool-one.html @@ -0,0 +1,255 @@ + + + + + + +
+

Название:

+

Количество студентов:

+ + + + + + + + + + + + + + + + + + + +
#IDФамилияИмяНомер телефонаКатегории
+ + + + + + Отчислить + Категории +
+ + + + +
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/drivingSchool.html b/src/main/resources/templates/drivingSchool.html new file mode 100644 index 0000000..2cfe943 --- /dev/null +++ b/src/main/resources/templates/drivingSchool.html @@ -0,0 +1,148 @@ + + + + + +
+
Автошколы
+ +
+ + + + + + + + + + + + + + + + +
#IDНазваниеСтудентыЭлементы управления
+ + + +
+ Изменить + +
+
+ +
+
+
+ + + +
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/error.html b/src/main/resources/templates/error.html new file mode 100644 index 0000000..78fb62d --- /dev/null +++ b/src/main/resources/templates/error.html @@ -0,0 +1,13 @@ + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/groupbycategory.html b/src/main/resources/templates/groupbycategory.html new file mode 100644 index 0000000..cb40444 --- /dev/null +++ b/src/main/resources/templates/groupbycategory.html @@ -0,0 +1,27 @@ + + + + + +
+

Отчет (количество студентов в категории)

+
+ + + + + + + + + + + + + +
Название категорииКоличество студентов
+
+
+ + \ No newline at end of file diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..a6eac40 --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,13 @@ + + + + + +
+
Вроде работает
+ Ошибка :( +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/student.html b/src/main/resources/templates/student.html new file mode 100644 index 0000000..8aa1d77 --- /dev/null +++ b/src/main/resources/templates/student.html @@ -0,0 +1,133 @@ + + + + + +
+
Студенты
+ +
+ + + + + + + + + + + + + + + + + + +
#IDФамилияИмяНомер телефонаКатегорииЭлементы управления
+ + + + + +
+ + Изменить + + +
+
+ +
+
+
+ +
+ + + + + \ No newline at end of file