1 | package com.proekt.Controller;
|
---|
2 |
|
---|
3 |
|
---|
4 | import com.proekt.Repository.NajavaRepository;
|
---|
5 | import com.proekt.Repository.VrabotenRepository1;
|
---|
6 | import com.proekt.Service.EmployeeService;
|
---|
7 | import org.springframework.stereotype.Controller;
|
---|
8 | import org.springframework.ui.Model;
|
---|
9 | import org.springframework.web.bind.annotation.*;
|
---|
10 |
|
---|
11 | @Controller
|
---|
12 | @RequestMapping("/employee")
|
---|
13 | public class Employee {
|
---|
14 |
|
---|
15 | private final VrabotenRepository1 vrabotenRepository1;
|
---|
16 | private final NajavaRepository najavaRepository;
|
---|
17 | private final EmployeeService employeeService;
|
---|
18 |
|
---|
19 | public Employee(VrabotenRepository1 vrabotenRepository1, NajavaRepository najavaRepository, EmployeeService employeeService) {
|
---|
20 | this.vrabotenRepository1 = vrabotenRepository1;
|
---|
21 | this.najavaRepository = najavaRepository;
|
---|
22 | this.employeeService = employeeService;
|
---|
23 | }
|
---|
24 |
|
---|
25 | @GetMapping
|
---|
26 | public String getMoviePage(@RequestParam(required = false) String error, Model model) {
|
---|
27 | if (error != null && !error.isEmpty()) {
|
---|
28 | model.addAttribute("hasError", true);
|
---|
29 | model.addAttribute("error", error);
|
---|
30 | }
|
---|
31 |
|
---|
32 | model.addAttribute("employee", this.vrabotenRepository1.findAll());
|
---|
33 | model.addAttribute("bodyContent", "employee");
|
---|
34 | return "master-template";
|
---|
35 | }
|
---|
36 | @PostMapping("/{id}/delete")
|
---|
37 | public String delete(@PathVariable String id) {
|
---|
38 | this.employeeService.delete(id);
|
---|
39 | return "redirect:/employee";
|
---|
40 | }
|
---|
41 | }
|
---|