1
|
package vldc.aswi.web.controller;
|
2
|
|
3
|
import org.springframework.beans.factory.annotation.Autowired;
|
4
|
import org.springframework.stereotype.Controller;
|
5
|
import org.springframework.ui.ModelMap;
|
6
|
import org.springframework.web.bind.annotation.*;
|
7
|
import org.springframework.web.servlet.ModelAndView;
|
8
|
import vldc.aswi.service.AssemblyManager;
|
9
|
import vldc.aswi.service.SqlQueryManager;
|
10
|
import javax.validation.Valid;
|
11
|
|
12
|
|
13
|
@Controller
|
14
|
public class IndexController {
|
15
|
|
16
|
@Autowired
|
17
|
private SqlQueryManager sqlQueryManager;
|
18
|
|
19
|
@Autowired
|
20
|
private AssemblyManager assemblyManager;
|
21
|
|
22
|
@GetMapping("/")
|
23
|
public ModelAndView index() {
|
24
|
ModelAndView modelAndView = new ModelAndView("index");
|
25
|
|
26
|
ModelMap modelMap = modelAndView.getModelMap();
|
27
|
|
28
|
modelMap.addAttribute("assemblies", assemblyManager.getAssemblies());
|
29
|
|
30
|
return modelAndView;
|
31
|
}
|
32
|
|
33
|
@PostMapping("/")
|
34
|
public ModelAndView indexPost(@Valid @ModelAttribute("assemblyID") String id) {
|
35
|
ModelAndView modelAndView = new ModelAndView();
|
36
|
modelAndView.setViewName("redirect:/assembly");
|
37
|
|
38
|
return modelAndView;
|
39
|
}
|
40
|
|
41
|
@ResponseBody
|
42
|
@RequestMapping("/saveOrder")
|
43
|
public String saveOrder(@RequestBody String data) {
|
44
|
// seřazený idčka záznamů
|
45
|
System.out.println(data);
|
46
|
|
47
|
return "Uloženo";
|
48
|
}
|
49
|
|
50
|
}
|