add mvc structure
This commit is contained in:
parent
c96cf40dee
commit
7e12068e8b
@ -18,6 +18,14 @@ dependencies {
|
||||
implementation 'com.h2database:h2:2.1.210'
|
||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
|
||||
|
||||
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'
|
||||
}
|
||||
jar {
|
||||
manifest {
|
||||
|
BIN
data.mv.db
BIN
data.mv.db
Binary file not shown.
@ -2,21 +2,20 @@ package com.example.demo;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistration;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.config.annotation.*;
|
||||
|
||||
@Configuration
|
||||
class WebConfiguration implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry){
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
public class WebConfiguration implements WebMvcConfigurer {
|
||||
public static final String REST_API = "/api";
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
ViewControllerRegistration registration = registry.addViewController("/notFound");
|
||||
registration.setViewName("forward:/index.html");
|
||||
registration.setStatusCode(HttpStatus.OK);
|
||||
WebMvcConfigurer.super.addViewControllers(registry);
|
||||
registry.addViewController("appointment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**").allowedMethods("*");
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
|
||||
import com.example.demo.speaker.controller.DTO.AppointmentDTO;
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.service.AppointmentService;
|
||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
||||
import org.springframework.dao.DataIntegrityViolationException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
//import javax.validation.Valid;
|
||||
|
||||
|
@ -1,16 +1,10 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.controller.DTO.CompanyDTO;
|
||||
import com.example.demo.speaker.model.Company;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
import com.example.demo.speaker.service.AppointmentService;
|
||||
import com.example.demo.speaker.service.CompanyService;
|
||||
import com.example.demo.speaker.service.EmployeeService;
|
||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@ -39,7 +33,7 @@ public class CompanyController {
|
||||
return new CompanyDTO(companyService.deleteCompany(id));
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@DeleteMapping("/remove")
|
||||
public void removeAllCompanies() {
|
||||
companyService.deleteAllCompanies();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
package com.example.demo.speaker.controller.DTO;
|
||||
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
package com.example.demo.speaker.controller.DTO;
|
||||
|
||||
import com.example.demo.speaker.model.Company;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
@ -1,10 +1,6 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
package com.example.demo.speaker.controller.DTO;
|
||||
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.OneToOne;
|
||||
|
||||
public class EmployeeDTO {
|
||||
private Long id;
|
@ -1,12 +1,8 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
package com.example.demo.speaker.controller.DTO;
|
||||
|
||||
import com.example.demo.speaker.model.Company;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.FetchType;
|
||||
import jakarta.persistence.OneToOne;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
|
||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
@ -8,7 +9,6 @@ import com.example.demo.speaker.service.RequestForCooperationService;
|
||||
import com.example.demo.speaker.service.EmployeeService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/employee")
|
||||
|
@ -0,0 +1,59 @@
|
||||
package com.example.demo.speaker.controller.MVCController;
|
||||
|
||||
import com.example.demo.speaker.controller.DTO.AppointmentDTO;
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.service.AppointmentService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/appointment")
|
||||
public class AppointmentMVCController
|
||||
{
|
||||
private final AppointmentService appointmentService;
|
||||
|
||||
public AppointmentMVCController(AppointmentService appointmentService) {
|
||||
this.appointmentService = appointmentService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String getAppointments(Model model) {
|
||||
model.addAttribute("appointments",
|
||||
appointmentService.findAllAppointments().stream()
|
||||
.map(AppointmentDTO::new)
|
||||
.toList());
|
||||
return "appointment";
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public String createAppointment(String name, Model model){
|
||||
|
||||
Random r = new Random();
|
||||
var app = new Appointment(r.nextLong(), name);
|
||||
appointmentService.addAppointment(new AppointmentDTO(app));
|
||||
model.addAttribute("appointmentName", name);
|
||||
model.addAttribute("appointmentDTO", new AppointmentDTO(appointmentService.addAppointment(new AppointmentDTO(app))));
|
||||
return "redirect:/appointment";
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("edit/{id}")
|
||||
public String updateMVCAppointment(@PathVariable Long id, @ModelAttribute("appointment") AppointmentDTO appointment,
|
||||
Model model) {
|
||||
//appointmentService.updateAppointment(id, appointment);
|
||||
model.addAttribute("appointmentId", id);
|
||||
model.addAttribute("appointmentDTO", new AppointmentDTO(appointmentService.updateAppointment(id,appointment)));
|
||||
return "redirect:/appointment";
|
||||
}
|
||||
|
||||
@PostMapping("delete/{id}")
|
||||
public String deleteAppointment(@PathVariable Long id) {
|
||||
appointmentService.deleteAppointment(id);
|
||||
return "redirect:/appointment";
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
package com.example.demo.speaker.controller.MVCController;
|
||||
|
||||
import com.example.demo.speaker.controller.DTO.CompanyDTO;
|
||||
import com.example.demo.speaker.model.Company;
|
||||
import com.example.demo.speaker.service.CompanyService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/company")
|
||||
public class CompanyMVCController {
|
||||
private final CompanyService companyService;
|
||||
|
||||
public CompanyMVCController(CompanyService _companyService) {
|
||||
this.companyService = _companyService;
|
||||
}
|
||||
@PostMapping("/create")
|
||||
public CompanyDTO addCompany(@RequestParam("name") String name, @RequestParam("legalAdressCompany") String legalAdressCompany,
|
||||
@RequestParam("adressCompany") String adressCompany,
|
||||
@RequestParam("contactEmail") String contactEmail) {
|
||||
var company = new Company(name, legalAdressCompany, adressCompany, contactEmail);
|
||||
return new CompanyDTO(companyService.addCompany(new CompanyDTO(company)));
|
||||
}
|
||||
|
||||
@PutMapping("/edit/{id}")
|
||||
public String updateCompany(@PathVariable Long id, @ModelAttribute CompanyDTO companyDTO) {
|
||||
companyService.updateCompany(id,companyDTO);
|
||||
return "redirect:company";
|
||||
}
|
||||
|
||||
@PostMapping("delete/{id}")
|
||||
public String removeCompany(@PathVariable Long id) {
|
||||
companyService.deleteCompany(id);
|
||||
return "company";
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String findAllCompanies(Model model) {
|
||||
model.addAttribute("companies", companyService.findAllCompanies()
|
||||
.stream()
|
||||
.map(CompanyDTO::new)
|
||||
.toList());
|
||||
return "company";
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.example.demo.speaker.controller.MVCController;
|
||||
|
||||
import com.example.demo.speaker.controller.DTO.AppointmentDTO;
|
||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
import com.example.demo.speaker.service.AppointmentService;
|
||||
import com.example.demo.speaker.service.EmployeeService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.ui.Model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/employee")
|
||||
public class EmployeeMVCController {
|
||||
private final EmployeeService employeeService;
|
||||
private final AppointmentService appointmentService;
|
||||
|
||||
public List<Appointment> appointments;
|
||||
|
||||
|
||||
public EmployeeMVCController(EmployeeService employeeService, AppointmentService appointmentService) {
|
||||
this.employeeService = employeeService;
|
||||
this.appointmentService = appointmentService;
|
||||
this.appointments = appointmentService.findAllAppointments();
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String getWorkers(Model model) {
|
||||
model.addAttribute("employees",
|
||||
employeeService.findAllWorkers().stream()
|
||||
.map(EmployeeDTO::new)
|
||||
.toList());
|
||||
model.addAttribute("appointments",
|
||||
appointmentService.findAllAppointments().stream().map(AppointmentDTO::new).toList());
|
||||
return "employee";
|
||||
}
|
||||
|
||||
@PostMapping("/create")
|
||||
public String createWorker(@RequestParam("name") String name, @RequestParam("appointmentId") Long appointmentId, Model model) {
|
||||
var Employee = new Employee(name, appointmentService.findAppointment(appointmentId));
|
||||
model.addAttribute("employee",new EmployeeDTO(employeeService.addWorker(new EmployeeDTO(Employee))));
|
||||
return "redirect:employee";
|
||||
}
|
||||
|
||||
@PostMapping("/edit/{id}")
|
||||
public String updateWorker(@PathVariable Long id,@ModelAttribute("employee") EmployeeDTO employee, Model model) {
|
||||
employeeService.updateReportWorker(id, employee);
|
||||
model.addAttribute("employees", employeeService.findAllWorkers());
|
||||
model.addAttribute("appointments", appointmentService.findAllAppointments());
|
||||
return "redirect:employee";
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public String deleteWorker(@PathVariable Long id) {
|
||||
employeeService.deleteWorker(id);
|
||||
return "redirect:/employee";
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.example.demo.speaker.controller.MVCController;
|
||||
|
||||
import com.example.demo.speaker.controller.DTO.CompanyDTO;
|
||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
||||
import com.example.demo.speaker.controller.DTO.RequestForCooperationDTO;
|
||||
import com.example.demo.speaker.model.Company;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
||||
import com.example.demo.speaker.service.CompanyService;
|
||||
import com.example.demo.speaker.service.EmployeeService;
|
||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/request")
|
||||
public class RequestMVCController {
|
||||
private final RequestForCooperationService requestForCooperationService;
|
||||
private final CompanyService companyService;
|
||||
private final EmployeeService employeeService;
|
||||
List<TypeOfRequestEnum> types;
|
||||
List<Employee> employees;
|
||||
List<Company> companies;
|
||||
|
||||
public RequestMVCController(RequestForCooperationService requestForCooperationService, CompanyService companyService, EmployeeService employeeService) {
|
||||
this.requestForCooperationService = requestForCooperationService;
|
||||
this.companyService = companyService;
|
||||
this.employeeService = employeeService;
|
||||
this.types = List.of(TypeOfRequestEnum.TRACKING, TypeOfRequestEnum.DEVELOP);
|
||||
employees = employeeService.findAllWorkers();
|
||||
companies = companyService.findAllCompanies();
|
||||
}
|
||||
|
||||
|
||||
@GetMapping
|
||||
public String getRequests(Model model) {
|
||||
model.addAttribute("requests", requestForCooperationService.findAllRequests()
|
||||
.stream().map(RequestForCooperationDTO::new).toList());
|
||||
model.addAttribute("types", types);
|
||||
model.addAttribute("employees", employees.stream()
|
||||
.map(EmployeeDTO::new).toList());
|
||||
model.addAttribute("companies", companies.stream()
|
||||
.map(CompanyDTO::new).toList());
|
||||
return "request";
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public String createRequest(@PathVariable Long nameCompany,
|
||||
@PathVariable String comment,
|
||||
@PathVariable Integer isActive,
|
||||
@PathVariable Long sort,
|
||||
@PathVariable Long type,
|
||||
Model model
|
||||
){
|
||||
|
||||
//@RequestBody RequestForCooperationDTO requestDTO) {
|
||||
var company = companyService.findCompany(nameCompany);
|
||||
var emp = employeeService.findWorker(sort);
|
||||
var request = new RequestForCooperation(company, new Date(), type == 0 ? TypeOfRequestEnum.DEVELOP : TypeOfRequestEnum.TRACKING, comment);
|
||||
requestForCooperationService.addRequest(new RequestForCooperationDTO(request));
|
||||
return "redirect:request";
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public String updateRequest(@PathVariable Long id,
|
||||
@ModelAttribute RequestForCooperationDTO request,
|
||||
Model model) {
|
||||
requestForCooperationService.updateRequest(request);
|
||||
return "redirect:request";
|
||||
}
|
||||
|
||||
@PostMapping("/delete/{id}")
|
||||
public String deleteRequest(@PathVariable Long id, Model model) {
|
||||
requestForCooperationService.deleteRequest(id);
|
||||
return "redirect:request";
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.example.demo.speaker.controller;
|
||||
|
||||
import com.example.demo.speaker.controller.DTO.RequestForCooperationDTO;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
||||
import com.example.demo.speaker.service.CompanyService;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.example.demo.speaker.service;
|
||||
|
||||
import com.example.demo.speaker.controller.AppointmentDTO;
|
||||
import com.example.demo.speaker.controller.DTO.AppointmentDTO;
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.repository.IAppointmentRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -8,7 +8,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
|
||||
@Service
|
||||
public class AppointmentService {
|
||||
|
@ -1,14 +1,11 @@
|
||||
package com.example.demo.speaker.service;
|
||||
|
||||
import com.example.demo.speaker.controller.CompanyDTO;
|
||||
import com.example.demo.speaker.controller.DTO.CompanyDTO;
|
||||
import com.example.demo.speaker.model.Company;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
import com.example.demo.speaker.model.TypeOfRequestEnum;
|
||||
import com.example.demo.speaker.repository.ICompanyRepository;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.example.demo.speaker.service;
|
||||
|
||||
import com.example.demo.speaker.controller.EmployeeDTO;
|
||||
import com.example.demo.speaker.controller.DTO.EmployeeDTO;
|
||||
import com.example.demo.speaker.model.Appointment;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.example.demo.speaker.service;
|
||||
|
||||
import com.example.demo.speaker.controller.CompanyDTO;
|
||||
import com.example.demo.speaker.controller.RequestForCooperationDTO;
|
||||
import com.example.demo.speaker.controller.DTO.RequestForCooperationDTO;
|
||||
import com.example.demo.speaker.model.Company;
|
||||
import com.example.demo.speaker.model.Employee;
|
||||
import com.example.demo.speaker.model.RequestForCooperation;
|
||||
|
47
src/main/resources/templates/appointment.html
Normal file
47
src/main/resources/templates/appointment.html
Normal file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">Имя</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="appointment, iterator: ${appointments}">
|
||||
<td th:text="${appointment.id}"/>
|
||||
<td ><!--<td th:text="${appointment.name}"/>-->
|
||||
<form th:action="@{/appointment/edit/{id}(id=*{id})}" th:object="${appointment}" th:method="post">
|
||||
<input type="text" class="form-control" id="name" th:value="*{name}" style="width: 60%; display: inline-block" >
|
||||
<button class="btn btn-warning button-fixed button-sm"
|
||||
type="submit" style="display: inline-block"> Изменить
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger button-fixed button-sm" style="display: inline-block"
|
||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${appointment.id}').click()|">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||
</button>
|
||||
</form></td>
|
||||
<!--<td th:text="${appointment.name}" style="width: 60%"/>-->
|
||||
<td style="width: 10%">
|
||||
|
||||
<form th:action="@{/appointment/delete/{id}(id=${appointment.id})}" method="post">
|
||||
<button th:id="'remove-' + ${appointment.id}" type="submit" style="display: none">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
50
src/main/resources/templates/company.html
Normal file
50
src/main/resources/templates/company.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">Компания</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="company, iterator: ${companies}">
|
||||
<td th:text="${company.id}"/>
|
||||
<td ><!--<td th:text="${appointment.name}"/>-->
|
||||
<form th:action="@{/company/edit/{id}(id=*{id})}" th:object="${company}" th:method="post">
|
||||
<input type="text" class="form-control" id="nameCompany" th:value="*{nameCompany}" style="width: 15%; display: inline-block" >
|
||||
<input type="text" class="form-control" id="legalAdressCompany" th:value="*{legalAdressCompany}" style="width: 15%; display: inline-block" >
|
||||
<input type="text" class="form-control" id="adressCompany" th:value="*{adressCompany}" style="width: 15%; display: inline-block" >
|
||||
<input type="text" class="form-control" id="contactEmail" th:value="*{contactEmail}" style="width: 15%; display: inline-block" >
|
||||
<button class="btn btn-warning button-fixed button-sm"
|
||||
type="submit" style="display: inline-block"> Изменить
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger button-fixed button-sm" style="display: inline-block"
|
||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${company.id}').click()|">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||
</button>
|
||||
</form></td>
|
||||
<!--<td th:text="${appointment.name}" style="width: 60%"/>-->
|
||||
<td style="width: 10%">
|
||||
|
||||
<form th:action="@{/company/delete/{id}(id=${company.id})}" method="post">
|
||||
<button th:id="'remove-' + ${company.id}" type="submit" style="display: none">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
50
src/main/resources/templates/default.html
Normal file
50
src/main/resources/templates/default.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru"
|
||||
xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<title>Site of Company</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<link rel="icon" href="/favicon.svg">
|
||||
<script type="text/javascript" src="/webjars/bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
|
||||
<link rel="stylesheet" href="/webjars/bootstrap/5.1.3/css/bootstrap.min.css"/>
|
||||
<link rel="stylesheet" href="/webjars/font-awesome/6.1.0/css/all.min.css"/>
|
||||
<link rel="stylesheet" href="/css/style.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">
|
||||
<i class="fa-solid fa-font-awesome"></i>
|
||||
Site of Company
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button"
|
||||
data-bs-toggle="collapse" data-bs-target="#navbarNav"
|
||||
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarNav">
|
||||
<ul class="navbar-nav"> <!--th:with="activeLink=${#request.requestURI}"-->
|
||||
<a class="nav-link" href="/"
|
||||
th:classappend="${#strings.equals(activeLink, '/')} ? 'active' : ''">Главная</a>
|
||||
<a class="nav-link" href="/appointment"
|
||||
th:classappend="${#strings.equals(activeLink, '/appointment')} ? 'active' : ''">Appointment</a>
|
||||
<a class="nav-link" href="/company"
|
||||
th:classappend="${#strings.equals(activeLink, '/company')} ? 'active' : ''">Company</a>
|
||||
<a class="nav-link" href="/employee"
|
||||
th:classappend="${#strings.equals(activeLink, '/employee')} ? 'active' : ''">Employee</a>
|
||||
<a class="nav-link" href="/request"
|
||||
th:classappend="${#strings.equals(activeLink, '/request')} ? 'active' : ''">Request</a>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div class="container-fluid">
|
||||
<div class="container container-padding" layout:fragment="content">
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<th:block layout:fragment="scripts">
|
||||
</th:block>
|
||||
</html>
|
54
src/main/resources/templates/employee.html
Normal file
54
src/main/resources/templates/employee.html
Normal file
@ -0,0 +1,54 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">Имя</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="employee, iterator: ${employees}">
|
||||
<td th:text="${employee.id}"/>
|
||||
<td ><!--<td th:text="${appointment.name}"/>-->
|
||||
<form th:action="@{/employee/edit/{id}(id=*{id})}" th:object="${employee}" th:method="post">
|
||||
<input type="text" class="form-control" id="fio" th:value="*{fio}" style="width: 30%; display: inline-block" >
|
||||
|
||||
<select id="appointment" class="form-select" th:name="appointment" style="width: 30%; display: inline-block">
|
||||
<option th:each="value: ${appointments}" th:selected="${employee.appointment.name} == ${value.name}">
|
||||
<span th:text="${value.name}"></span>
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<button class="btn btn-warning button-fixed button-sm"
|
||||
type="submit" style="display: inline-block"> Изменить
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger button-fixed button-sm" style="display: inline-block"
|
||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${employee.id}').click()|">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||
</button>
|
||||
</form></td>
|
||||
<!--<td th:text="${appointment.name}" style="width: 60%"/>-->
|
||||
<td style="width: 10%">
|
||||
|
||||
<form th:action="@{/employee/delete/{id}(id=${employee.id})}" method="post">
|
||||
<button th:id="'remove-' + ${employee.id}" type="submit" style="display: none">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
12
src/main/resources/templates/index.html
Normal file
12
src/main/resources/templates/index.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<p>It's works!</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
67
src/main/resources/templates/request.html
Normal file
67
src/main/resources/templates/request.html
Normal file
@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div layout:fragment="content">
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">ID</th>
|
||||
<th scope="col">Заявка</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="request, iterator: ${requests}">
|
||||
<td th:text="${request.id}"/>
|
||||
<td ><!--<td th:text="${appointment.name}"/>-->
|
||||
<form th:action="@{/request/edit/{id}(id=*{id})}" th:object="${request}" th:method="post">
|
||||
<select id="company" class="form-select" th:name="company" style="width: 15%; display: inline-block">
|
||||
<option th:each="value: ${companies}" th:selected="${request.getNameCompany().getNameCompany()} == ${value.nameCompany}">
|
||||
<span th:text="${value.getNameCompany()}"></span>
|
||||
</option>
|
||||
</select>
|
||||
<input type="date" class="form-control" id="createDate" th:value="${request.getCreateDate()}" style="width: 15%; display: inline-block" >
|
||||
<input type="date" class="form-control" id="approveDate" th:value="${request.getApproveDate()}" style="width: 15%; display: inline-block" >
|
||||
<input type="text" class="form-control" id="comment" th:value="${request.getComment()}" style="width: 15%; display: inline-block" >
|
||||
|
||||
<select id="employee" class="form-select" th:name="employee" style="width: 30%; display: inline-block">
|
||||
<option th:each="value: ${employees}" th:selected="${request.getSotr().getFio()} == ${value.getFio()}">
|
||||
<span th:text="${value.getFio()}"></span>
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<select id="types" class="form-select" th:name="type" style="width: 30%; display: inline-block">
|
||||
<option th:each="value: ${types}" th:selected="${request.getType()} == ${value}">
|
||||
<span th:text="${value}"></span>
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<button class="btn btn-warning button-fixed button-sm"
|
||||
type="submit" style="display: inline-block"> Изменить
|
||||
</button>
|
||||
<button type="button" class="btn btn-danger button-fixed button-sm" style="display: inline-block"
|
||||
th:attr="onclick=|confirm('Удалить запись?') && document.getElementById('remove-${employee.id}').click()|">
|
||||
<i class="fa fa-trash" aria-hidden="true"></i> Удалить
|
||||
</button>
|
||||
</form></td>
|
||||
<!--<td th:text="${appointment.name}" style="width: 60%"/>-->
|
||||
<td style="width: 10%">
|
||||
|
||||
<form th:action="@{/employee/delete/{id}(id=${employee.id})}" method="post">
|
||||
<button th:id="'remove-' + ${employee.id}" type="submit" style="display: none">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,27 +1,8 @@
|
||||
package com.example.demo;
|
||||
|
||||
|
||||
import com.example.demo.speaker.controller.AppointmentDTO;
|
||||
import com.example.demo.speaker.model.*;
|
||||
import com.example.demo.speaker.service.CompanyService;
|
||||
import com.example.demo.speaker.service.RequestForCooperationService;
|
||||
import com.example.demo.speaker.service.AppointmentService;
|
||||
import com.example.demo.speaker.service.EmployeeService;
|
||||
import jakarta.persistence.EntityNotFoundException;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@SpringBootTest
|
||||
public class JPATests {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user