blob: fbea98098d01d03600e6221f8853ae87a3bf1020 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package com.mavlushechka.notary.controller;
import com.mavlushechka.notary.model.Request;
import com.mavlushechka.notary.repository.RequestRepository;
import com.mavlushechka.notary.util.EmailSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import javax.mail.MessagingException;
@Controller
public class MainPageController {
@Autowired
private RequestRepository requestRepository;
@GetMapping
public String redirectToHome() {
return "redirect:/";
}
@GetMapping("/")
public String home() {
return "index";
}
@GetMapping("/about-us")
public String aboutUs() {
return "about-us";
}
@GetMapping("/typography")
public String typography() {
return "typography";
}
@GetMapping("/contacts")
public String contacts() {
return "contact-us";
}
@PostMapping("/send-request")
public String sendRequest(String firstName, String secondName, String number, String requestForm, String message) {
requestRepository.save(new Request(firstName, secondName, number, requestForm, message));
return redirectToHome();
}
}
|